Add: Auth protection & error notifications

This commit is contained in:
supalerk-ar66 2026-01-14 16:47:29 +07:00
parent 5d508c4731
commit 51668bae9d
6 changed files with 53 additions and 37 deletions

View file

@ -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