File tree 2 files changed +28
-3
lines changed
2 files changed +28
-3
lines changed Original file line number Diff line number Diff line change @@ -436,7 +436,9 @@ class VerificationController extends Controller {
436
436
! entry . metadata ||
437
437
typeof entry . metadata !== "object" ||
438
438
! ( "emailToken" in entry . metadata ) ||
439
- entry . metadata . emailToken !== emailToken
439
+ entry . metadata . emailToken !== emailToken ||
440
+ ! ( "email" in entry . metadata ) ||
441
+ entry . metadata . email !== email
440
442
) {
441
443
return new Response ( {
442
444
status : 403 ,
@@ -448,10 +450,11 @@ class VerificationController extends Controller {
448
450
. service ( "verificationService" )
449
451
. verifyWithEntry ( entry , {
450
452
email,
453
+ emailToken,
451
454
method : VerificationMethod . EMAIL
452
455
} ) ;
453
456
454
- if ( ! result ) {
457
+ if ( ! result || result . error === "invalid_email" ) {
455
458
return new Response ( {
456
459
status : 403 ,
457
460
body : { error : "We're unable to verify you, please try again." }
Original file line number Diff line number Diff line change @@ -199,11 +199,32 @@ class VerificationService extends Service {
199
199
return null ;
200
200
}
201
201
202
+ if ( payload . method === VerificationMethod . EMAIL ) {
203
+ if (
204
+ typeof entry . metadata !== "object" ||
205
+ ! entry . metadata ||
206
+ ! ( "email" in entry . metadata ) ||
207
+ ! ( "emailToken" in entry . metadata ) ||
208
+ entry . metadata . email !== payload . email ||
209
+ entry . metadata . emailToken !== payload . emailToken
210
+ ) {
211
+ return {
212
+ error : "invalid_email"
213
+ } ;
214
+ }
215
+
216
+ if ( payload . emailToken ) {
217
+ delete payload . emailToken ;
218
+ }
219
+ }
220
+
202
221
const existingRecord = await this . application . prisma . verificationRecord . findFirst ( {
203
222
where : {
204
223
guildId : guild . id ,
205
224
userId : entry . userId ,
206
- ...payload
225
+ ...( payload as {
226
+ email ?: string ;
227
+ } )
207
228
}
208
229
} ) ;
209
230
@@ -309,6 +330,7 @@ export type VerificationPayload = {
309
330
googleId ?: string ;
310
331
discordId ?: string ;
311
332
email ?: string ;
333
+ emailToken ?: string ;
312
334
method : VerificationMethod ;
313
335
} ;
314
336
You can’t perform that action at this time.
0 commit comments