Merge pull request #16447 from cassidypignatello/fix/normalize-flash-type
fix(app): Normalize flash typepull/16481/head
commit
5dae72ad7b
|
@ -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.'
|
||||
});
|
||||
|
|
|
@ -281,7 +281,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);
|
||||
|
@ -290,14 +290,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);
|
||||
|
@ -315,7 +315,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);
|
||||
|
@ -395,7 +395,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
|
||||
|
@ -459,13 +459,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.
|
||||
|
@ -479,7 +479,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
|
||||
|
@ -489,7 +489,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.
|
||||
`
|
||||
|
@ -511,7 +511,7 @@ module.exports = function(app) {
|
|||
}
|
||||
);
|
||||
}
|
||||
req.flash('errors', {
|
||||
req.flash('danger', {
|
||||
msg: `Looks like user ${username} is not ${certText[certType]}`
|
||||
});
|
||||
return res.redirect('back');
|
||||
|
@ -576,7 +576,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'});
|
||||
|
|
|
@ -80,7 +80,7 @@ export default function prodErrorHandler() {
|
|||
}
|
||||
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
|
||||
.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')
|
||||
|
|
Loading…
Reference in New Issue