Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/apps/core/loginapp/LoginForm.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<div class="login-form">
<div class="left">
{#if !$persistence}
<Field bind:value={$username} placeholder="Username" icon="user" />
<Field bind:value={$username} placeholder="Username/Email" icon="user" />
{/if}
<Field bind:value={$password} placeholder="Password" icon="key-round" password onsubmit={go} />
</div>
Expand Down
24 changes: 17 additions & 7 deletions src/apps/core/loginapp/runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion src/interfaces/runtimes/ILoginAppRuntime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export interface ILoginAppRuntime extends IAppProcess {
logoff(userDaemon: IUserDaemon): Promise<void>;
shutdown(userDaemon?: IUserDaemon): Promise<void>;
restart(userDaemon?: IUserDaemon): Promise<void>;
proceed(username: string, password: string): Promise<void>;
proceed(identifier: string, password: string): Promise<void>;

resetCookies(): void;
firstRun(daemon: IUserDaemon): Promise<void>;
Expand Down
2 changes: 1 addition & 1 deletion src/ts/user/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export async function LoginUser(identity: string, password: string): Promise<ICo
})
);

if (response.status !== 200) return CommandResult.Error(response.data?.e ?? "Username or password is incorrect");
if (response.status !== 200) return CommandResult.Error(response.data?.e ?? "Username/Email or password is incorrect");

return CommandResult.Ok(response.data.token);
} catch (e) {
Expand Down
Loading