|
| 1 | +# Login Templates |
| 2 | + |
| 3 | +This package ships with a number of built-in templates for displaying the |
| 4 | +"login" page when a user is unauthorized; these are in the `templates/` |
| 5 | +subdirectory, and map to the `oauth2clientauthentication::401` template. |
| 6 | + |
| 7 | +The templates provided expose links for each of the GitHub, Google, and (when |
| 8 | +enabled) Debug providers. Further, they are written using [Bootstrap |
| 9 | +theming](http://getbootstrap.com). As such, you will likely want to override |
| 10 | +them. |
| 11 | + |
| 12 | +Below, we demonstrate each of the default shipped versions. |
| 13 | + |
| 14 | +## Plates |
| 15 | + |
| 16 | +```php |
| 17 | +<?php $this->layout('layout::layout', [ |
| 18 | + 'title' => 'Unauthorized', |
| 19 | +]); ?> |
| 20 | + |
| 21 | +<section class="col-md-8 col-md-offset-2 code_401"> |
| 22 | + <h2>Unauthorized</h2> |
| 23 | + |
| 24 | + <p> |
| 25 | + You are not logged in, and therefore cannot perform this action. |
| 26 | + </p> |
| 27 | + |
| 28 | + <p> |
| 29 | + Login to continue: |
| 30 | + <p> |
| 31 | + |
| 32 | + <div class="btn-group-vertical" role="group"> |
| 33 | + <a class="btn btn-default" href="<?= $auth_path ?>/github?redirect=<?= $redirect ?>">GitHub</a> |
| 34 | + <a class="btn btn-default" href="<?= $auth_path ?>/google?redirect=<?= $redirect ?>">Google</a> |
| 35 | + <?php if ($debug) : ?> |
| 36 | + <a class="btn btn-default" href="<?= $auth_path ?>/debug?redirect=<?= $redirect ?>">Debug</a> |
| 37 | + <?php endif ?> |
| 38 | + </div> |
| 39 | +</section> |
| 40 | +``` |
| 41 | + |
| 42 | +## Twig |
| 43 | + |
| 44 | +```twig |
| 45 | +{% extends '@layout/default.html.twig' %} |
| 46 | +
|
| 47 | +{% block title %}404 Not Found{% endblock %} |
| 48 | +
|
| 49 | +{% block content %} |
| 50 | +<section class="col-md-8 col-md-offset-2 code_401"> |
| 51 | + <h2>Unauthorized</h2> |
| 52 | +
|
| 53 | + <p> |
| 54 | + You are not logged in, and therefore cannot perform this action. |
| 55 | + </p> |
| 56 | +
|
| 57 | + <p> |
| 58 | + Login to continue: |
| 59 | + <p> |
| 60 | +
|
| 61 | + <div class="btn-group-vertical" role="group"> |
| 62 | + <a class="btn btn-default" href="{{ auth_path }}/github?redirect={{ redirect }}">GitHub</a> |
| 63 | + <a class="btn btn-default" href="{{ auth_path }}/google?redirect={{ redirect }}">Google</a> |
| 64 | + {% if debug is defined %} |
| 65 | + <a class="btn btn-default" href="{{ auth_path }}/debug?redirect={{ redirect }}">Debug</a> |
| 66 | + {% endif %} |
| 67 | + </div> |
| 68 | +</section> |
| 69 | +{% endblock %} |
| 70 | +``` |
| 71 | + |
| 72 | +## zend-view |
| 73 | + |
| 74 | +```php |
| 75 | +<?php $this->headTitle('Unauthorized') ?> |
| 76 | + |
| 77 | +<section class="col-md-8 col-md-offset-2 code_401"> |
| 78 | + <h2>Unauthorized</h2> |
| 79 | + |
| 80 | + <p> |
| 81 | + You are not logged in, and therefore cannot perform this action. |
| 82 | + </p> |
| 83 | + |
| 84 | + <p> |
| 85 | + Login to continue: |
| 86 | + <p> |
| 87 | + |
| 88 | + <div class="btn-group-vertical" role="group"> |
| 89 | + <a class="btn btn-default" href="<?= $this->auth_path ?>/github?redirect=<?= $this->redirect ?>">GitHub</a> |
| 90 | + <a class="btn btn-default" href="<?= $this->auth_path ?>/google?redirect=<?= $this->redirect ?>">Google</a> |
| 91 | + <?php if ($debug) : ?> |
| 92 | + <a class="btn btn-default" href="<?= $this->auth_path ?>/debug?redirect=<?= $this->redirect ?>">Debug</a> |
| 93 | + <?php endif ?> |
| 94 | + </div> |
| 95 | +</section> |
| 96 | +``` |
| 97 | + |
| 98 | +## Mustache |
| 99 | + |
| 100 | +This example can be used via the |
| 101 | +[phly-expressive-mustache](https://github.com/phly/phly-expressive-mustache) |
| 102 | +renderer for zend-expressive-template: |
| 103 | + |
| 104 | +```mustache |
| 105 | +{{<layout::layout}} |
| 106 | +{{$title}}Unauthorized{{/title}} |
| 107 | +{{$content}} |
| 108 | +<section class="col-md-8 col-md-offset-2 code_401"> |
| 109 | + <h2>Unauthorized</h2> |
| 110 | +
|
| 111 | + <p> |
| 112 | + You are not logged in, and therefore cannot perform this action. |
| 113 | + </p> |
| 114 | +
|
| 115 | + <p> |
| 116 | + Login to continue: |
| 117 | + <p> |
| 118 | +
|
| 119 | + <div class="btn-group-vertical" role="group"> |
| 120 | + <a class="btn btn-default" href="{{auth_path}}/github?redirect={{redirect}}">GitHub</a> |
| 121 | + <a class="btn btn-default" href="{{auth_path}}/google?redirect={{redirect}}">Google</a> |
| 122 | + {{#debug}} |
| 123 | + <a class="btn btn-default" href="{{auth_path}}/debug?redirect={{redirect}}">Debug</a> |
| 124 | + {{/debug}} |
| 125 | + </div> |
| 126 | +</section> |
| 127 | +{{/content}} |
| 128 | +{{/layout::layout}} |
| 129 | +``` |
0 commit comments