feat: add user authentication flow and configuration management
This commit is contained in:
@@ -4,12 +4,14 @@ import { invoke } from '@tauri-apps/api/core';
|
||||
import { Crypto } from './crypto';
|
||||
|
||||
export class Config {
|
||||
private fileName: string;
|
||||
private config: Record<string, unknown> = {};
|
||||
private crypto: Crypto | undefined;
|
||||
private configFilePath: string | undefined;
|
||||
private encrypt: boolean;
|
||||
|
||||
constructor(encrypt?: boolean) {
|
||||
constructor(fileName: string, encrypt?: boolean) {
|
||||
this.fileName = fileName;
|
||||
this.encrypt = encrypt ?? false;
|
||||
}
|
||||
|
||||
@@ -20,7 +22,7 @@ export class Config {
|
||||
|
||||
const homeDir = await path.homeDir();
|
||||
const folderPath = await path.join(homeDir, '.ezpplauncher');
|
||||
this.configFilePath = await path.join(folderPath, 'user_settings');
|
||||
this.configFilePath = await path.join(folderPath, this.fileName);
|
||||
|
||||
const createFolder = !(await exists(folderPath));
|
||||
if (createFolder) await mkdir(folderPath);
|
||||
|
@@ -1,7 +1,6 @@
|
||||
import { writable } from 'svelte/store';
|
||||
import { Config } from './config';
|
||||
import type { EZPPUser } from './types';
|
||||
|
||||
export const userAuth = writable<Config>(new Config(true));
|
||||
|
||||
export const username = writable<string>("");
|
||||
export const password = writable<string>("")
|
||||
export const userAuth = writable<Config>(new Config("user_auth", true));
|
||||
export const currentUser = writable<EZPPUser | undefined>(undefined);
|
||||
|
@@ -1,7 +1,7 @@
|
||||
import { writable } from 'svelte/store';
|
||||
import { Config } from './config';
|
||||
|
||||
export const userSettings = writable<Config>(new Config(false));
|
||||
export const userSettings = writable<Config>(new Config('user_settings', false));
|
||||
|
||||
export const customCursor = writable<boolean>(true);
|
||||
export const cursorSmoothening = writable<boolean>(true);
|
||||
|
Reference in New Issue
Block a user