mirror of
https://github.com/OpenLiberty/liberty-bikes.git
synced 2025-01-18 10:23:58 +08:00
Merge pull request #114 from ryanesch/googleusername
For Google Auth, add register username panel
This commit is contained in:
commit
a79b50ee55
@ -33,7 +33,7 @@
|
||||
<input type="text" id="username" name="username" [(ngModel)]="username" />
|
||||
</div>
|
||||
<div class="form-item">
|
||||
<button type="button" (click)="loginAsGuest(username)">Sign In As Guest</button>
|
||||
<button type="button" id="signin" (click)="loginAsGuest(username)">Sign In As Guest</button>
|
||||
</div>
|
||||
<div class="form-item">
|
||||
<button type="button" (click)="cancelLogin()">Cancel</button>
|
||||
|
@ -162,6 +162,7 @@ export class LoginComponent implements OnInit, OnDestroy {
|
||||
|
||||
showGuestLogin() {
|
||||
this.pane = 'center';
|
||||
document.getElementById("signin").innerHTML="Sign In As Guest";
|
||||
}
|
||||
|
||||
setQueueOnMessage() {
|
||||
@ -208,7 +209,7 @@ export class LoginComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
|
||||
async loginAsGuest(username: string) {
|
||||
if (await this.createUser(username, null))
|
||||
if (await this.createUser(username, sessionStorage.getItem('userId')))
|
||||
this.pane = 'right';
|
||||
}
|
||||
|
||||
@ -218,16 +219,14 @@ export class LoginComponent implements OnInit, OnDestroy {
|
||||
'Content-Type': 'application/json',
|
||||
'Authorization': 'Bearer ' + `${jwt}`
|
||||
}) }).toPromise();
|
||||
sessionStorage.setItem('userId', user.id);
|
||||
if (user.exists === 'true') {
|
||||
sessionStorage.setItem('username', user.username);
|
||||
sessionStorage.setItem('userId', user.id);
|
||||
this.player.name = user.username;
|
||||
this.pane = 'right';
|
||||
} else {
|
||||
var username = prompt("Choose a username:", "");
|
||||
if (await this.createUser(username, user.id)) {
|
||||
this.pane = 'right';
|
||||
}
|
||||
this.pane = 'center';
|
||||
document.getElementById("signin").innerHTML="register username";
|
||||
}
|
||||
}
|
||||
|
||||
@ -272,6 +271,8 @@ export class LoginComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
|
||||
cancelLogin() {
|
||||
sessionStorage.removeItem('username');
|
||||
sessionStorage.removeItem('userId');
|
||||
this.pane = 'left';
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user