Skip to content

Commit

Permalink
added login validations
Browse files Browse the repository at this point in the history
  • Loading branch information
Gururajj77 committed Jan 10, 2024
1 parent 1bd182b commit 0b5ecb2
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 18 deletions.
5 changes: 3 additions & 2 deletions src/app/sign-in/sign-in.component.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
<section class="container">
<div class="back-arrow">&lt;</div>
<div class="logo">BREVIPOST</div>

<h2 class="heading">Log In</h2>
<p>
<p class="main-text">
Type in your Email ID and Password for logging into you Brevipost account
</p>
<form [formGroup]="loginForm" (ngSubmit)="signIn()">
Expand Down Expand Up @@ -36,6 +35,8 @@ <h2 class="heading">Log In</h2>
} @if (loginForm.controls['password'].errors?.['pattern'] &&
loginForm.controls['password'].touched) {
<p class="error-message">Password does not meet complexity requirements.</p>
} @if (ERROR_CODE==="auth/invalid-credential") {
<p class="error-message">Invalid Login credentails.</p>
}

<button type="submit">Log In</button>
Expand Down
9 changes: 3 additions & 6 deletions src/app/sign-in/sign-in.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,15 @@
position: relative;
height: 100%;
background-color: #f5f5f5;
padding: 20px;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}

.back-arrow {
position: absolute;
top: 20px;
left: 20px;
.main-text {
padding: 10px;
text-align: center;
}

.heading {
Expand Down Expand Up @@ -46,7 +44,6 @@ input[type="password"] {
text-align: center;
font-size: 0.8rem;
height: 20px;
margin-top: 5px;
}

button {
Expand Down
14 changes: 4 additions & 10 deletions src/app/sign-in/sign-in.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export class SignInComponent {
private readonly auth: Auth = inject(Auth);
private readonly router: Router = inject(Router);
private readonly formBuilder: FormBuilder = inject(FormBuilder);

ERROR_CODE: string = "";
ngOnInit() {
this.loginForm = this.formBuilder.group({
email: ['', [Validators.required, Validators.email]],
Expand All @@ -34,13 +34,9 @@ export class SignInComponent {
const email = this.loginForm.get('email')!.value;
const password = this.loginForm.get('password')!.value;
signInWithEmailAndPassword(this.auth, email, password)
.then(userCredential => {
const user = userCredential.user;
console.log(userCredential)
})
.catch(error => {
const errorCode = error.code;
const errorMessage = error.message;
.catch((error) => {
this.ERROR_CODE = error.code
console.log(this.ERROR_CODE)
});
}

Expand All @@ -51,8 +47,6 @@ export class SignInComponent {
signInWithPopup(this.auth, provider)
.then((result) => {
const credential = GoogleAuthProvider.credentialFromResult(result);
const token = credential?.accessToken;
const user = result.user;
}).catch((error) => {
const credential = GoogleAuthProvider.credentialFromError(error);
});
Expand Down

0 comments on commit 0b5ecb2

Please sign in to comment.