diff --git a/static/src/app/app.component.html b/static/src/app/app.component.html
index e506d03..5003f64 100644
--- a/static/src/app/app.component.html
+++ b/static/src/app/app.component.html
@@ -15,7 +15,10 @@
- -
+
-
+ Login
+
+ -
Armeeübersicht
-
diff --git a/static/src/app/app.component.ts b/static/src/app/app.component.ts
index a44f11c..0d796f7 100644
--- a/static/src/app/app.component.ts
+++ b/static/src/app/app.component.ts
@@ -47,7 +47,7 @@ export class AppComponent {
logout() {
this.loginService.logout();
- this.router.navigate(['login']);
+ this.router.navigate(['cc-overview']);
return false;
}
diff --git a/static/src/app/app.routing.ts b/static/src/app/app.routing.ts
index 7b13506..a516844 100644
--- a/static/src/app/app.routing.ts
+++ b/static/src/app/app.routing.ts
@@ -12,11 +12,10 @@ import {armyRoutes, armyRoutingComponents} from "./army/army.routing";
export const appRoutes: Routes = [
{path: 'cc-overview', children: armyRoutes},
+ {path: '', redirectTo: '/cc-overview', pathMatch: 'full'},
{path: 'login', component: LoginComponent},
{path: 'cc-users', children: usersRoutes, canActivate: [LoginGuard]},
- {path: '', redirectTo: '/cc-users', pathMatch: 'full'},
-
{path: 'cc-squads', children: squadsRoutes, canActivate: [LoginGuard]},
{path: 'cc-decorations', children: decorationsRoutes, canActivate: [LoginGuard]},
{path: 'cc-ranks', children: ranksRoutes, canActivate: [LoginGuard]},
diff --git a/static/src/app/login/login.component.ts b/static/src/app/login/login.component.ts
index 7df8755..18fbe45 100644
--- a/static/src/app/login/login.component.ts
+++ b/static/src/app/login/login.component.ts
@@ -25,8 +25,8 @@ export class LoginComponent implements OnInit {
ngOnInit() {
// reset login status
this.loginService.logout();
- // get return url from route parameters or default to '/'
- this.returnUrl = this.route.snapshot.queryParams['returnUrl'] || '/';
+ // redirect to user overview on success
+ this.returnUrl = '/cc-users'
}
login(username: string, password: string) {
@@ -41,7 +41,7 @@ export class LoginComponent implements OnInit {
this.showErrorLabel = true;
setTimeout(() => {
this.showErrorLabel = false;
- }, 4000)
+ }, 4000);
this.loading = false;
});
}
diff --git a/static/src/app/services/http-client.ts b/static/src/app/services/http-client.ts
index 088ad03..1a735b8 100644
--- a/static/src/app/services/http-client.ts
+++ b/static/src/app/services/http-client.ts
@@ -13,19 +13,21 @@ export class HttpClient {
createAuthorizationHeader() {
let currentUser = JSON.parse(localStorage.getItem('currentUser'));
- if (new Date().getTime() <= Date.parse(currentUser.tokenExpireDate)) {
- let headers = new Headers();
- headers.append('x-access-token', currentUser.token);
- return headers;
- } else {
- this.loginService.logout();
- this.router.navigate(['/login'])
+ if (currentUser) {
+ if (new Date().getTime() <= Date.parse(currentUser.tokenExpireDate)) {
+ let headers = new Headers();
+ headers.append('x-access-token', currentUser.token);
+ return headers;
+ } else {
+ this.loginService.logout();
+ this.router.navigate(['/login'])
+ }
}
}
get(url, searchParams?) {
let headers = this.createAuthorizationHeader();
- let options:any = {headers: headers};
+ let options: any = {headers: headers};
if (searchParams) {
options.search = searchParams;
}