mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-05-28 18:26:54 +00:00
fix(api): reorder certificate early returns (#47656)
This commit is contained in:
@@ -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: [
|
||||
|
||||
Reference in New Issue
Block a user