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) {
|
failCallback (req, res, next, nextValidRequestDate) {
|
||||||
req.flash('alert', {
|
req.flash('alert', {
|
||||||
class: 'error',
|
class: 'error',
|
||||||
title: 'Too many attempts!',
|
title: lang.t('auth:errors.toomanyattempts'),
|
||||||
message: "You've made too many failed attempts in a short period of time, please try again " + moment(nextValidRequestDate).fromNow() + '.',
|
message: lang.t('auth:errors.toomanyattemptsmsg', { time: moment(nextValidRequestDate).fromNow() }),
|
||||||
iconClass: 'fa-times'
|
iconClass: 'fa-times'
|
||||||
})
|
})
|
||||||
res.redirect('/login')
|
res.redirect('/login')
|
||||||
@ -71,13 +71,13 @@ router.post('/login', bruteforce.prevent, function (req, res, next) {
|
|||||||
// LOGIN FAIL
|
// LOGIN FAIL
|
||||||
if (err.message === 'INVALID_LOGIN') {
|
if (err.message === 'INVALID_LOGIN') {
|
||||||
req.flash('alert', {
|
req.flash('alert', {
|
||||||
title: 'Invalid login',
|
title: lang.t('auth:errors.invalidlogin'),
|
||||||
message: 'The email or password is invalid.'
|
message: lang.t('auth:errors.invalidloginmsg')
|
||||||
})
|
})
|
||||||
return res.redirect('/login')
|
return res.redirect('/login')
|
||||||
} else {
|
} else {
|
||||||
req.flash('alert', {
|
req.flash('alert', {
|
||||||
title: 'Login error',
|
title: lang.t('auth:errors.loginerror'),
|
||||||
message: err.message
|
message: err.message
|
||||||
})
|
})
|
||||||
return res.redirect('/login')
|
return res.redirect('/login')
|
||||||
|
@ -16,7 +16,7 @@ module.exports = function (passport) {
|
|||||||
if (user) {
|
if (user) {
|
||||||
done(null, user)
|
done(null, user)
|
||||||
} else {
|
} else {
|
||||||
done(new Error('User not found.'), null)
|
done(new Error(lang.t('auth:errors:usernotfound')), null)
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
}).catch((err) => {
|
}).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": {
|
"providers": {
|
||||||
"local": "Local",
|
"local": "Local",
|
||||||
"windowslive": "Microsoft Account",
|
"windowslive": "Microsoft Account",
|
||||||
@ -9,4 +27,4 @@
|
|||||||
"slack": "Slack",
|
"slack": "Slack",
|
||||||
"ldap": "LDAP / Active Directory"
|
"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);')
|
div(style='background-image:url(/images/bg_' + bg + '.jpg);')
|
||||||
#root
|
#root
|
||||||
h1= appconfig.title
|
h1= appconfig.title
|
||||||
h2 Login required
|
h2= t('auth:loginrequired')
|
||||||
if appflash.length > 0
|
if appflash.length > 0
|
||||||
h3
|
h3
|
||||||
i.icon-warning-outline
|
i.icon-warning-outline
|
||||||
@ -34,39 +34,39 @@ html(data-logic='login')
|
|||||||
h4= appflash[0].message
|
h4= appflash[0].message
|
||||||
if appconfig.auth.local.enabled
|
if appconfig.auth.local.enabled
|
||||||
form(method='post', action='/login')
|
form(method='post', action='/login')
|
||||||
input#login-user(type='text', name='email', placeholder='Email / Username')
|
input#login-user(type='text', name='email', placeholder=t('auth:fields.emailuser'))
|
||||||
input#login-pass(type='password', name='password', placeholder='Password')
|
input#login-pass(type='password', name='password', placeholder=t('auth:fields.password'))
|
||||||
button(type='submit') Log In
|
button(type='submit')= t('auth:actions.login')
|
||||||
if appconfig.authStrategies.socialEnabled
|
if appconfig.authStrategies.socialEnabled
|
||||||
#social
|
#social
|
||||||
if appconfig.auth.local.enabled
|
if appconfig.auth.local.enabled
|
||||||
span Or, log in using...
|
span= t('auth:loginusingalt')
|
||||||
else
|
else
|
||||||
span Log in using...
|
span= t('auth:loginusing')
|
||||||
if appconfig.auth.microsoft && appconfig.auth.microsoft.enabled
|
if appconfig.auth.microsoft && appconfig.auth.microsoft.enabled
|
||||||
button.ms(onclick='window.location.assign("/login/ms")')
|
button.ms(onclick='window.location.assign("/login/ms")')
|
||||||
i.icon-windows2
|
i.icon-windows2
|
||||||
span Microsoft Account
|
span= t('auth:providers.windowslive')
|
||||||
if appconfig.auth.azure && appconfig.auth.azure.enabled
|
if appconfig.auth.azure && appconfig.auth.azure.enabled
|
||||||
button.ms(onclick='window.location.assign("/login/azure")')
|
button.ms(onclick='window.location.assign("/login/azure")')
|
||||||
i.icon-windows2
|
i.icon-windows2
|
||||||
span Azure AD
|
span= t('auth:providers.azure')
|
||||||
if appconfig.auth.google && appconfig.auth.google.enabled
|
if appconfig.auth.google && appconfig.auth.google.enabled
|
||||||
button.google(onclick='window.location.assign("/login/google")')
|
button.google(onclick='window.location.assign("/login/google")')
|
||||||
i.icon-google
|
i.icon-google
|
||||||
span Google ID
|
span= t('auth:providers.google')
|
||||||
if appconfig.auth.facebook && appconfig.auth.facebook.enabled
|
if appconfig.auth.facebook && appconfig.auth.facebook.enabled
|
||||||
button.facebook(onclick='window.location.assign("/login/facebook")')
|
button.facebook(onclick='window.location.assign("/login/facebook")')
|
||||||
i.icon-facebook
|
i.icon-facebook
|
||||||
span Facebook
|
span= t('auth:providers.facebook')
|
||||||
if appconfig.auth.github && appconfig.auth.github.enabled
|
if appconfig.auth.github && appconfig.auth.github.enabled
|
||||||
button.github(onclick='window.location.assign("/login/github")')
|
button.github(onclick='window.location.assign("/login/github")')
|
||||||
i.icon-github
|
i.icon-github
|
||||||
span GitHub
|
span= t('auth:providers.github')
|
||||||
if appconfig.auth.slack && appconfig.auth.slack.enabled
|
if appconfig.auth.slack && appconfig.auth.slack.enabled
|
||||||
button.slack(onclick='window.location.assign("/login/slack")')
|
button.slack(onclick='window.location.assign("/login/slack")')
|
||||||
i.icon-slack
|
i.icon-slack
|
||||||
span Slack
|
span= t('auth:providers.slack')
|
||||||
#copyright
|
#copyright
|
||||||
= t('footer.poweredby') + ' '
|
= t('footer.poweredby') + ' '
|
||||||
a.icon(href='https://github.com/Requarks/wiki')
|
a.icon(href='https://github.com/Requarks/wiki')
|
||||||
|
Loading…
Reference in New Issue
Block a user