File tree Expand file tree Collapse file tree 1 file changed +7
-5
lines changed Expand file tree Collapse file tree 1 file changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -15,7 +15,6 @@ import { AuthenticationRepository } from './authentication.repository';
15
15
import { CryptoService } from './crypto.service' ;
16
16
import type { LoginInput , RegisterInput , ResetPasswordInput } from './dto' ;
17
17
import { JwtService } from './jwt.service' ;
18
- import { type Session } from './session/session.dto' ;
19
18
import { SessionHost } from './session/session.host' ;
20
19
import { SessionManager } from './session/session.manager' ;
21
20
@@ -36,10 +35,9 @@ export class AuthenticationService {
36
35
private readonly moduleRef : ModuleRef ,
37
36
) { }
38
37
39
- async register (
40
- { password, ...input } : RegisterInput ,
41
- session ?: Session ,
42
- ) : Promise < ID > {
38
+ async register ( { password, ...input } : RegisterInput ) : Promise < ID > {
39
+ const session = this . sessionHost . currentIfInCtx ;
40
+
43
41
// ensure no other tokens are associated with this user
44
42
if ( session ) {
45
43
await this . logout ( session . token , false ) ;
@@ -64,6 +62,10 @@ export class AuthenticationService {
64
62
const passwordHash = await this . crypto . hash ( password ) ;
65
63
await this . repo . savePasswordHashOnUser ( userId , passwordHash ) ;
66
64
65
+ if ( ! session ) {
66
+ return userId ;
67
+ }
68
+
67
69
return await this . login ( {
68
70
email : input . email ,
69
71
password,
You can’t perform that action at this time.
0 commit comments