Skip to content

Commit c0e6908

Browse files
committed
fix: fixed checkVerifiedEmail to only invoke next() if necessary
1 parent 2dd366d commit c0e6908

1 file changed

Lines changed: 13 additions & 4 deletions

File tree

index.js

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ class Policies {
5050
this.ensureTurnstile = this.ensureTurnstile.bind(this);
5151
}
5252

53+
// eslint-disable-next-line complexity
5354
async checkVerifiedEmail(ctx, next) {
5455
if (!ctx.isAuthenticated()) {
5556
ctx.session.returnTo = ctx.originalUrl || ctx.req.url;
@@ -86,16 +87,24 @@ class Policies {
8687
return;
8788
}
8889

89-
if (!this.config.userFields.hasVerifiedEmail) return next();
90+
if (!this.config.userFields.hasVerifiedEmail) {
91+
if (next) return next();
92+
return;
93+
}
9094

91-
if (ctx.state.user[this.config.userFields.hasVerifiedEmail]) return next();
95+
if (ctx.state.user[this.config.userFields.hasVerifiedEmail]) {
96+
if (next) return next();
97+
return;
98+
}
9299

93100
if (
94101
typeof ctx.pathWithoutLocale === 'string'
95102
? ctx.pathWithoutLocale === this.config.verifyRoute
96103
: ctx.path === this.config.verifyRoute
97-
)
98-
return next();
104+
) {
105+
if (next) return next();
106+
return;
107+
}
99108

100109
const message = ctx.translate
101110
? ctx.translate('EMAIL_VERIFICATION_REQUIRED')

0 commit comments

Comments
 (0)