Add: Auth protection & error notifications
This commit is contained in:
parent
5d508c4731
commit
51668bae9d
6 changed files with 53 additions and 37 deletions
|
|
@ -77,6 +77,11 @@ export const useAuth = () => {
|
|||
}
|
||||
|
||||
if (data.value) {
|
||||
// Validation: Only allow STUDENT role to login
|
||||
if (data.value.user.role.code !== 'STUDENT') {
|
||||
return { success: false, error: 'Email ไม่ถูกต้อง' }
|
||||
}
|
||||
|
||||
token.value = data.value.token
|
||||
refreshToken.value = data.value.refreshToken // Save refresh token
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue