Skip to content

Commit cee595b

Browse files
authored
Merge pull request #17 from NextStepFinalProject/NXD-19
Hotfix Local Register And Login
2 parents 0d9185c + a453773 commit cee595b

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

nextstep-backend/src/services/users_service.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export const deleteUserById = async (id: string): Promise<UserData | null> => {
4949
return user ? userToUserData(user) : null;
5050
};
5151

52-
export const registerUser = async (username: string, password: string, email: string, authProvider: string): Promise<UserData> => {
52+
export const registerUser = async (username: string, password: string, email: string, authProvider: string = "local"): Promise<UserData> => {
5353
let hashedPassword: string = '';
5454
// If registering with a password (local registration)
5555
if (password && authProvider === 'local') {
@@ -102,14 +102,14 @@ export const loginUserGoogle = async (email: string, authProvider: string, name:
102102
return {...tokens, userId: user.id, username: user.username, imageFilename: user.imageFilename}
103103
}
104104

105-
export const loginUser = async (email: string, password: string, authProvider?: string): Promise<{ accessToken: string, refreshToken: string, userId: string, username: string, imageFilename?: string } | null> => {
105+
export const loginUser = async (email: string, password: string, authProvider: string = "local"): Promise<{ accessToken: string, refreshToken: string, userId: string, username: string, imageFilename?: string } | null> => {
106106
const user = await getIUserByEmail(email);
107107
if (!user) {
108108
return null;
109109
}
110110
// Local login (with password)
111111
if (authProvider === 'local') {
112-
if ((await bcrypt.compare(password, user.password))) {
112+
if (!(await bcrypt.compare(password, user.password))) {
113113
return null;
114114
}
115115
}

0 commit comments

Comments
 (0)