Compare commits

..

No commits in common. "8412218bb2d16bfa6b0054e06deb9f85c43e7093" and "7e9c78fd93ba8af7a7b5e2006ed9647403f556ef" have entirely different histories.

View file

@ -73,8 +73,6 @@ class ApiService {
return false;
}
console.log("ApiService: isLoggedIn: Token:", token);
// Update token expiry
this.saveToken(token);
@ -90,19 +88,11 @@ class ApiService {
}
try {
console.log("ApiService: isLoggedInTeacher: Token:", token);
const decodedToken = jwtDecode(token) as { roles: string[] };
/////// REMOVE BELOW
// automatically add teacher role if not present
if (!decodedToken.roles.includes('teacher')) {
decodedToken.roles.push('teacher');
}
////// REMOVE ABOVE
const userRoles = decodedToken.roles;
const requiredRole = 'teacher';
console.log("ApiService: isLoggedInTeacher: UserRoles:", userRoles);
if (!userRoles || !userRoles.includes(requiredRole)) {
return false;
}
@ -978,4 +968,4 @@ public async login(email: string, password: string): Promise<any> {
}
const apiService = new ApiService();
export default apiService;
export default apiService;