@@ -69,7 +69,7 @@ export class AuthenticationService {
69
69
const users = this . moduleRef . get ( userMod . UserService , { strict : false } ) ;
70
70
userId = await this . gel . usingOptions (
71
71
disableAccessPolicies ,
72
- async ( ) => await users . create ( input , session ) ,
72
+ async ( ) => await users . create ( input ) ,
73
73
) ;
74
74
} catch ( e ) {
75
75
// remap field prop as `email` field is at a different location in register() than createPerson()
@@ -85,14 +85,17 @@ export class AuthenticationService {
85
85
return userId ;
86
86
}
87
87
88
- async login ( input : LoginInput , session : Session ) : Promise < ID > {
88
+ async login ( input : LoginInput ) : Promise < ID > {
89
89
const hash = await this . repo . getPasswordHash ( input ) ;
90
90
91
91
if ( ! ( await this . crypto . verify ( hash , input . password ) ) ) {
92
92
throw new UnauthenticatedException ( 'Invalid credentials' ) ;
93
93
}
94
94
95
- const userId = await this . repo . connectSessionToUser ( input , session ) ;
95
+ const userId = await this . repo . connectSessionToUser (
96
+ input ,
97
+ this . sessionHost . current ,
98
+ ) ;
96
99
97
100
if ( ! userId ) {
98
101
throw new ServerException ( 'Login failed' ) ;
@@ -256,21 +259,20 @@ export class AuthenticationService {
256
259
async changePassword (
257
260
oldPassword : string ,
258
261
newPassword : string ,
259
- session : Session ,
260
262
) : Promise < void > {
261
263
if ( ! oldPassword )
262
264
throw new InputException ( 'Old Password Required' , 'oldPassword' ) ;
263
265
264
- const hash = await this . repo . getCurrentPasswordHash ( session ) ;
266
+ const hash = await this . repo . getCurrentPasswordHash ( ) ;
265
267
266
268
if ( ! ( await this . crypto . verify ( hash , oldPassword ) ) ) {
267
269
throw new UnauthenticatedException ( 'Invalid credentials' ) ;
268
270
}
269
271
270
272
const newPasswordHash = await this . crypto . hash ( newPassword ) ;
271
- await this . repo . updatePassword ( newPasswordHash , session ) ;
273
+ await this . repo . updatePassword ( newPasswordHash ) ;
272
274
273
- await this . repo . deactivateAllOtherSessions ( session ) ;
275
+ await this . repo . deactivateAllOtherSessions ( this . sessionHost . current ) ;
274
276
}
275
277
276
278
async forgotPassword ( email : string ) : Promise < void > {
@@ -288,10 +290,7 @@ export class AuthenticationService {
288
290
} ) ;
289
291
}
290
292
291
- async resetPassword (
292
- { token, password } : ResetPasswordInput ,
293
- session : Session ,
294
- ) : Promise < void > {
293
+ async resetPassword ( { token, password } : ResetPasswordInput ) : Promise < void > {
295
294
const emailToken = await this . repo . findEmailToken ( token ) ;
296
295
if ( ! emailToken ) {
297
296
throw new InputException ( 'Token is invalid' , 'TokenInvalid' ) ;
@@ -306,7 +305,7 @@ export class AuthenticationService {
306
305
await this . repo . updatePasswordViaEmailToken ( emailToken , pash ) ;
307
306
await this . repo . deactivateAllOtherSessionsByEmail (
308
307
emailToken . email ,
309
- session ,
308
+ this . sessionHost . current ,
310
309
) ;
311
310
await this . repo . removeAllEmailTokensForEmail ( emailToken . email ) ;
312
311
}
0 commit comments