Fix user errors for login auth
This commit is contained in:
@@ -45,12 +45,7 @@ export class LoginComponent {
|
||||
this.errorMsgs.push("Waiting for response from server");
|
||||
this.auth.Login(this.UserName, this.Password, this.StayLoggedIn).subscribe(
|
||||
data => {
|
||||
if (data.error.length === 0){
|
||||
this.router.navigate([this.returnURL]);
|
||||
}else{
|
||||
this.errorMsgs.pop();
|
||||
this.errorMsgs.push(data.error);
|
||||
}
|
||||
this.router.navigate([this.returnURL]);
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
@@ -60,26 +60,21 @@ export class RegisterComponent {
|
||||
// Send to server and wait for response
|
||||
this.errorMsgs.push("Waiting for response from server");
|
||||
const body = new HttpParams()
|
||||
.set("Email", this.email)
|
||||
.set("UserName", this.userName)
|
||||
.set("PasswordHash", this.passwordHash);
|
||||
.set("Email", this.email)
|
||||
.set("UserName", this.userName)
|
||||
.set("PasswordHash", this.passwordHash);
|
||||
const headers = new HttpHeaders({
|
||||
'Content-Type': 'application/x-www-form-urlencoded'
|
||||
'Content-Type': 'application/x-www-form-urlencoded'
|
||||
});
|
||||
this.http.post<Account>( "api/account/register", body, { headers } ).subscribe({
|
||||
next: async (data) => {
|
||||
if (data.error.length === 0){
|
||||
this.errorMsgs = ["Account Created"];
|
||||
await this.sleep(3000);
|
||||
this.router.navigate([this.returnURL]);
|
||||
}else{
|
||||
this.errorMsgs = [];
|
||||
this.errorMsgs.push(data.error);
|
||||
}
|
||||
},
|
||||
error: err => {
|
||||
console.log("HTTP Error Signing In: ", err);
|
||||
}
|
||||
next: async (data) => {
|
||||
this.errorMsgs = ["Account Created"];
|
||||
await this.sleep(3000);
|
||||
this.router.navigate([this.returnURL]);
|
||||
},
|
||||
error: err => {
|
||||
console.log("HTTP Error Signing In: ", err);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -24,10 +24,8 @@ export class Authentication{
|
||||
let sub = this.http.post<Account>( "api/account/login", body, { headers } );
|
||||
sub.subscribe({
|
||||
next: data => {
|
||||
if (data.error.length === 0){
|
||||
this._user.next(data);
|
||||
this.setUserToStorage(data, StayLoggedIn == true ? SessionType.Forever : SessionType.Session);
|
||||
}
|
||||
this._user.next(data);
|
||||
this.setUserToStorage(data, StayLoggedIn == true ? SessionType.Forever : SessionType.Session);
|
||||
},
|
||||
error: err => {
|
||||
console.log("HTTP Error Signing In: ", err);
|
||||
|
||||
Reference in New Issue
Block a user