mirror of
https://github.com/ivabus/gui
synced 2025-06-07 15:50:27 +03:00
fix register device request
This commit is contained in:
parent
0fee964bf1
commit
7c08c39af6
1 changed files with 12 additions and 9 deletions
|
@ -15,11 +15,15 @@ export let session: Session | null = null;
|
||||||
export const getSession = async (): Promise<Session | null> => {
|
export const getSession = async (): Promise<Session | null> => {
|
||||||
if (session && session?.user) return session;
|
if (session && session?.user) return session;
|
||||||
const sessionFilePath = await join(basePath, 'tmp.dat');
|
const sessionFilePath = await join(basePath, 'tmp.dat');
|
||||||
const encryptedData = await readTextFile(sessionFilePath, {
|
try {
|
||||||
dir: BaseDirectory.Home
|
const encryptedData = await readTextFile(sessionFilePath, {
|
||||||
});
|
dir: BaseDirectory.Home
|
||||||
session = JSON.parse(encryptedData || '{}') as Session;
|
});
|
||||||
return session;
|
session = JSON.parse(encryptedData || '{}') as Session;
|
||||||
|
return session;
|
||||||
|
} catch (error) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function initAuthStore() {
|
export default function initAuthStore() {
|
||||||
|
@ -101,11 +105,10 @@ const getLocalSessionData = async (): Promise<Session | void> => {
|
||||||
let data: Session;
|
let data: Session;
|
||||||
try {
|
try {
|
||||||
const session = await getSession();
|
const session = await getSession();
|
||||||
if (session) {
|
if (!session) throw new Error('no session');
|
||||||
data = session;
|
data = session;
|
||||||
}
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error('register device:',error);
|
||||||
const deviceId = await registerDevice();
|
const deviceId = await registerDevice();
|
||||||
data = {
|
data = {
|
||||||
device_id: deviceId
|
device_id: deviceId
|
||||||
|
|
Loading…
Reference in a new issue