Skip to content

Commit

Permalink
Fix logout flow
Browse files Browse the repository at this point in the history
  • Loading branch information
jvyden committed Jul 5, 2023
1 parent 8ee1286 commit 1bb05aa
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
10 changes: 4 additions & 6 deletions src/app/api/api-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,12 +144,10 @@ export class ApiClient {
this._userId = undefined;
this.user = undefined;

localStorage.removeItem('game_token');

this.userWatcher.emit(undefined);
this.makeRequest("POST", "logout", {})
.subscribe(() => {
}); // Need to subscribe for request to fire
this.makeRequest("PUT", "logout", {}).subscribe();

localStorage.removeItem('game_token');
}

public ResetPassword(username: string, passwordSha512: string, signIn: boolean = false): void {
Expand All @@ -163,7 +161,7 @@ export class ApiClient {
resetToken: this.resetToken,
}

this.makeRequest("POST", "resetPassword", body)
this.makeRequest("PUT", "resetPassword", body)
.subscribe(() => {
if (signIn) this.LogIn(username, passwordSha512);
this.bannerService.push({
Expand Down
8 changes: 5 additions & 3 deletions src/app/pages/login/login.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,22 @@ import { Component } from '@angular/core';
import { ApiClient } from 'src/app/api/api-client';
import { sha512Async } from 'src/app/hash';

let i: number = 0;

@Component({
selector: 'app-login',
templateUrl: './login.component.html'
})
export class LoginComponent {
usernameId: string = "login-username"
passwordId: string = "login-password"
usernameId: string = "login-username" + i++;
passwordId: string = "login-password" + i++;

constructor(private apiClient: ApiClient) {}

login() {
const usernameInput: string = (<HTMLInputElement>document.getElementById(this.usernameId)).value;
const passwordInput: string = (<HTMLInputElement>document.getElementById(this.passwordId)).value;

sha512Async(passwordInput).then((hash) => {
this.apiClient.LogIn(usernameInput, hash)
});
Expand Down

0 comments on commit 1bb05aa

Please sign in to comment.