fix(app): Normalize flash type
Changed flash messages to use types provided by Bootstrap Closes #16395
This commit is contained in:
@ -238,7 +238,7 @@ module.exports = function(User) {
|
||||
return User.findById(uid, (err, user) => {
|
||||
|
||||
if (err || !user || !user.newEmail) {
|
||||
ctx.req.flash('error', {
|
||||
ctx.req.flash('danger', {
|
||||
msg: dedent`Oops, something went wrong, please try again later`
|
||||
});
|
||||
return ctx.res.redirect('/');
|
||||
@ -309,7 +309,7 @@ module.exports = function(User) {
|
||||
return next();
|
||||
}
|
||||
|
||||
req.flash('error', {
|
||||
req.flash('danger', {
|
||||
msg: dedent`
|
||||
The ${req.body.email} email address is already associated with an account.
|
||||
Try signing in with it here instead.
|
||||
@ -320,7 +320,7 @@ module.exports = function(User) {
|
||||
})
|
||||
.catch(err => {
|
||||
console.error(err);
|
||||
req.flash('error', {
|
||||
req.flash('danger', {
|
||||
msg: 'Oops, something went wrong, please try again later'
|
||||
});
|
||||
return res.redirect('/email-signin');
|
||||
@ -376,7 +376,7 @@ module.exports = function(User) {
|
||||
var res = ctx.res;
|
||||
var req = ctx.req;
|
||||
|
||||
req.flash('errors', {
|
||||
req.flash('danger', {
|
||||
msg: 'Invalid username or password.'
|
||||
});
|
||||
return res.redirect('/email-signin');
|
||||
|
@ -261,7 +261,7 @@ export default function(app) {
|
||||
!completedChallenge.githubLink
|
||||
)
|
||||
) {
|
||||
req.flash('errors', {
|
||||
req.flash('danger', {
|
||||
msg: 'You haven\'t supplied the necessary URLs for us to inspect ' +
|
||||
'your work.'
|
||||
});
|
||||
|
@ -424,7 +424,7 @@ module.exports = function(app) {
|
||||
|
||||
let social = req.params.social;
|
||||
if (!social) {
|
||||
req.flash('errors', {
|
||||
req.flash('danger', {
|
||||
msg: 'No social account found'
|
||||
});
|
||||
return res.redirect('/' + username);
|
||||
@ -433,14 +433,14 @@ module.exports = function(app) {
|
||||
social = social.toLowerCase();
|
||||
const validSocialAccounts = ['twitter', 'linkedin'];
|
||||
if (validSocialAccounts.indexOf(social) === -1) {
|
||||
req.flash('errors', {
|
||||
req.flash('danger', {
|
||||
msg: 'Invalid social account'
|
||||
});
|
||||
return res.redirect('/' + username);
|
||||
}
|
||||
|
||||
if (!user[social]) {
|
||||
req.flash('errors', {
|
||||
req.flash('danger', {
|
||||
msg: `No ${social} account associated`
|
||||
});
|
||||
return res.redirect('/' + username);
|
||||
@ -458,7 +458,7 @@ module.exports = function(app) {
|
||||
// assumed user identity is unique by provider
|
||||
let identity = identities.shift();
|
||||
if (!identity) {
|
||||
req.flash('errors', {
|
||||
req.flash('danger', {
|
||||
msg: 'No social account found'
|
||||
});
|
||||
return res.redirect('/' + username);
|
||||
@ -538,7 +538,7 @@ module.exports = function(app) {
|
||||
}, {});
|
||||
|
||||
if (userPortfolio.isCheater && !user) {
|
||||
req.flash('errors', {
|
||||
req.flash('danger', {
|
||||
msg: dedent`
|
||||
Upon review, this account has been flagged for academic
|
||||
dishonesty. If you’re the owner of this account contact
|
||||
@ -597,13 +597,13 @@ module.exports = function(app) {
|
||||
.subscribe(
|
||||
user => {
|
||||
if (!user) {
|
||||
req.flash('errors', {
|
||||
req.flash('danger', {
|
||||
msg: `We couldn't find a user with the username ${username}`
|
||||
});
|
||||
return res.redirect('/');
|
||||
}
|
||||
if (!user.isGithubCool) {
|
||||
req.flash('errors', {
|
||||
req.flash('danger', {
|
||||
msg: dedent`
|
||||
This user needs to link GitHub with their account
|
||||
in order for others to be able to view their certificate.
|
||||
@ -617,7 +617,7 @@ module.exports = function(app) {
|
||||
}
|
||||
|
||||
if (user.isLocked) {
|
||||
req.flash('errors', {
|
||||
req.flash('danger', {
|
||||
msg: dedent`
|
||||
${username} has chosen to make their profile
|
||||
private. They will need to make their profile public
|
||||
@ -627,7 +627,7 @@ module.exports = function(app) {
|
||||
return res.redirect('back');
|
||||
}
|
||||
if (!user.isHonest) {
|
||||
req.flash('errors', {
|
||||
req.flash('danger', {
|
||||
msg: dedent`
|
||||
${username} has not yet agreed to our Academic Honesty Pledge.
|
||||
`
|
||||
@ -649,7 +649,7 @@ module.exports = function(app) {
|
||||
}
|
||||
);
|
||||
}
|
||||
req.flash('errors', {
|
||||
req.flash('danger', {
|
||||
msg: `Looks like user ${username} is not ${certText[certType]}`
|
||||
});
|
||||
return res.redirect('back');
|
||||
@ -714,7 +714,7 @@ module.exports = function(app) {
|
||||
const report = req.sanitize('reportDescription').trimTags();
|
||||
|
||||
if (!username || !report || report === '') {
|
||||
req.flash('errors', {
|
||||
req.flash('danger', {
|
||||
msg: 'Oops, something is not right please re-check your submission.'
|
||||
});
|
||||
return next();
|
||||
|
@ -23,7 +23,7 @@ export default function redirectLang(app) {
|
||||
}
|
||||
|
||||
if (type === 'html') {
|
||||
req.flash('errors', {
|
||||
req.flash('danger', {
|
||||
msg: `We couldn't find path ${ path }`
|
||||
});
|
||||
return res.render('404', { title: '404'});
|
||||
|
@ -30,7 +30,7 @@ export default function prodErrorHandler() {
|
||||
if (type === 'html') {
|
||||
if (typeof req.flash === 'function') {
|
||||
req.flash(
|
||||
handled.type || 'errors',
|
||||
handled.type || 'danger',
|
||||
{ msg: message }
|
||||
);
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ export default function flashCheaters() {
|
||||
EXCLUDED_PATHS.indexOf(req.path) === -1 &&
|
||||
req.user && req.url !== '/' && req.user.isCheater
|
||||
) {
|
||||
req.flash('errors', {
|
||||
req.flash('danger', {
|
||||
msg: dedent`
|
||||
Upon review, this account has been flagged for academic
|
||||
dishonesty. If you’re the owner of this account contact
|
||||
|
@ -1,4 +1,4 @@
|
||||
export function ifNoUserRedirectTo(url, message, type = 'errors') {
|
||||
export function ifNoUserRedirectTo(url, message, type = 'danger') {
|
||||
return function(req, res, next) {
|
||||
const { path } = req;
|
||||
if (req.user) {
|
||||
@ -35,7 +35,7 @@ export function ifNotVerifiedRedirectToSettings(req, res, next) {
|
||||
return next();
|
||||
}
|
||||
if (!user.emailVerified) {
|
||||
req.flash('error', {
|
||||
req.flash('danger', {
|
||||
msg: 'We do not have your verified email address on record, '
|
||||
+ 'please add it in the settings to continue with your request.'
|
||||
});
|
||||
|
@ -1,12 +1,12 @@
|
||||
.container
|
||||
.row.flashMessage.negative-30
|
||||
.col-xs-12.col-sm-8.col-sm-offset-2.col-md-6.col-md-offset-3
|
||||
if (messages.errors || messages.error)
|
||||
if (messages.danger)
|
||||
.alert.alert-danger.fade.in
|
||||
button.close(type='button', data-dismiss='alert')
|
||||
span.ion-close-circled
|
||||
for error in (messages.errors || messages.error)
|
||||
div!= error.msg || error
|
||||
for danger in (messages.danger)
|
||||
div!= danger.msg || danger
|
||||
if messages.info
|
||||
.alert.alert-info.fade.in
|
||||
button.close(type='button', data-dismiss='alert')
|
||||
|
Reference in New Issue
Block a user