Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
simplesamlphp-module-privacyidea
Manage
Activity
Members
Labels
Plan
Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Perun
Perun ProxyIdP
simplesamlphp-module-privacyidea
Commits
7c4d8faa
Verified
Commit
7c4d8faa
authored
3 years ago
by
Pavel Břoušek
Browse files
Options
Downloads
Patches
Plain Diff
fix: allow translation of JS alerts
parent
16001418
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
dictionaries/privacyidea.definition.json
+18
-0
18 additions, 0 deletions
dictionaries/privacyidea.definition.json
templates/loginform.php
+16
-2
16 additions, 2 deletions
templates/loginform.php
www/js/loginform.js
+10
-6
10 additions, 6 deletions
www/js/loginform.js
with
44 additions
and
8 deletions
dictionaries/privacyidea.definition.json
+
18
−
0
View file @
7c4d8faa
...
...
@@ -41,6 +41,24 @@
"alternate_login_options"
:
{
"en"
:
"Alternate login options:"
},
"alert_webauthn_insecure_context"
:
{
"en"
:
"Unable to proceed with Web Authn because the context is insecure!"
},
"alert_webauthn_unavailable"
:
{
"en"
:
"Could not load WebAuthn library. Please try again or use other token."
},
"alert_webAuthnSignRequest_error"
:
{
"en"
:
"Error while signing WebAuthnSignRequest:"
},
"alert_u2f_insecure_context"
:
{
"en"
:
"Unable to proceed with U2F because the context is insecure!"
},
"alert_u2f_unavailable"
:
{
"en"
:
"Could not load U2F library. Please try again or use other token."
},
"alert_U2FSignRequest_error"
:
{
"en"
:
"Error while signing U2FSignRequest:"
},
"tryAgain"
:
{
"en"
:
"Try Again"
}
...
...
This diff is collapsed.
Click to expand it.
templates/loginform.php
+
16
−
2
View file @
7c4d8faa
...
...
@@ -272,8 +272,6 @@ if (!empty($this->data['links']))
}
echo
'</ul>'
;
}
$this
->
includeAtTemplateBase
(
'includes/footer.php'
);
?>
<script
src=
"
<?php
echo
htmlspecialchars
(
SimpleSAML_Module
::
getModuleUrl
(
'privacyidea/js/webauthn.js'
),
ENT_QUOTES
)
?>
"
>
...
...
@@ -289,5 +287,21 @@ $this->includeAtTemplateBase('includes/footer.php');
&&
((
$this
->
data
[
'webAuthnSignRequest'
])
==
""
)
)
?
'true'
:
'false'
;
?>
"
>
<meta
id=
"privacyidea-translations"
name=
"privacyidea-translations"
content=
"
<?php
$translations
=
[];
$translation_keys
=
[
'alert_webauthn_insecure_context'
,
'alert_webauthn_unavailable'
,
'alert_webAuthnSignRequest_error'
,
'alert_u2f_insecure_context'
,
'alert_u2f_unavailable'
,
'alert_U2FSignRequest_error'
,
];
foreach
(
$translation_keys
as
$translation_key
)
{
$translations
[
$translation_key
]
=
$this
->
t
(
sprintf
(
'{privacyidea:privacyidea:%s}'
,
$translation_key
));
}
echo
htmlspecialchars
(
json_encode
(
$translations
));
?>
"
>
<script
src=
"
<?php
echo
htmlspecialchars
(
SimpleSAML_Module
::
getModuleUrl
(
'privacyidea/js/loginform.js'
),
ENT_QUOTES
)
?>
"
>
</script>
<?php
$this
->
includeAtTemplateBase
(
'includes/footer.php'
);
?>
This diff is collapsed.
Click to expand it.
www/js/loginform.js
+
10
−
6
View file @
7c4d8faa
...
...
@@ -55,6 +55,10 @@ function changeMode(newMode)
document
.
forms
[
"
piLoginForm
"
].
submit
();
}
function
t
(
key
)
{
return
JSON
.
parse
(
document
.
getElementById
(
"
privacyidea-translations
"
).
content
)[
key
];
}
const
step
=
document
.
getElementById
(
"
privacyidea-step
"
).
content
;
if
(
step
>
"
1
"
)
...
...
@@ -142,7 +146,7 @@ function doWebAuthn()
if
(
!
window
.
isSecureContext
)
{
alert
(
"
Unable to proceed with Web Authn because the context is insecure!
"
);
alert
(
t
(
"
alert_webauthn_insecure_context
"
)
);
console
.
log
(
"
Insecure context detected: Aborting Web Authn authentication!
"
)
changeMode
(
"
otp
"
);
return
;
...
...
@@ -150,7 +154,7 @@ function doWebAuthn()
if
(
!
window
.
pi_webauthn
)
{
alert
(
"
Could not load W
eb
A
uthn
library. Please try again or use other token.
"
);
alert
(
t
(
"
alert_w
eb
a
uthn
_unavailable
"
)
);
changeMode
(
"
otp
"
);
return
;
}
...
...
@@ -180,7 +184,7 @@ function doWebAuthn()
}
catch
(
err
)
{
console
.
log
(
"
Error while signing WebAuthnSignRequest:
"
+
err
);
alert
(
"
Error while signing W
ebAuthnSignRequest
:
"
+
err
);
alert
(
t
(
"
alert_w
ebAuthnSignRequest
_error
"
)
+
"
"
+
err
);
}
}
...
...
@@ -194,7 +198,7 @@ function doU2F()
if
(
!
window
.
isSecureContext
)
{
alert
(
"
Unable to proceed with U2F because the context is insecure!
"
);
alert
(
t
(
"
alert_u2f_insecure_context
"
)
);
console
.
log
(
"
Insecure context detected: Aborting U2F authentication!
"
)
changeMode
(
"
otp
"
);
return
;
...
...
@@ -204,7 +208,7 @@ function doU2F()
if
(
requestStr
===
null
)
{
alert
(
"
Could not load U2F library. Please try again or use other token.
"
);
alert
(
t
(
"
alert_u2f_unavailable
"
)
);
changeMode
(
"
otp
"
);
return
;
}
...
...
@@ -216,7 +220,7 @@ function doU2F()
}
catch
(
err
)
{
console
.
log
(
"
Error while signing U2FSignRequest:
"
+
err
);
alert
(
"
Error while signing
U2FSignRequest
:
"
+
err
);
alert
(
t
(
"
alert_
U2FSignRequest
_error
"
)
+
"
"
+
err
);
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment