|
4 | 4 |
|
5 | 5 | $this->data['u2fAvailable'] = !empty($this->data['u2fSignRequest']); |
6 | 6 | $this->data['webauthnAvailable'] = !empty($this->data['webAuthnSignRequest']); |
7 | | -$this->data['pushAvailable'] = $this->data['pushAvailable'] ?? false; |
8 | | - |
9 | 7 | $this->data['mode'] = ($this->data['mode'] ?? null) ?: 'otp'; |
10 | 8 | $this->data['noAlternatives'] = true; |
11 | | -foreach (['webauthn', 'otp', 'push', 'u2f'] as $mode) { |
| 9 | +foreach (['otp', 'push', 'u2f', 'webauthn'] as $mode) { |
12 | 10 | if ($mode !== $this->data['mode'] && $this->data[$mode . 'Available']) { |
13 | 11 | $this->data['noAlternatives'] = false; |
14 | 12 | break; |
|
25 | 23 | } |
26 | 24 |
|
27 | 25 | // Set the right text shown in otp/pass field(s) |
28 | | -$otpHint = $this->data['otpFieldHint'] ?? $this->t('{privacyidea:privacyidea:otp}'); |
29 | | -$passHint = $this->data['passFieldHint'] ?? $this->t('{privacyidea:privacyidea:password}'); |
| 26 | +if (isset($this->data['otpFieldHint'])) { |
| 27 | + $otpHint = $this->data['otpFieldHint']; |
| 28 | +} else { |
| 29 | + $otpHint = $this->t('{privacyidea:privacyidea:otp}'); |
| 30 | +} |
| 31 | +if (isset($this->data['passFieldHint'])) { |
| 32 | + $passHint = $this->data['passFieldHint']; |
| 33 | +} else { |
| 34 | + $passHint = $this->t('{privacyidea:privacyidea:password}'); |
| 35 | +} |
30 | 36 |
|
31 | 37 | $this->data['header'] = $this->t('{privacyidea:privacyidea:login_title_challenge}'); |
32 | 38 |
|
|
40 | 46 | $this->data['head'] .= '<link rel="stylesheet" href="' |
41 | 47 | . htmlspecialchars(Module::getModuleUrl('privacyidea/css/loginform.css'), ENT_QUOTES) |
42 | 48 | . '" media="screen" />'; |
| 49 | +$this->data['head'] .= '<link rel="stylesheet" href="' |
| 50 | + . htmlspecialchars(Module::getModuleUrl('perun/res/css/privacyidea.css'), ENT_QUOTES) |
| 51 | + . '" media="screen" />'; |
43 | 52 |
|
44 | 53 | $this->includeAtTemplateBase('includes/header.php'); |
45 | 54 |
|
46 | 55 | // Prepare error case to show it in UI if needed |
47 | 56 | if (null !== $this->data['errorCode']) { |
48 | 57 | ?> |
| 58 | + |
49 | 59 | <div class="alert alert-dismissable alert-danger" role="alert"> |
50 | | - <button type="button" class="close" data-dismiss="alert" aria-label="Close"> |
| 60 | + <button type="button" class="close" data-dismiss="alert" aria-label="<?php echo $this->t('{perun:privacyidea:close}'); ?>"> |
51 | 61 | <span aria-hidden="true">×</span> |
52 | 62 | </button> |
53 | 63 | <h2 class="alert-heading"><?php echo $this->t('{login:error_header}'); ?></h2> |
54 | 64 | <p> |
55 | | - <?php |
56 | | - echo htmlspecialchars( |
| 65 | + <?php |
| 66 | + echo htmlspecialchars( |
57 | 67 | sprintf('%s%s: %s', $this->t( |
58 | 68 | '{privacyidea:privacyidea:error}' |
59 | 69 | ), $this->data['errorCode'] ? (' ' . $this->data['errorCode']) : '', $this->data['errorMessage']) |
|
64 | 74 | <?php |
65 | 75 | } // end of errorcode |
66 | 76 | ?> |
| 77 | + |
67 | 78 | <p><?php echo $this->t('{perun:privacyidea:info_text}'); ?></p> |
68 | 79 | <form action="FormReceiver.php" method="POST" id="piLoginForm" name="piLoginForm" class="loginForm"> |
69 | 80 | <div class="row"> |
70 | 81 | <?php if ($this->data['webauthnAvailable']) { ?> |
71 | | - <div class="<?php echo (!$this->data['noAlternatives']) ? 'col-md-6' : 'col-sm-12'; ?>"> |
72 | | - <h2><?php echo $this->t('{perun:privacyidea:webauthn}'); ?></h2> |
73 | | - <div> |
74 | | - <button id="useWebAuthnButton" name="useWebAuthnButton" class="btn btn-primary btn-block text-nowrap" type="button"><?php echo $this->t('{perun:privacyidea:webauthn_btn}'); ?></button> |
75 | | - </div> |
76 | | - <div id="message" role="alert"> |
77 | | - <?php |
| 82 | + <div class="col-md-6"> |
| 83 | + <h2><?php echo $this->t('{privacyidea:privacyidea:webauthn}'); ?></h2> |
| 84 | + <p id="message" role="alert"><?php |
78 | 85 | $messageOverride = $this->data['messageOverride'] ?? null; |
79 | 86 | if (null === $messageOverride || is_string($messageOverride)) { |
80 | 87 | echo htmlspecialchars($messageOverride ?? $this->data['message'] ?? '', ENT_QUOTES); |
81 | 88 | } elseif (is_callable($messageOverride)) { |
82 | 89 | echo call_user_func($messageOverride, $this->data['message'] ?? ''); |
83 | 90 | } |
84 | | - ?> |
85 | | - </div> |
| 91 | + ?></p> |
| 92 | + <p> |
| 93 | + <button id="useWebAuthnButton" name="useWebAuthnButton" class="btn btn-primary btn-s" type="button"> |
| 94 | + <span><?php echo $this->t('{privacyidea:privacyidea:webauthn}'); ?></span> |
| 95 | + </button> |
| 96 | + </p> |
86 | 97 | </div> |
87 | 98 | <?php } ?> |
88 | 99 |
|
89 | 100 | <?php if ($this->data['otpAvailable'] ?? true) { ?> |
90 | | - <div class="<?php echo (!$this->data['noAlternatives']) ? 'col-md-6' : 'col-sm-12'; ?>"> |
| 101 | + <div class="col-md-6"> |
91 | 102 | <h2><?php echo $this->t('{privacyidea:privacyidea:otp}'); ?></h2> |
92 | 103 | <p><?php echo $this->t('{perun:privacyidea:otp_help}'); ?></p> |
93 | 104 | <div class="form-row"> |
94 | | - <div class="form-group col-sm-12 <?php echo (!$this->data['noAlternatives']) ? '' : 'col-md-6'; ?>"> |
95 | | - <label for="otp" class="sr-only"><?php echo $this->t('{perun:privacyidea:otp}'); ?></label> |
96 | | - <input id="otp" name="otp" tabindex="1" value="" class="form-control" autocomplete="one-time-code" type="text" inputmode="numeric" pattern="[0-9]{6,}" required placeholder="<?php echo htmlspecialchars($otpHint, ENT_QUOTES); ?>"/> |
| 105 | + <div class="form-group col-sm-12 col-md-6"> |
| 106 | + <label for="otp" class="sr-only"><?php echo $this->t('{privacyidea:privacyidea:otp}'); ?></label> |
| 107 | + <input id="otp" name="otp" tabindex="1" value="" class="form-control" autocomplete="one-time-code" type="text" inputmode="numeric" pattern="[0-9]{6,}" required placeholder="<?php echo htmlspecialchars($otpHint, ENT_QUOTES); ?>"<?php if ($this->data['noAlternatives']) { |
| 108 | + echo ' autofocus'; |
| 109 | + } ?> /> |
97 | 110 | </div> |
98 | | - <div class="form-group col-sm-12 <?php echo (!$this->data['noAlternatives']) ? '' : 'col-md-6'; ?>"> |
99 | | - <button id="submitButton" tabindex="1" class="btn btn-primary btn-block text-nowrap" type="submit" name="Submit"><?php echo htmlspecialchars($this->t('{perun:privacyidea:otp_submit_btn}'), ENT_QUOTES); ?></button> |
| 111 | + <div class="form-group col-sm-12 col-md-6"> |
| 112 | + <button id="submitButton" tabindex="1" class="btn btn-primary btn-block text-nowrap" type="submit" name="Submit"> |
| 113 | + <span><?php echo htmlspecialchars($this->t('{login:login_button}'), ENT_QUOTES); ?></span> |
| 114 | + </button> |
100 | 115 | </div> |
101 | 116 | </div> |
102 | 117 | </div> |
103 | 118 | <?php } ?> |
104 | | - </div> |
105 | 119 |
|
106 | | - <!-- Undefined index is suppressed and the default is used for these values --> |
107 | | - <input id="mode" type="hidden" name="mode" value="otp" data-preferred="<?php echo htmlspecialchars($this->data['mode'], ENT_QUOTES); ?>"/> |
108 | | - <input id="pushAvailable" type="hidden" name="pushAvailable" value="<?php echo ($this->data['pushAvailable'] ?? false) ? 'true' : ''; ?>"/> |
109 | | - <input id="otpAvailable" type="hidden" name="otpAvailable" value="<?php echo ($this->data['otpAvailable'] ?? true) ? 'true' : ''; ?>"/> |
110 | | - <input id="webAuthnSignRequest" type="hidden" name="webAuthnSignRequest" value='<?php echo htmlspecialchars($this->data['webAuthnSignRequest'] ?? '', ENT_QUOTES); ?>'/> |
111 | | - <input id="u2fSignRequest" type="hidden" name="u2fSignRequest" value='<?php echo htmlspecialchars($this->data['u2fSignRequest'] ?? '', ENT_QUOTES); ?>'/> |
112 | | - <input id="modeChanged" type="hidden" name="modeChanged" value=""/> |
113 | | - <input id="step" type="hidden" name="step" value="<?php echo htmlspecialchars(strval(($this->data['step'] ?? null) ?: 2), ENT_QUOTES); ?>"/> |
114 | | - <input id="webAuthnSignResponse" type="hidden" name="webAuthnSignResponse" value=""/> |
115 | | - <input id="u2fSignResponse" type="hidden" name="u2fSignResponse" value=""/> |
116 | | - <input id="origin" type="hidden" name="origin" value=""/> |
117 | | - <input id="loadCounter" type="hidden" name="loadCounter" value="<?php echo htmlspecialchars(strval(($this->data['loadCounter'] ?? null) ?: 1), ENT_QUOTES); ?>"/> |
118 | | - |
119 | | - <!-- Additional input to persist the message --> |
120 | | - <input type="hidden" name="message" value="<?php echo htmlspecialchars($this->data['message'] ?? '', ENT_QUOTES); ?>"/> |
| 120 | + <!-- Undefined index is suppressed and the default is used for these values --> |
| 121 | + <input id="mode" type="hidden" name="mode" value="otp" |
| 122 | + data-preferred="<?php echo htmlspecialchars($this->data['mode'], ENT_QUOTES); ?>"/> |
| 123 | + |
| 124 | + <input id="pushAvailable" type="hidden" name="pushAvailable" |
| 125 | + value="<?php echo ($this->data['pushAvailable'] ?? false) ? 'true' : ''; ?>"/> |
| 126 | + |
| 127 | + <input id="otpAvailable" type="hidden" name="otpAvailable" |
| 128 | + value="<?php echo ($this->data['otpAvailable'] ?? true) ? 'true' : ''; ?>"/> |
| 129 | + |
| 130 | + <input id="webAuthnSignRequest" type="hidden" name="webAuthnSignRequest" |
| 131 | + value='<?php echo htmlspecialchars($this->data['webAuthnSignRequest'] ?? '', ENT_QUOTES); ?>'/> |
| 132 | + |
| 133 | + <input id="u2fSignRequest" type="hidden" name="u2fSignRequest" |
| 134 | + value='<?php echo htmlspecialchars($this->data['u2fSignRequest'] ?? '', ENT_QUOTES); ?>'/> |
| 135 | + |
| 136 | + <input id="modeChanged" type="hidden" name="modeChanged" value=""/> |
| 137 | + <input id="step" type="hidden" name="step" |
| 138 | + value="<?php echo htmlspecialchars(strval(($this->data['step'] ?? null) ?: 2), ENT_QUOTES); ?>"/> |
| 139 | + |
| 140 | + <input id="webAuthnSignResponse" type="hidden" name="webAuthnSignResponse" value=""/> |
| 141 | + <input id="u2fSignResponse" type="hidden" name="u2fSignResponse" value=""/> |
| 142 | + <input id="origin" type="hidden" name="origin" value=""/> |
| 143 | + <input id="loadCounter" type="hidden" name="loadCounter" |
| 144 | + value="<?php echo htmlspecialchars(strval(($this->data['loadCounter'] ?? null) ?: 1), ENT_QUOTES); ?>"/> |
| 145 | + |
| 146 | + <!-- Additional input to persist the message --> |
| 147 | + <input type="hidden" name="message" |
| 148 | + value="<?php echo htmlspecialchars($this->data['message'] ?? '', ENT_QUOTES); ?>"/> |
| 149 | + </div> <!-- row --> |
121 | 150 | </form> |
| 151 | + |
122 | 152 | <script src="<?php echo htmlspecialchars(Module::getModuleUrl('privacyidea/js/pi-webauthn.js'), ENT_QUOTES); ?>"> |
123 | 153 | </script> |
124 | 154 |
|
|
151 | 181 | echo htmlspecialchars(json_encode($translations)); |
152 | 182 | ?>"> |
153 | 183 |
|
154 | | -<script src="<?php echo htmlspecialchars(Module::getModuleUrl('privacyidea/js/loginform.js'), ENT_QUOTES); ?>"></script> |
155 | | -<script src="<?php echo htmlspecialchars(Module::getModuleUrl('perun/js/privacy-idea-loginform.js'), ENT_QUOTES); ?>"></script> |
| 184 | +<script src="<?php echo htmlspecialchars(Module::getModuleUrl('privacyidea/js/loginform.js'), ENT_QUOTES); ?>"> |
| 185 | +</script> |
| 186 | +<script src="<?php echo htmlspecialchars(Module::getModuleUrl('perun/res/js/privacyidea.js'), ENT_QUOTES); ?>"> |
| 187 | +</script> |
156 | 188 |
|
157 | 189 | <?php |
158 | 190 | $this->includeAtTemplateBase('includes/footer.php'); |
|
0 commit comments