From 338e1ad81751c04be59872657eb3b78a14c8944b Mon Sep 17 00:00:00 2001 From: Blockyheadman <80011716+Blockyheadman@users.noreply.github.com> Date: Thu, 30 Jul 2026 15:35:15 -0500 Subject: [PATCH] add email login support (super simple) --- src/apps/core/loginapp/LoginForm.svelte | 2 +- src/apps/core/loginapp/runtime.ts | 24 +++++++++++++++------ src/interfaces/runtimes/ILoginAppRuntime.ts | 2 +- src/ts/user/auth.ts | 2 +- 4 files changed, 20 insertions(+), 10 deletions(-) diff --git a/src/apps/core/loginapp/LoginForm.svelte b/src/apps/core/loginapp/LoginForm.svelte index afe7e0e0..89900cdd 100755 --- a/src/apps/core/loginapp/LoginForm.svelte +++ b/src/apps/core/loginapp/LoginForm.svelte @@ -17,7 +17,7 @@
{#if !$persistence} - + {/if}
diff --git a/src/apps/core/loginapp/runtime.ts b/src/apps/core/loginapp/runtime.ts index a1599627..f5b1987b 100755 --- a/src/apps/core/loginapp/runtime.ts +++ b/src/apps/core/loginapp/runtime.ts @@ -290,23 +290,33 @@ export class LoginAppRuntime extends AppProcess implements ILoginAppRuntime { //#endregion //#region CREDENTIALS - async proceed(username: string, password: string) { - this.Log(`Trying login of '${username}'`); + async proceed(identifier: string, password: string) { + this.Log(`Trying login of '${identifier}'`); - this.loadingStatus.set(`Hi, ${username}!`); - - const tokenResult = await LoginUser(username, password); + const tokenResult = await LoginUser(identifier, password); if (!tokenResult.success) { this.loadingStatus.set(""); - this.errorMessage.set(tokenResult.errorMessage ?? "Username or password incorrect"); + this.errorMessage.set(tokenResult.errorMessage ?? "Username/Email or password incorrect"); this.updateServerStuff(); return; } - await this.startDaemon(tokenResult.result!, username); + const userInfo = await this.validateUserToken(tokenResult.result!); + if (!userInfo) { + this.resetCookies(); + + this.loadingStatus.set(""); + this.errorMessage.set("Session token is invalid."); + + return; + } + + this.loadingStatus.set(`Hi, ${userInfo.username}!`); + + await this.startDaemon(tokenResult.result!, userInfo.username); } private saveToken(userDaemon: IUserDaemon) { diff --git a/src/interfaces/runtimes/ILoginAppRuntime.ts b/src/interfaces/runtimes/ILoginAppRuntime.ts index 566e665c..42c1a288 100644 --- a/src/interfaces/runtimes/ILoginAppRuntime.ts +++ b/src/interfaces/runtimes/ILoginAppRuntime.ts @@ -28,7 +28,7 @@ export interface ILoginAppRuntime extends IAppProcess { logoff(userDaemon: IUserDaemon): Promise; shutdown(userDaemon?: IUserDaemon): Promise; restart(userDaemon?: IUserDaemon): Promise; - proceed(username: string, password: string): Promise; + proceed(identifier: string, password: string): Promise; resetCookies(): void; firstRun(daemon: IUserDaemon): Promise; diff --git a/src/ts/user/auth.ts b/src/ts/user/auth.ts index 12f5a036..ab0a4193 100644 --- a/src/ts/user/auth.ts +++ b/src/ts/user/auth.ts @@ -19,7 +19,7 @@ export async function LoginUser(identity: string, password: string): Promise