add inactivity page

This commit is contained in:
Peter Maquiran
2021-08-27 15:21:15 +01:00
50 changed files with 259 additions and 244 deletions
@@ -45,6 +45,58 @@ export class InactivityPage implements OnInit {
}
//Function to validade the login inputs
validateUsername() {
return (
this.username.trim().length > 0
);
}
validatePassword() {
return (
this.password.trim().length > 0
);
}
async Login() {
if (this.validateUsername()) {
if(this.validatePassword()) {
this.userattempt = {
username: this.username,
password: this.password,
domainName: environment.domain,
BasicAuthKey: ""
}
let attempt = await this.authService.login(this.userattempt, false)
if (attempt) {
// if current attemp is equal to the current user
if (attempt.UserId == SessionStore.user.UserId) {
await this.authService.SetSession(attempt, this.userattempt);
await this.authService.loginChat(this.userattempt);
await this.getToken();
this.router.navigate(['/home/events']);
} else {
SessionStore.delete()
await this.authService.SetSession(attempt, this.userattempt);
}
}
}
else {
this.toastService.badRequest('Por favor, insira a sua palavra-passe');
}
}
else {
this.toastService.badRequest('Por favor, insira o seu nome de utilizador');
}
}
getToken() {
this.notificatinsservice.getAndpostToken(this.username);
}