feat: Authentication localization
This commit is contained in:
parent
06035786c9
commit
69c342f80b
@ -20,8 +20,8 @@ const bruteforce = new ExpressBrute(EBstore, {
|
||||
failCallback (req, res, next, nextValidRequestDate) {
|
||||
req.flash('alert', {
|
||||
class: 'error',
|
||||
title: 'Too many attempts!',
|
||||
message: "You've made too many failed attempts in a short period of time, please try again " + moment(nextValidRequestDate).fromNow() + '.',
|
||||
title: lang.t('auth:errors.toomanyattempts'),
|
||||
message: lang.t('auth:errors.toomanyattemptsmsg', { time: moment(nextValidRequestDate).fromNow() }),
|
||||
iconClass: 'fa-times'
|
||||
})
|
||||
res.redirect('/login')
|
||||
@ -71,13 +71,13 @@ router.post('/login', bruteforce.prevent, function (req, res, next) {
|
||||
// LOGIN FAIL
|
||||
if (err.message === 'INVALID_LOGIN') {
|
||||
req.flash('alert', {
|
||||
title: 'Invalid login',
|
||||
message: 'The email or password is invalid.'
|
||||
title: lang.t('auth:errors.invalidlogin'),
|
||||
message: lang.t('auth:errors.invalidloginmsg')
|
||||
})
|
||||
return res.redirect('/login')
|
||||
} else {
|
||||
req.flash('alert', {
|
||||
title: 'Login error',
|
||||
title: lang.t('auth:errors.loginerror'),
|
||||
message: err.message
|
||||
})
|
||||
return res.redirect('/login')
|
||||
|
@ -16,7 +16,7 @@ module.exports = function (passport) {
|
||||
if (user) {
|
||||
done(null, user)
|
||||
} else {
|
||||
done(new Error('User not found.'), null)
|
||||
done(new Error(lang.t('auth:errors:usernotfound')), null)
|
||||
}
|
||||
return true
|
||||
}).catch((err) => {
|
||||
|
@ -1,4 +1,22 @@
|
||||
{
|
||||
"loginrequired": "Login required",
|
||||
"loginusing": "Log in using...",
|
||||
"loginusingalt": "Or, log in using...",
|
||||
"fields": {
|
||||
"emailuser": "Email / Username",
|
||||
"password": "Password"
|
||||
},
|
||||
"actions": {
|
||||
"login": "Log In"
|
||||
},
|
||||
"errors": {
|
||||
"invalidlogin": "Invalid Login",
|
||||
"invalidloginmsg": "The email or password is invalid.",
|
||||
"loginerror": "Login error",
|
||||
"toomanyattempts": "Too many attempts!",
|
||||
"toomanyattemptsmsg": "You've made too many failed attempts in a short period of time, please try again {{time}}.",
|
||||
"usernotfound": "User not found"
|
||||
},
|
||||
"providers": {
|
||||
"local": "Local",
|
||||
"windowslive": "Microsoft Account",
|
||||
@ -9,4 +27,4 @@
|
||||
"slack": "Slack",
|
||||
"ldap": "LDAP / Active Directory"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
19
server/locales/en/errors.json
Normal file
19
server/locales/en/errors.json
Normal file
@ -0,0 +1,19 @@
|
||||
{
|
||||
"generic": "Oops, something went wrong",
|
||||
"notexistdetail": "Would you like to create this entry?",
|
||||
"forbidden": "Forbidden",
|
||||
"forbiddendetail": "Sorry, you don't have the necessary permissions to access this page.",
|
||||
"unauthorized": "Unauthorized",
|
||||
"debugmsg": "Detailed debug trail",
|
||||
"invalidaction": "Invalid Action.",
|
||||
"invalidpath": "Invalid page path.",
|
||||
"invaliduserid": "Invalid User Id",
|
||||
"reservedname": "You cannot create a document with this name as it is reserved by the system.",
|
||||
"alreadyexists": "This entry already exists!",
|
||||
"starterfailed": "Could not load starter content!",
|
||||
"actions": {
|
||||
"create": "Create",
|
||||
"gohome": "Go Home",
|
||||
"loginas": "Login as..."
|
||||
}
|
||||
}
|
@ -26,7 +26,7 @@ html(data-logic='login')
|
||||
div(style='background-image:url(/images/bg_' + bg + '.jpg);')
|
||||
#root
|
||||
h1= appconfig.title
|
||||
h2 Login required
|
||||
h2= t('auth:loginrequired')
|
||||
if appflash.length > 0
|
||||
h3
|
||||
i.icon-warning-outline
|
||||
@ -34,39 +34,39 @@ html(data-logic='login')
|
||||
h4= appflash[0].message
|
||||
if appconfig.auth.local.enabled
|
||||
form(method='post', action='/login')
|
||||
input#login-user(type='text', name='email', placeholder='Email / Username')
|
||||
input#login-pass(type='password', name='password', placeholder='Password')
|
||||
button(type='submit') Log In
|
||||
input#login-user(type='text', name='email', placeholder=t('auth:fields.emailuser'))
|
||||
input#login-pass(type='password', name='password', placeholder=t('auth:fields.password'))
|
||||
button(type='submit')= t('auth:actions.login')
|
||||
if appconfig.authStrategies.socialEnabled
|
||||
#social
|
||||
if appconfig.auth.local.enabled
|
||||
span Or, log in using...
|
||||
span= t('auth:loginusingalt')
|
||||
else
|
||||
span Log in using...
|
||||
span= t('auth:loginusing')
|
||||
if appconfig.auth.microsoft && appconfig.auth.microsoft.enabled
|
||||
button.ms(onclick='window.location.assign("/login/ms")')
|
||||
i.icon-windows2
|
||||
span Microsoft Account
|
||||
span= t('auth:providers.windowslive')
|
||||
if appconfig.auth.azure && appconfig.auth.azure.enabled
|
||||
button.ms(onclick='window.location.assign("/login/azure")')
|
||||
i.icon-windows2
|
||||
span Azure AD
|
||||
span= t('auth:providers.azure')
|
||||
if appconfig.auth.google && appconfig.auth.google.enabled
|
||||
button.google(onclick='window.location.assign("/login/google")')
|
||||
i.icon-google
|
||||
span Google ID
|
||||
span= t('auth:providers.google')
|
||||
if appconfig.auth.facebook && appconfig.auth.facebook.enabled
|
||||
button.facebook(onclick='window.location.assign("/login/facebook")')
|
||||
i.icon-facebook
|
||||
span Facebook
|
||||
span= t('auth:providers.facebook')
|
||||
if appconfig.auth.github && appconfig.auth.github.enabled
|
||||
button.github(onclick='window.location.assign("/login/github")')
|
||||
i.icon-github
|
||||
span GitHub
|
||||
span= t('auth:providers.github')
|
||||
if appconfig.auth.slack && appconfig.auth.slack.enabled
|
||||
button.slack(onclick='window.location.assign("/login/slack")')
|
||||
i.icon-slack
|
||||
span Slack
|
||||
span= t('auth:providers.slack')
|
||||
#copyright
|
||||
= t('footer.poweredby') + ' '
|
||||
a.icon(href='https://github.com/Requarks/wiki')
|
||||
|
Loading…
Reference in New Issue
Block a user