Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace router outlet override with @CanActivate check
- Loading branch information
Showing
9 changed files
with
39 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import {Router, CanActivate} from 'angular2/router'; | ||
import AuthenticationService from '../../services/authentication'; | ||
import Context from '../../context'; | ||
|
||
export default function (constr: Function): any { | ||
return CanActivate(() => { | ||
if (Context.injector.get(AuthenticationService).authenticated) { | ||
return true; | ||
} else { | ||
Context.injector.get(Router).navigate(['Login']); | ||
return false; | ||
} | ||
})(constr); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import {Injector} from 'angular2/core'; | ||
|
||
export default class Context { | ||
private static _injector: Injector; | ||
|
||
static get injector (): Injector { | ||
return this._injector; | ||
} | ||
|
||
static set injector (value: Injector) { | ||
this._injector = value; | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.