Skip to content

Commit

Permalink
Check password in signinup only when email/password signInUp (#5042)
Browse files Browse the repository at this point in the history
- disable password check when signInUp from google (sso)
- check password when signInUp with email password
  • Loading branch information
martmull committed Apr 18, 2024
1 parent e0efa35 commit 36d4c38
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,10 @@ export class AuthResolver {

@Mutation(() => LoginToken)
async signUp(@Args() signUpInput: SignUpInput): Promise<LoginToken> {
const user = await this.authService.signInUp(signUpInput);
const user = await this.authService.signInUp({
...signUpInput,
fromSSO: false,
});

const loginToken = await this.tokenService.generateLoginToken(user.email);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export class GoogleAuthController {
lastName,
picture,
workspaceInviteHash,
fromSSO: true,
});

const loginToken = await this.tokenService.generateLoginToken(user.email);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,15 @@ export class AuthService {
firstName,
lastName,
picture,
fromSSO,
}: {
email: string;
password?: string;
firstName?: string | null;
lastName?: string | null;
workspaceInviteHash?: string | null;
picture?: string | null;
fromSSO: boolean;
}) {
return await this.signInUpService.signInUp({
email,
Expand All @@ -102,6 +104,7 @@ export class AuthService {
lastName,
workspaceInviteHash,
picture,
fromSSO,
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export type SignInUpServiceInput = {
lastName?: string | null;
workspaceInviteHash?: string | null;
picture?: string | null;
fromSSO: boolean;
};

@Injectable()
Expand All @@ -54,6 +55,7 @@ export class SignInUpService {
firstName,
lastName,
picture,
fromSSO,
}: SignInUpServiceInput) {
if (!firstName) firstName = '';
if (!lastName) lastName = '';
Expand All @@ -80,7 +82,7 @@ export class SignInUpService {
relations: ['defaultWorkspace'],
});

if (existingUser && existingUser.passwordHash) {
if (existingUser && !fromSSO) {
const isValid = await compareHash(
password || '',
existingUser.passwordHash,
Expand Down

0 comments on commit 36d4c38

Please sign in to comment.