Better Typing and Optimizations
This commit is contained in:
@@ -14,9 +14,7 @@ import { DomSanitizer } from '@angular/platform-browser';
|
||||
import { faLock, faUser } from '@fortawesome/free-solid-svg-icons';
|
||||
import { Subscription } from 'rxjs';
|
||||
import { AuthService } from 'src/app/shared/service/auth.service';
|
||||
import { HttpError } from 'src/app/shared/model/httpError/httpError.model';
|
||||
import HttpErrorChecker from 'src/app/shared/model/httpError/httpErrorChecker';
|
||||
import UserChecker from 'src/app/shared/model/user/user.checker';
|
||||
import { Value } from '@sinclair/typebox/value'
|
||||
import { User } from 'src/app/shared/model/user/user.model';
|
||||
import {
|
||||
animate,
|
||||
@@ -35,6 +33,7 @@ import {
|
||||
NgcStatusChangeEvent,
|
||||
} from 'ngx-cookieconsent';
|
||||
import { CookieConsertService } from '../../../shared/cookie-consent/cookie-consert.service';
|
||||
import {HttpError} from "../../../shared/model/httpError/httpError.model";
|
||||
|
||||
const GOOGLE_LOGO_SVG = 'assets/img/providers/google.svg';
|
||||
const GOOGLE_DISABLED_LOGO_SVG = 'assets/img/providers/google-disabled.svg';
|
||||
@@ -206,10 +205,10 @@ export class LoginComponent implements OnInit, AfterViewInit, OnDestroy {
|
||||
}
|
||||
|
||||
private validateLogin(res: User | HttpError | null) {
|
||||
if (res && UserChecker.test(res)) {
|
||||
if (res && Value.Check(User, res)) {
|
||||
this.closePopup();
|
||||
}
|
||||
if (HttpErrorChecker.test(res)) {
|
||||
if (Value.Check(HttpError, res)) {
|
||||
this.errorMessage = (<HttpError>res).details;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import {
|
||||
ChangeDetectorRef,
|
||||
Component,
|
||||
EventEmitter,
|
||||
Input,
|
||||
@@ -18,15 +17,9 @@ import {
|
||||
transition,
|
||||
trigger,
|
||||
} from '@angular/animations';
|
||||
import { MatIconRegistry } from '@angular/material/icon';
|
||||
import { DomSanitizer } from '@angular/platform-browser';
|
||||
import { FormControl, FormGroup, Validators } from '@angular/forms';
|
||||
import { ValidateNotEmptyValidator } from '../../../shared/validators/validate-not-empty.validator';
|
||||
import { ValidatePasswordValidator } from '../../../shared/validators/validate-password.validator';
|
||||
import { first, take } from 'rxjs';
|
||||
import UserChecker from '../../../shared/model/user/user.checker';
|
||||
import HttpErrorChecker from '../../../shared/model/httpError/httpErrorChecker';
|
||||
import { HttpError } from '../../../shared/model/httpError/httpError.model';
|
||||
import { faFileUpload } from '@fortawesome/free-solid-svg-icons';
|
||||
|
||||
@Component({
|
||||
|
||||
@@ -11,8 +11,6 @@ import {
|
||||
import { Subscription } from 'rxjs';
|
||||
import { AuthService } from 'src/app/shared/service/auth.service';
|
||||
import { HttpError } from 'src/app/shared/model/httpError/httpError.model';
|
||||
import HttpErrorChecker from 'src/app/shared/model/httpError/httpErrorChecker';
|
||||
import UserChecker from 'src/app/shared/model/user/user.checker';
|
||||
import { User } from 'src/app/shared/model/user/user.model';
|
||||
import {
|
||||
animate,
|
||||
@@ -27,6 +25,7 @@ import {
|
||||
import { ValidateEmailValidator } from '../../../shared/validators/validate-email.validator';
|
||||
import { ValidatePasswordValidator } from '../../../shared/validators/validate-password.validator';
|
||||
import { ValidateNotEmptyValidator } from '../../../shared/validators/validate-not-empty.validator';
|
||||
import {Value} from "@sinclair/typebox/value";
|
||||
|
||||
const GOOGLE_LOGO_SVG = 'assets/img/providers/google.svg';
|
||||
const GITHUB_LOGO_SVG = 'assets/img/providers/github.svg';
|
||||
@@ -179,10 +178,10 @@ export class SignupComponent implements OnInit {
|
||||
}
|
||||
|
||||
private validateSignup(res: User | HttpError | null) {
|
||||
if (res && UserChecker.test(res)) {
|
||||
if (res && Value.Check(User, res)) {
|
||||
this.closePopup();
|
||||
}
|
||||
if (HttpErrorChecker.test(res)) {
|
||||
if (Value.Check(HttpError, res)) {
|
||||
this.errorMessage = (<HttpError>res).details;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user