fix(api): reorder certificate early returns (#47656)

This commit is contained in:
Shaun Hamilton
2022-09-29 19:42:34 +01:00
committed by GitHub
parent 2c4b0adf41
commit 3a4640b678
+25 -24
View File
@@ -357,6 +357,7 @@ function createShowCert(app) {
const certTitle = certTypeTitleMap[certType];
const completionTime = completionHours[certType] || 300;
return findUserByUsername$(username, {
isBanned: true,
isCheater: true,
isFrontEndCert: true,
isBackEndCert: true,
@@ -393,18 +394,7 @@ function createShowCert(app) {
}
const { isLocked, showCerts, showName, showTimeLine } = user.profileUI;
if (!user.name) {
return res.json({
messages: [
{
type: 'info',
message: 'flash.add-name'
}
]
});
}
if (user.isCheater) {
if (user.isCheater || user.isBanned) {
return res.json({
messages: [
{
@@ -415,6 +405,18 @@ function createShowCert(app) {
});
}
if (!user.isHonest) {
return res.json({
messages: [
{
type: 'info',
message: 'flash.not-honest',
variables: { username: username }
}
]
});
}
if (isLocked) {
return res.json({
messages: [
@@ -427,6 +429,17 @@ function createShowCert(app) {
});
}
if (!user.name) {
return res.json({
messages: [
{
type: 'info',
message: 'flash.add-name'
}
]
});
}
if (!showCerts) {
return res.json({
messages: [
@@ -439,18 +452,6 @@ function createShowCert(app) {
});
}
if (!user.isHonest) {
return res.json({
messages: [
{
type: 'info',
message: 'flash.not-honest',
variables: { username: username }
}
]
});
}
if (!showTimeLine) {
return res.json({
messages: [