Bug fix +

Meilleur chargement du cache après login
This commit is contained in:
Sébastien André
2021-05-03 16:13:55 +02:00
parent f9930a10e6
commit 784bdea786
9 changed files with 107 additions and 81 deletions

View File

@@ -6,6 +6,10 @@ import { MatInput } from '@angular/material/input';
import { first } from 'rxjs/operators';
import { AuthenticationService } from '../../services/authentication.service';
import { AircraftService } from "../../services/aircraft.service";
import { GearService } from "../../services/gear.service";
import { JumpTypeService } from "../../services/jump-type.service";
import { DropzoneService } from "../../services/dropzone.service";
@Component({
selector: 'app-login-user',
@@ -20,13 +24,14 @@ export class LoginUserComponent implements OnInit, AfterViewInit {
error = '';
@ViewChild('username') userNameInput: MatInput;
constructor(
private formBuilder: FormBuilder,
private route: ActivatedRoute,
private router: Router,
private authenticationService: AuthenticationService
) {
// redirect to home if already logged in
constructor(private formBuilder: FormBuilder,
private route: ActivatedRoute,
private router: Router,
private authenticationService: AuthenticationService,
private serviceApiAircraft : AircraftService,
private serviceApiJumpType : JumpTypeService,
private serviceApiDropzone : DropzoneService,
private serviceApiGear : GearService) {
if (this.authenticationService.currentUserValue) {
this.router.navigate(['/']);
}
@@ -40,12 +45,7 @@ export class LoginUserComponent implements OnInit, AfterViewInit {
this.loginForm = this.formBuilder.group(
{
username: ['', [Validators.required, Validators.minLength(3)]],
password: [
'',
[
Validators.required
]
]
password: ['', [Validators.required]]
},
{ updateOn: 'blur' }
);
@@ -68,17 +68,21 @@ export class LoginUserComponent implements OnInit, AfterViewInit {
}
this.loading = true;
this.authenticationService
.login(this.formCtrls.username.value, this.formCtrls.password.value)
.pipe(first())
.subscribe(
data => {
this.router.navigate([this.returnUrl]);
},
error => {
this.error = error;
this.loading = false;
}
);
this.authenticationService.login(this.formCtrls.username.value, this.formCtrls.password.value)
.pipe(first())
.subscribe(
() => {
this.serviceApiAircraft.getListOfAircrafts(false).subscribe();
this.serviceApiJumpType.getListOfJumpTypes().subscribe();
this.serviceApiDropzone.getListOfDropZones(false).subscribe();
this.serviceApiGear.getListOfGears().subscribe();
this.router.navigate([this.returnUrl]);
},
error => {
this.error = error;
this.loading = false;
}
);
}
}