Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
},
"homepage": "https://github.com/auth0/angular2-authentication-sample",
"dependencies": {
"angular2": "2.0.0-alpha.26",
"angular2": "^2.0.0-alpha.29",
"raw-loader": "^0.5.1",
"reflect-metadata": "^0.1.0",
"rtts_assert": "2.0.0-alpha.26",
"rtts_assert": "2.0.0-alpha.29",
"rx": "^2.5.3",
"zone.js": "^0.5.0",
"bootstrap": "~3.3.4",
Expand Down
31 changes: 18 additions & 13 deletions src/app/LoggedInOutlet.ts
Original file line number Diff line number Diff line change
@@ -1,31 +1,36 @@
import {Directive, Attribute, ElementRef, DynamicComponentLoader} from 'angular2/angular2';
import {Directive, Attribute} from 'angular2/annotations';
import {ElementRef, DynamicComponentLoader} from 'angular2/core';
import {Router, RouterOutlet} from 'angular2/router';
import {Injector} from 'angular2/di';
import {Login} from '../login/login';

import * as routerMod from 'angular2/router';

@Directive({selector: 'router-outlet'})
export class LoggedInRouterOutlet extends RouterOutlet {
export class LoggedInRouterOutlet extends routerMod.RouterOutlet {

publicRoutes: any
constructor(
elementRef: ElementRef,
_loader: DynamicComponentLoader,
_parentRouter: Router,
_parentRouter: routerMod.Router,
_injector: Injector,
@Attribute('name') nameAttr: string) {

@Attribute('name') nameAttr: string) {
this.publicRoutes = {
'/login': true,
'/signup': true
};

super(elementRef, _loader, _parentRouter, _injector, nameAttr);

}

activate(instruction) {
var url = this._parentRouter.lastNavigationAttempt;
if (!this.publicRoutes[url] && !localStorage.getItem('jwt')) {
instruction.component = Login;
}
super.activate(instruction);
}
// activate(instruction) {
// var url = this._parentRouter.lastNavigationAttempt;
// if (!this.publicRoutes[url] && !localStorage.getItem('jwt')) {
// instruction.component = Login;
// }
// super.activate(instruction);
// }
}
20 changes: 10 additions & 10 deletions src/app/app.ts
Original file line number Diff line number Diff line change
@@ -1,38 +1,38 @@
/// <reference path="../../typings/tsd.d.ts" />

import {View, Component} from 'angular2/angular2';
import {View, Component} from 'angular2/annotations';
import {Home} from '../home/home';
import {Login} from '../login/login';
import {Signup} from '../signup/signup';
import {RouteConfig, RouterOutlet, RouterLink, Router} from 'angular2/router';
import {BrowserLocation} from 'angular2/src/router/browser_location';
import {Router, RouteConfig} from 'angular2/router';
import {Location} from 'angular2/router';
import {LoggedInRouterOutlet} from './LoggedInOutlet';

let template = require('./app.html');


@Component({
selector: 'auth-app'
selector: 'auth-app',
viewInjector: [Location]
})
@View({
template:`${template}`,
directives: [LoggedInRouterOutlet]
})
@RouteConfig([
{ path: '/home', as: 'home', component: Home },
{ path: '/home', as: 'home', component: Home },
{ path: '/login', as: 'login', component: Login },
{ path: '/signup', as: 'signup', component: Signup }
])
export class App {
router: Router;
constructor(router: Router, browserLocation: BrowserLocation) {
constructor(router:Router, location: Location) {
// we need to manually go to the correct uri until the router is fixed
this.router = router;
let uri = browserLocation.path();
let uri = location.path();
if (uri === '' || uri === '/') {
router.navigate('/home');
} else {
router.navigate(uri);
//} else {
//router.navigate(uri);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/home/home.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/// <reference path="../../typings/tsd.d.ts" />

import {Component, View} from 'angular2/angular2';
import {Component, View} from 'angular2/annotations';
import {coreDirectives} from 'angular2/directives';
import {status, text} from '../utils/fetch'
import { Router} from 'angular2/router';
Expand Down
2 changes: 1 addition & 1 deletion src/login/login.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/// <reference path="../../typings/tsd.d.ts" />

import {Component, View} from 'angular2/angular2';
import {Component, View} from 'angular2/annotations';
import {status, json} from '../utils/fetch'
import { Router, RouterLink } from 'angular2/router';

Expand Down
2 changes: 1 addition & 1 deletion src/signup/signup.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/// <reference path="../../typings/tsd.d.ts" />

import {coreDirectives} from 'angular2/directives';
import {Component, View} from 'angular2/angular2';
import {Component, View} from 'angular2/annotations';
import {status, json} from '../utils/fetch';
import { Router, RouterLink } from 'angular2/router';

Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "1.5.0",
"version": "1.5.1",
"compilerOptions": {
"target": "es5",
"module": "commonjs",
Expand Down
Loading