feat: new implementation for rest routes that check setup status
This commit is contained in:
@@ -154,6 +154,14 @@ export const auth = {
|
||||
getCurrentUserStream: () => currentUser$,
|
||||
getAuthEventsStream: () => authEvents$,
|
||||
getCurrentUser: () => currentUser$.value,
|
||||
checkCurrentUser: async () => {
|
||||
try {
|
||||
const res = await authQuery.getUserDetails();
|
||||
return res.data.data.me;
|
||||
} catch (err) {
|
||||
return null;
|
||||
}
|
||||
},
|
||||
|
||||
performAuthInit: () => {
|
||||
const currentUser = JSON.parse(getLocalConfig('login_state') ?? 'null');
|
||||
@@ -232,4 +240,24 @@ export const auth = {
|
||||
const res = await authQuery.getProviders();
|
||||
return res.data?.providers;
|
||||
},
|
||||
|
||||
getFirstTimeInfraSetupStatus: async (): Promise<boolean> => {
|
||||
try {
|
||||
const res = await authQuery.getFirstTimeInfraSetupStatus();
|
||||
return res.data?.value;
|
||||
} catch (err) {
|
||||
// Setup is not done
|
||||
return true;
|
||||
}
|
||||
},
|
||||
|
||||
updateFirstTimeInfraSetupStatus: async () => {
|
||||
try {
|
||||
await authQuery.updateFirstTimeInfraSetupStatus();
|
||||
return true;
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
return false;
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
@@ -29,5 +29,7 @@ export default {
|
||||
token,
|
||||
deviceIdentifier,
|
||||
}),
|
||||
getFirstTimeInfraSetupStatus: () => restApi.get('/site/setup'),
|
||||
updateFirstTimeInfraSetupStatus: () => restApi.put('/site/setup'),
|
||||
logout: () => restApi.get('/auth/logout'),
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user