@@ -10,6 +10,9 @@ import { BasicStrategy } from 'passport-http';
10
10
11
11
import User from '../models/user' ;
12
12
13
+ const accountSuspensionMessage =
14
+ 'Account has been suspended. Please contact privacy@p5js.org if you believe this is an error.' ;
15
+
13
16
function generateUniqueUsername ( username ) {
14
17
const adj =
15
18
friendlyWords . predicates [
@@ -39,9 +42,7 @@ passport.use(
39
42
done ( null , false , { msg : `Email ${ email } not found.` } ) ;
40
43
return ;
41
44
} else if ( user . banned ) {
42
- const msg =
43
- 'Account has been suspended. Please contact privacy@p5js.org if you believe this is an error.' ;
44
- done ( null , false , { msg } ) ;
45
+ done ( null , false , { msg : accountSuspensionMessage } ) ;
45
46
return ;
46
47
}
47
48
user . comparePassword ( password , ( innerErr , isMatch ) => {
@@ -71,9 +72,7 @@ passport.use(
71
72
return ;
72
73
}
73
74
if ( user . banned ) {
74
- const msg =
75
- 'Account has been suspended. Please contact privacy@p5js.org if you believe this is an error.' ;
76
- done ( null , false , { msg } ) ;
75
+ done ( null , false , { msg : accountSuspensionMessage } ) ;
77
76
return ;
78
77
}
79
78
user . findMatchingKey ( key , ( innerErr , isMatch , keyDocument ) => {
@@ -129,9 +128,7 @@ passport.use(
129
128
) ;
130
129
return ;
131
130
} else if ( existingUser . banned ) {
132
- const msg =
133
- 'Account has been suspended. Please contact privacy@p5js.org if you believe this is an error.' ;
134
- done ( new Error ( msg ) ) ;
131
+ done ( new Error ( accountSuspensionMessage ) ) ;
135
132
return ;
136
133
}
137
134
done ( null , existingUser ) ;
@@ -140,7 +137,6 @@ passport.use(
140
137
141
138
const emails = getVerifiedEmails ( profile . emails ) ;
142
139
const primaryEmail = getPrimaryEmail ( profile . emails ) ;
143
- console . log ( profile ) ;
144
140
145
141
if ( req . user ) {
146
142
if ( ! req . user . github ) {
@@ -162,6 +158,10 @@ passport.use(
162
158
} else {
163
159
[ existingEmailUser ] = existingEmailUsers ;
164
160
}
161
+ if ( existingEmailUser . banned ) {
162
+ done ( new Error ( accountSuspensionMessage ) ) ;
163
+ return ;
164
+ }
165
165
existingEmailUser . email = existingEmailUser . email || primaryEmail ;
166
166
existingEmailUser . github = profile . id ;
167
167
existingEmailUser . username =
@@ -225,9 +225,7 @@ passport.use(
225
225
) ;
226
226
return ;
227
227
} else if ( existingUser . banned ) {
228
- const msg =
229
- 'Account has been suspended. Please contact privacy@p5js.org if you believe this is an error.' ;
230
- done ( new Error ( msg ) ) ;
228
+ done ( new Error ( accountSuspensionMessage ) ) ;
231
229
return ;
232
230
}
233
231
done ( null , existingUser ) ;
@@ -257,6 +255,10 @@ passport.use(
257
255
// what if a username is already taken from the display name too?
258
256
// then, append a random friendly word?
259
257
if ( existingEmailUser ) {
258
+ if ( existingEmailUser . banned ) {
259
+ done ( new Error ( accountSuspensionMessage ) ) ;
260
+ return ;
261
+ }
260
262
existingEmailUser . email =
261
263
existingEmailUser . email || primaryEmail ;
262
264
existingEmailUser . google = profile . _json . emails [ 0 ] . value ;
0 commit comments