Skip to content

Commit 8434fe4

Browse files
author
Harshdev098
committed
fix: handle register and login errors
Signed-off-by: Harshdev098 <harshoxfordgkp@gmail.com>
1 parent c31285b commit 8434fe4

File tree

3 files changed

+4
-2
lines changed

3 files changed

+4
-2
lines changed

src/learning-token-backend/src/modules/auth/auth.controller.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export class AuthController {
5656
throw new NotFoundException('Invalid Credentials')
5757
}
5858
} catch (error) {
59-
throw new NotFoundException('Invalid Credentials')
59+
throw new NotFoundException('An error occured')
6060
}
6161
}
6262

src/learning-token-backend/src/modules/auth/service/auth.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ export class AuthService {
151151
token: token,
152152
createdAt: user.createdAt,
153153
updatedAt: user.updatedAt,
154-
role: user.role.name
154+
role: user.role?.name
155155
}
156156
}
157157

src/learning-token-dashboard/src/pages/Register.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,15 @@ const Login = () => {
7474
name: values.name,
7575
email: values.email,
7676
password: values.password,
77+
type: 'Admin'
7778
})
7879
.unwrap()
7980
.then((result: any) => {
8081
if (result && result.status === 201) {
8182
loginAdmin({
8283
email: values.email,
8384
password: values.password,
85+
type: 'Admin'
8486
})
8587
.unwrap()
8688
.then((res: any) => {

0 commit comments

Comments
 (0)