feat: add mode parameter to social auth to distinguish between login and signup flows

This commit is contained in:
pradeepkumar
2026-03-31 23:22:52 +05:30
parent e5e1888615
commit f30894dd79
3 changed files with 16 additions and 10 deletions

View File

@@ -256,8 +256,13 @@ export class AuthService {
where: { id: user.id },
data: { [providerIdField]: dto.providerId },
});
} else if (dto.mode === 'login') {
// Login mode: user must exist
throw new BadRequestException(
'No account found with this email. Please sign up first.',
);
} else {
// Create new user
// Create new user (signup mode)
const role = dto.role === 'AGENT' ? UserRole.AGENT : UserRole.USER;
const authProvider =
dto.provider === 'google'