|
@@ -11,6 +11,9 @@ import { AuthService } from '@core/services/authentication/auth.service';
|
|
|
import { takeUntil } from 'rxjs';
|
|
|
import { Router } from '@angular/router';
|
|
|
import { ToastrService } from 'ngx-toastr';
|
|
|
+import { Store } from '@ngrx/store';
|
|
|
+import { Profile, USER } from '../../../core/models/authenticcation.model';
|
|
|
+import { ADD_PROFILE } from '../../../core/state/profile/profile.actions';
|
|
|
|
|
|
@Component({
|
|
|
selector: 'app-sign-in',
|
|
@@ -24,7 +27,8 @@ export class SignInComponent extends ComponentBase implements BaseForm, OnInit {
|
|
|
constructor(
|
|
|
private readonly authService: AuthService,
|
|
|
private readonly router: Router,
|
|
|
- private readonly toastr: ToastrService
|
|
|
+ private readonly toastr: ToastrService,
|
|
|
+ private readonly store: Store<{ user: Profile }>
|
|
|
) {
|
|
|
super();
|
|
|
}
|
|
@@ -49,7 +53,9 @@ export class SignInComponent extends ComponentBase implements BaseForm, OnInit {
|
|
|
.Login(this.form.value)
|
|
|
.pipe(takeUntil(this.destroy$))
|
|
|
.subscribe((response) => {
|
|
|
- console.log(response);
|
|
|
+ localStorage.setItem('token', response.token!);
|
|
|
+ localStorage.setItem('id', response.id!);
|
|
|
+ this.store.dispatch(ADD_PROFILE({ user: response }));
|
|
|
this.router.navigate(['/modules']);
|
|
|
});
|
|
|
}
|