Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- constructor(
- private validateService: ValidateService,
- private authService: AuthService,
- private router: Router
- ) { }
- ngOnInit() {
- }
- onRegisterSubmit(){
- const user ={
- name: this.name,
- email: this.email,
- username: this.username,
- password: this.password
- }
- if(!this.validateService.validateRegister(user)){
- console.log('Please fill in all fields');
- return false;
- }
- if(!this.validateService.validateEmail(user.email)){
- console.log('Please use a valid email');
- return false;
- }
- //registering the user
- this.authService.registerUser(user).subscribe(data=>{
- if(data.success){
- console.log('Registered Us+er');
- this.router.navigate(['/login'])
- }else{
- console.log('Failed to register User');
- this.router.navigate(['/register'])
- }
- });
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement