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