mirror of
https://github.com/azukaar/Cosmos-Server.git
synced 2026-01-23 13:08:29 -06:00
* Replaced the lodash module with submodules * Using lazy imports of heavy modules * Replaced the old authorization verification system with PrivateRoute * Dynamic import of all paths * Minifying the syntax highlighting library * Added missing imports * Added expires to head meta * Don't force the code to follow unnecessary redirects * Kawanaao accept CLA --------- Co-authored-by: Yann S <7872597+azukaar@users.noreply.github.com>
26 lines
947 B
JavaScript
26 lines
947 B
JavaScript
|
|
import * as API from './api';
|
|
|
|
async function isLoggedIn() {
|
|
const urlSearch = encodeURIComponent(window.location.search);
|
|
const redirectToURL = (window.location.pathname + urlSearch);
|
|
const data = await API.auth.me();
|
|
|
|
if (data.status == 'NEW_INSTALL') {
|
|
return '/cosmos-ui/newInstall';
|
|
} else if (data.status == 'error' && data.code == "HTTP004") {
|
|
return '/cosmos-ui/login?redirect=' + redirectToURL;
|
|
} else if (data.status == 'error' && data.code == "HTTP006") {
|
|
return '/cosmos-ui/loginmfa?redirect=' + redirectToURL;
|
|
} else if (data.status == 'error' && data.code == "HTTP007") {
|
|
return '/cosmos-ui/newmfa?redirect=' + redirectToURL;
|
|
} else if (data.status == 'OK') {
|
|
return data.status
|
|
} else {
|
|
console.warn(`Status "${data.status}" does not have a navigation handler, will be interpreted as OK!`)
|
|
return 'OK'
|
|
}
|
|
};
|
|
|
|
export default isLoggedIn;
|