Skip to content

Commit

Permalink
BUG/67-trim-outer-user-name-on-login-signup
Browse files Browse the repository at this point in the history
credentials data trimmed
  • Loading branch information
priteshyadav444 committed Mar 13, 2023
2 parents 6545ecb + 7ca3561 commit 2c5f598
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 55 deletions.
70 changes: 42 additions & 28 deletions src/app/component/auth/login/login.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ import { Router } from '@angular/router';
import { Store } from '@ngrx/store';
import { AppState } from 'src/app/app-store/app.state';
import { setLoadingSpinner } from 'src/app/component/shared/state/Shared/shared.actions';
import { getLoading, getLogoLoading } from 'src/app/component/shared/state/Shared/shared.selector';
import {
getLoading,
getLogoLoading,
} from 'src/app/component/shared/state/Shared/shared.selector';
import { loginStart } from '../state/auth.actions';

@Component({
Expand All @@ -15,44 +18,55 @@ import { loginStart } from '../state/auth.actions';
})
export class LoginComponent implements OnInit {
password!: string;
constructor(private router: Router,private store:Store<AppState>, private titleService: Title) {}
loginForm!:FormGroup
constructor(
private router: Router,
private store: Store<AppState>,
private titleService: Title
) {}
loginForm!: FormGroup;
ngOnInit(): void {
this.titleService.setTitle("Login - TaskEasy.in");
this.titleService.setTitle('Login - TaskEasy.in');
this.loginForm = new FormGroup({
email: new FormControl('', [Validators.required, Validators.email]),
password: new FormControl('',[ Validators.required, Validators.minLength(8)]),
});
this.store.select(getLoading).pipe().forEach((value)=>{
if(value==true){
this.titleService.setTitle("Checking your credentials...");
}
else{
this.titleService.setTitle("Login - TaskEasy.in");
}
password: new FormControl('', [
Validators.required,
Validators.minLength(8),
]),
});
this.store
.select(getLoading)
.pipe()
.forEach((value) => {
if (value == true) {
this.titleService.setTitle('Checking your credentials...');
} else {
this.titleService.setTitle('Login - TaskEasy.in');
}
});

this.store.select(getLogoLoading).pipe().forEach((value)=>{
if(value==true){
this.titleService.setTitle("Checking your credentials...");
}
else{
this.titleService.setTitle("Login - TaskEasy.in");
}
});
this.store
.select(getLogoLoading)
.pipe()
.forEach((value) => {
if (value == true) {
this.titleService.setTitle('Checking your credentials...');
} else {
this.titleService.setTitle('Login - TaskEasy.in');
}
});
}

onSignUpClick (this:any) {
onSignUpClick(this: any) {
this.router.navigateByUrl('/signup');
};
}

onSignInSubmit(){
if(this.loginForm.invalid){
return
onSignInSubmit() {
if (this.loginForm.invalid) {
return;
}

const email = this.loginForm.value.email;
const password = this.loginForm.value.password;
const email = this.loginForm.value.email.trim();
const password = this.loginForm.value.password.trim();
this.store.dispatch(setLoadingSpinner({ status: true }));
this.store.dispatch(loginStart({ email, password }));
}
Expand Down
67 changes: 40 additions & 27 deletions src/app/component/auth/signup/signup.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,62 +6,75 @@ import { Store } from '@ngrx/store';
import { MessageService } from 'primeng/api';
import { Observable } from 'rxjs';
import { AppState } from 'src/app/app-store/app.state';
import { setLoadingSpinner, setLogoLoading } from 'src/app/component/shared/state/Shared/shared.actions';
import { getErrorMessage, getLoading, getLogoLoading } from 'src/app/component/shared/state/Shared/shared.selector';
import {
setLoadingSpinner,
setLogoLoading,
} from 'src/app/component/shared/state/Shared/shared.actions';
import {
getErrorMessage,
getLoading,
getLogoLoading,
} from 'src/app/component/shared/state/Shared/shared.selector';
import { signupStart } from '../state/auth.actions';

@Component({
selector: 'app-signup',
templateUrl: './signup.component.html',
styleUrls: ['./signup.component.css'],

})
export class SignupComponent implements OnInit {
signUpForm!: FormGroup;
errorMessage!:Observable<string>;
constructor(private router: Router,private store :Store<AppState>, private titleService: Title) {}

errorMessage!: Observable<string>;
constructor(
private router: Router,
private store: Store<AppState>,
private titleService: Title
) {}

confirmPassword(signUpForm: FormGroup) {
return signUpForm.controls['newPassword'].value === signUpForm.controls['repeatNewPassword'].value ? null : {'mismatch': true};
return signUpForm.controls['newPassword'].value ===
signUpForm.controls['repeatNewPassword'].value
? null
: { mismatch: true };
}
ngOnInit(): void {
this.titleService.setTitle("Signup - TaskEasy.in");
this.titleService.setTitle('Signup - TaskEasy.in');
this.signUpForm = new FormGroup({
firstname: new FormControl('', Validators.required),
lastname: new FormControl('', Validators.required),
email: new FormControl('', [Validators.required, Validators.email]),
password: new FormControl('', [ Validators.required, Validators.minLength(8)]),

password: new FormControl('', [
Validators.required,
Validators.minLength(8),
]),
});

this.store.select(getLogoLoading).pipe().forEach((value)=>{
if(value==true){
this.titleService.setTitle("checking......");
}
else{
this.titleService.setTitle("Signup - TaskEasy.in");
}
});

this.store
.select(getLogoLoading)
.pipe()
.forEach((value) => {
if (value == true) {
this.titleService.setTitle('checking......');
} else {
this.titleService.setTitle('Signup - TaskEasy.in');
}
});
}

onSignUpSubmit() {
console.log('SignUp');
const firstname = this.signUpForm.value.firstname
const lastname = this.signUpForm.value.lastname
const email = this.signUpForm.value.email
const password = this.signUpForm.value.password
const firstname = this.signUpForm.value.firstname.trim();
const lastname = this.signUpForm.value.lastname.trim();
const email = this.signUpForm.value.email.trim();
const password = this.signUpForm.value.password.trim();
if (this.signUpForm.invalid) {
return;
}
this.store.dispatch(setLogoLoading({ status: true }));
this.store.dispatch(signupStart({firstname,lastname,email,password}))
this.store.dispatch(signupStart({ firstname, lastname, email, password }));
console.log('SignUp');
}
onSignInClick(this: any) {
this.router.navigateByUrl('/login');
}


}

0 comments on commit 2c5f598

Please sign in to comment.