@@ -36,7 +36,7 @@ import sendEmailVerification from "./send-email-verification";
36
36
export default async function setEmailAddress (
37
37
account_id : string ,
38
38
email_address : string ,
39
- password : string
39
+ password : string ,
40
40
) : Promise < void > {
41
41
if ( ! isValidUUID ( account_id ) ) {
42
42
throw Error ( "account_id is not valid" ) ;
@@ -52,7 +52,7 @@ export default async function setEmailAddress(
52
52
const pool = getPool ( ) ;
53
53
const { rows } = await pool . query (
54
54
"SELECT email_address, password_hash, email_address_verified, stripe_customer_id FROM accounts WHERE account_id=$1" ,
55
- [ account_id ]
55
+ [ account_id ] ,
56
56
) ;
57
57
if ( rows . length == 0 ) {
58
58
throw Error ( "no such account" ) ;
@@ -73,7 +73,7 @@ export default async function setEmailAddress(
73
73
if ( ! password_hash ) {
74
74
await pool . query (
75
75
"UPDATE accounts SET password_hash=$1, WHERE account_id=$2" ,
76
- [ passwordHash ( password ) , account_id ]
76
+ [ passwordHash ( password ) , account_id ] ,
77
77
) ;
78
78
}
79
79
throw new Error ( `You are not allowed to change your email address` ) ;
@@ -82,15 +82,15 @@ export default async function setEmailAddress(
82
82
// you're also not allowed to change your email address to one that's covered by an exclusive strategy
83
83
if ( checkRequiredSSO ( { strategies, email : email_address } ) != null ) {
84
84
throw new Error (
85
- `You are not allowed to change your email address to this one`
85
+ `You are not allowed to change your email address to this one` ,
86
86
) ;
87
87
}
88
88
89
89
if ( ! password_hash ) {
90
90
// setting both the email_address *and* password at once.
91
91
await pool . query (
92
92
"UPDATE accounts SET password_hash=$1, email_address=$2 WHERE account_id=$3" ,
93
- [ passwordHash ( password ) , email_address , account_id ]
93
+ [ passwordHash ( password ) , email_address , account_id ] ,
94
94
) ;
95
95
return ;
96
96
}
@@ -104,12 +104,12 @@ export default async function setEmailAddress(
104
104
(
105
105
await pool . query (
106
106
"SELECT COUNT(*)::INT FROM accounts WHERE email_address=$1" ,
107
- [ email_address ]
107
+ [ email_address ] ,
108
108
)
109
109
) . rows [ 0 ] . count > 0
110
110
) {
111
111
throw Error (
112
- `email address "${ email_address } " is already in use by another account`
112
+ `email address "${ email_address } " is already in use by another account` ,
113
113
) ;
114
114
}
115
115
@@ -120,7 +120,7 @@ export default async function setEmailAddress(
120
120
] ) ;
121
121
122
122
// Do any pending account creation actions for this email.
123
- await accountCreationActions ( email_address , account_id ) ;
123
+ await accountCreationActions ( { email_address, account_id } ) ;
124
124
await creationActionsDone ( account_id ) ;
125
125
126
126
// sync new email address with stripe
@@ -130,7 +130,7 @@ export default async function setEmailAddress(
130
130
await stripe . update_database ( ) ;
131
131
} catch ( err ) {
132
132
console . warn (
133
- `ERROR syncing new email address with stripe: ${ err } – ignoring`
133
+ `ERROR syncing new email address with stripe: ${ err } – ignoring` ,
134
134
) ;
135
135
}
136
136
}
0 commit comments