Skip to content

Instantly share code, notes, and snippets.

@Austio
Last active February 26, 2016 16:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Austio/2cb4abe7d5c4dd8654f6 to your computer and use it in GitHub Desktop.
Save Austio/2cb4abe7d5c4dd8654f6 to your computer and use it in GitHub Desktop.
app.ts
@RouteConfig([
{ path: '/login', name: 'Login', component: LoginFormCmp, useAsDefault: true },
{ path: '/home', name: 'Home', component: HomeCmp},
{ path: '/system/health', name: 'SystemHealth', component: SystemHealthCmp }
])
login-form.component.ts #REDIRECTS PROPERLY
onSubmit(email, password) {
let sessionParams = {user_session: {login: email, password: password}};
this.loginService.create(sessionParams).subscribe(
response => this.onSuccess(response)
);
}
onSuccess(response) {
let authObj = response.data.auth;
this.sessionService.setSession(authObj);
this.router.navigate(['Home']);
}
top-nav.ts #DOES NOT REDIRECT PROPERLY, SENDS TO HOME
logOut() {
this.sessionService.clearSession();
this.router.navigateByUrl(['Login']);
}
#ALSO TRIED LIKE THIS STILL SENDS TO HOME
logOut() {
this.sessionService.clearSession();
this.router.navigateByUrl('/login');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment