66 <?php include __DIR__ . '/../common-head-elements.php ' ?>
77
88 <script src="mfa-u2f-api.js"></script>
9- <script src="bowser.1.8.0.min.js"></script>
109
1110 <script>
12- function isU2fSupported() {
13- var isSupported = (bowser.chrome && bowser.version >= 41) ||
14- (bowser.firefox && bowser.version >= 58) ||
15- (bowser.opera && bowser.version >= 39);
16-
17- var nodeToShow = isSupported ? document.querySelector('#supported') :
18- document.querySelector('#unsupported');
19-
20- nodeToShow.classList.remove('hide');
21-
22- return isSupported;
23- }
24-
2511 function verifyU2f() {
2612 var u2fSignRequest = <?= json_encode ($ this ->data ['mfaOption ' ]['data ' ]) ?> || {};
2713
28- u2f.sign(u2fSignRequest.appId, u2fSignRequest.challenge, [u2fSignRequest],
29- handleU2fResponse);
14+ u2f.sign(u2fSignRequest.appId, u2fSignRequest.challenge, [u2fSignRequest], handleU2fResponse);
3015 }
3116
3217 function handleU2fResponse(u2fResponse) {
@@ -101,7 +86,10 @@ function createHiddenInput(name) {
10186 }
10287 </script>
10388</head>
104- <body class="gradient-bg" onload="if (isU2fSupported()) verifyU2f()">
89+
90+ <?php $ isU2fSupported = $ this ->data ['supportsU2f ' ]; ?>
91+
92+ <body class="gradient-bg" onload="<?= $ isU2fSupported ? 'verifyU2f() ' : '' ?> ">
10593<div class="mdl-layout mdl-layout--fixed-header fill-viewport">
10694 <header class="mdl-layout__header">
10795 <div class="mdl-layout__header-row">
@@ -125,17 +113,19 @@ class="icon">
125113 </h1>
126114 </div>
127115
128- <div class="mdl-card__title center hide" id="supported">
129- <p class="mdl-card__subtitle-text center">
116+ <?php if ($ isU2fSupported ): ?>
117+ <div class="mdl-card__title">
118+ <p class="mdl-card__subtitle-text">
130119 <?= $ this ->t ('{material:mfa:u2f_instructions} ' ) ?>
131120 </p>
132121 </div>
133-
134- <div class="mdl-card__title hide" id="unsupported ">
122+ <?php else : ?>
123+ <div class="mdl-card__title">
135124 <p class="mdl-typography--text-center mdl-color-text--red">
136125 <?= $ this ->t ('{material:mfa:u2f_unsupported} ' ) ?>
137126 </p>
138127 </div>
128+ <?php endif ; ?>
139129
140130 <?php
141131 $ message = $ this ->data ['errorMessage ' ];
0 commit comments