Skip to content

Instantly share code, notes, and snippets.

@dasmido
Last active January 20, 2018 22:13
Show Gist options
  • Save dasmido/c1ee6d92f6bf21e263211f7b592e1fb2 to your computer and use it in GitHub Desktop.
Save dasmido/c1ee6d92f6bf21e263211f7b592e1fb2 to your computer and use it in GitHub Desktop.
onLoginSubmit(){
//console.log(this.username);
const user = {
username: this.username,
password: this.password
}
this.authService.authenticateUser(user).subscribe(data => {
//console.log(data);
if(data.success){
this.authService.storeUserData(data.token, data.user);
this.flashMessage.show('You are now logged in', {
cssClass: 'alert-success',
timeout: 5000});
this.router.navigate(['dashboard']);
}else{
this.flashMessage.show(data.msg, {
cssClass: 'alert-danger',
timeout: 5000});
this.router.navigate(['login']);
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment