Finish server-side translations in controllers
This commit is contained in:
@@ -21,7 +21,7 @@ class Forms extends FormController {
|
||||
|
||||
return res.page('auth:login', {
|
||||
...this.Vue.data({
|
||||
login_message: req.session?.auth?.message || 'Please sign-in to continue.',
|
||||
login_message: req.session?.auth?.message || req.T('auth.sign_in_to_continue'),
|
||||
registration_enabled: await Setting.get('auth.allow_registration')
|
||||
}),
|
||||
})
|
||||
@@ -29,7 +29,7 @@ class Forms extends FormController {
|
||||
|
||||
async logout_provider_present_success(req, res, next) {
|
||||
return this.Vue.auth_message(res, {
|
||||
message: 'You have been successfully logged out.',
|
||||
message: req.T('auth.logged_out'),
|
||||
next_destination: '/',
|
||||
})
|
||||
}
|
||||
|
||||
@@ -9,8 +9,8 @@ class MFAController extends Controller {
|
||||
if ( req.user.mfa_enabled ) {
|
||||
// Already set up!
|
||||
return this.Vue.auth_message(res, {
|
||||
message: 'It looks like your account is already set up for multi-factor authentication. Unable to continue with MFA setup.',
|
||||
next_destination: '/', // TODO update this
|
||||
message: req.T('auth.already_mfa'),
|
||||
next_destination: '/dash/profile',
|
||||
button_text: 'Okay',
|
||||
})
|
||||
}
|
||||
@@ -24,7 +24,7 @@ class MFAController extends Controller {
|
||||
async challenge(req, res, next) {
|
||||
if ( !req.user.mfa_enabled ) {
|
||||
return this.Vue.auth_message(res, {
|
||||
message: 'Your account is not configured to use multi-factor authentication. Would you like to configure it now?',
|
||||
message: req.T('auth.mfa_prompt'),
|
||||
next_destination: '/auth/mfa/setup',
|
||||
button_text: 'Setup MFA',
|
||||
})
|
||||
@@ -42,7 +42,7 @@ class MFAController extends Controller {
|
||||
|
||||
async get_disable(req, res, next) {
|
||||
return this.Vue.confirm(res, {
|
||||
message: `You are about to disable multi-factor authentication for your account. This process will require you to re-authenticate to continue. <br><br> Proceed?`,
|
||||
message: req.T('auth.mfa_disable_prompt'),
|
||||
yes: '/auth/mfa/disable/process',
|
||||
no: '/dash/profile',
|
||||
})
|
||||
@@ -61,7 +61,7 @@ class MFAController extends Controller {
|
||||
|| !Array.isArray(req.user.mfa_token.recovery_codes)
|
||||
|| req.user.mfa_token.recovery_codes.length < 1
|
||||
) return this.Vue.auth_message(res, {
|
||||
message: 'Unfortunately, it looks like your account does not have any MFA recovery codes generated.',
|
||||
message: req.T('auth.mfa_no_recovery'),
|
||||
next_destination: '/auth/mfa/challenge',
|
||||
button_text: 'Go Back',
|
||||
})
|
||||
|
||||
@@ -13,7 +13,7 @@ class Oauth2 extends Oauth2Controller {
|
||||
|
||||
async authorize_post(req, res, next) {
|
||||
const client = await this._get_authorize_client({query: req.body})
|
||||
if ( !client ) return this._uniform(res, 'Unable to authorize client application. The application config is invalid. Please check the client ID and redirect URI and try again.')
|
||||
if ( !client ) return this._uniform(res, req.T('unable_to_authorize'))
|
||||
|
||||
const StarshipClient = this.models.get('oauth:Client')
|
||||
const starship_client = await StarshipClient.findOne({ active: true, uuid: client.clientID })
|
||||
@@ -25,7 +25,7 @@ class Oauth2 extends Oauth2Controller {
|
||||
|
||||
async authorize_get(req, res, next) {
|
||||
const client = await this._get_authorize_client(req)
|
||||
if ( !client ) return this._uniform(res, 'Unable to authorize client application. The application config is invalid. Please check the client ID and redirect URI and try again.')
|
||||
if ( !client ) return this._uniform(res, req.T('unable_to_authorize'))
|
||||
const uri = new URL(req.query.redirect_uri)
|
||||
|
||||
const StarshipClient = this.models.get('oauth:Client')
|
||||
@@ -46,18 +46,18 @@ class Oauth2 extends Oauth2Controller {
|
||||
...this.Vue.data({
|
||||
message: `<h3 class="font-weight-light">Authorize ${client.name}?</h3>
|
||||
<br>
|
||||
${client.name} is requesting access to your ${this.configs.get('app.name')} account. Once you grant it, you may not be prompted for permission again.
|
||||
${req.T('auth.oauth_prompt').replace('CLIENT_NAME', client.name).replace('APP_NAME', this.configs.get('app.name'))}
|
||||
<br><br><br>
|
||||
<i><small>You will be redirected to: ${uri.host}</small></i>`,
|
||||
<i><small>${req.T('auth.will_redirect')} ${uri.host}</small></i>`,
|
||||
|
||||
actions: [
|
||||
{
|
||||
text: 'Deny',
|
||||
text: req.T('common.deny'),
|
||||
action: 'redirect',
|
||||
next: '/dash',
|
||||
},
|
||||
{
|
||||
text: 'Grant Access',
|
||||
text: req.T('common.grant'),
|
||||
action: 'post',
|
||||
params: {
|
||||
redirect_uri: uri.toString(),
|
||||
|
||||
@@ -13,7 +13,7 @@ class TrustController extends Controller {
|
||||
*/
|
||||
async get_issue(req, res, next) {
|
||||
if ( !req.trust.has_flow() )
|
||||
return res.status(400).message('Missing trust flow data.').send()
|
||||
return res.status(400).message(req.T('auth.missing_trust_flow')).send()
|
||||
|
||||
// Check if the session already has a token for this scope
|
||||
const has_scope = req.trust.has(req.trust.flow_scope())
|
||||
@@ -28,22 +28,11 @@ class TrustController extends Controller {
|
||||
return res.page('auth:trust:grant', {
|
||||
...this.Vue.data({
|
||||
grant_code: token,
|
||||
login_message: 'Please re-authenticate to continue.',
|
||||
login_message: req.T('auth.reauth_to_continue'),
|
||||
}),
|
||||
...this.Vue.session(req)
|
||||
})
|
||||
}
|
||||
|
||||
/*async get_continue(req, res, next) {
|
||||
if ( !req.trust.has_flow() )
|
||||
return res.status(400).message('Missing trust flow data.')
|
||||
|
||||
if ( !req.trust.in_progress() )
|
||||
return res.status(401).message('No flow in progress. Please try again.')
|
||||
|
||||
req.trust.grant(req.trust.flow_scope())
|
||||
return res.redirect(req.trust.end())
|
||||
}*/
|
||||
}
|
||||
|
||||
module.exports = exports = TrustController
|
||||
|
||||
Reference in New Issue
Block a user