Fakultas Ilmu Komputer UI

Commit c51fa07a authored by FadhilP's avatar FadhilP
Browse files

merge service into one file

parent def7e8c5
......@@ -8,20 +8,19 @@ class AuthService {
}
getCurrentUserId() {
try {
return this.getCurrentUser()?.data?.id;
} catch (error) {
return '';
}
return this.getCurrentUser()?.data?.id;
}
getCurrentUsername() {
try {
return this.getCurrentUser()?.data?.username;
} catch (error) {
return '';
}
return this.getCurrentUser()?.data?.username;
}
}
export default new AuthService();
export const authHeader = () => {
const user = JSON.parse(localStorage.getItem('user'));
return { Authorization: `Bearer ${user?.data?.token}` };
};
export const loggedIn = JSON.parse(localStorage.getItem('user')) && 1;
export default function authHeader() {
const user = JSON.parse(localStorage.getItem('user'));
if (user?.tokenId)
return { Authorization: `Bearer ${user?.accessToken}` };
else if (user?.data?.token)
// kalo make google
return { Authorization: `Bearer ${user?.data.token}` };
// if (user && user.token)
// return { Authorization: `Bearer ${user.token}` }
else return {};
}
import AuthService from './auth.service';
export const loggedIn = AuthService.getCurrentUser() && 1;
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment