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