feishin/src/renderer/api/utils.ts

18 lines
644 B
TypeScript
Raw Normal View History

import { toast } from '/@/renderer/components';
import { useAuthStore } from '/@/renderer/store';
import { ServerListItem } from '/@/shared/types/types';
export const authenticationFailure = (currentServer: null | ServerListItem) => {
2023-07-01 19:10:05 -07:00
toast.error({
message: 'Your session has expired.',
});
2023-07-01 19:10:05 -07:00
if (currentServer) {
const serverId = currentServer.id;
const token = currentServer.ndCredential;
console.log(`token is expired: ${token}`);
useAuthStore.getState().actions.updateServer(serverId, { ndCredential: undefined });
useAuthStore.getState().actions.setCurrentServer(null);
}
};