Skip to content

Commit b4dc28d

Browse files
committed
chore: update to alpha 29
1 parent e1907d6 commit b4dc28d

File tree

10 files changed

+835
-156
lines changed

10 files changed

+835
-156
lines changed

package.json

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "angular2-full-app-demo",
2+
"name": "angular2-authentication-sample",
33
"version": "0.0.0",
44
"description": "This is a sample that shows how to add authentication to an Angular 2 (ng2) app",
55
"main": "",
@@ -11,17 +11,20 @@
1111
"type": "git",
1212
"url": "https://github.com/auth0/angular2-authentication-sample.git"
1313
},
14-
"author": "Martin Gontovnikas (http://gon.to) <martin@gon.to>",
14+
"contributors": [
15+
"Martin Gontovnikas (http://gon.to) <martin@gon.to>",
16+
"PatrickJS <github@gdi2290.com>"
17+
],
1518
"license": "MIT",
1619
"bugs": {
1720
"url": "https://github.com/auth0/angular2-authentication-sample/issues"
1821
},
1922
"homepage": "https://github.com/auth0/angular2-authentication-sample",
2023
"dependencies": {
21-
"angular2": "2.0.0-alpha.26",
24+
"angular2": "2.0.0-alpha.29",
2225
"raw-loader": "^0.5.1",
2326
"reflect-metadata": "^0.1.0",
24-
"rtts_assert": "2.0.0-alpha.26",
27+
"rtts_assert": "2.0.0-alpha.29",
2528
"rx": "^2.5.3",
2629
"zone.js": "^0.5.0",
2730
"bootstrap": "~3.3.4",

src/app/LoggedInOutlet.ts

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,29 +3,27 @@ import {Router, RouterOutlet} from 'angular2/router';
33
import {Injector} from 'angular2/di';
44
import {Login} from '../login/login';
55

6-
@Directive({selector: 'router-outlet'})
6+
@Directive({
7+
selector: 'router-outlet'
8+
})
79
export class LoggedInRouterOutlet extends RouterOutlet {
810
publicRoutes: any
9-
constructor(
10-
elementRef: ElementRef,
11-
_loader: DynamicComponentLoader,
12-
_parentRouter: Router,
13-
_injector: Injector,
14-
@Attribute('name') nameAttr: string) {
11+
constructor(public _elementRef: ElementRef, public _loader: DynamicComponentLoader,
12+
public _parentRouter: Router, @Attribute('name') nameAttr: string) {
13+
super(_elementRef, _loader, _parentRouter, nameAttr);
1514

1615
this.publicRoutes = {
1716
'/login': true,
1817
'/signup': true
1918
};
2019

21-
super(elementRef, _loader, _parentRouter, _injector, nameAttr);
2220
}
2321

2422
activate(instruction) {
2523
var url = this._parentRouter.lastNavigationAttempt;
2624
if (!this.publicRoutes[url] && !localStorage.getItem('jwt')) {
2725
instruction.component = Login;
2826
}
29-
super.activate(instruction);
27+
return super.activate(instruction);
3028
}
3129
}

src/app/app.html

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
<router-outlet>
2-
</router-outlet>
1+
<router-outlet></router-outlet>

src/app/app.ts

Lines changed: 9 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
/// <reference path="../../typings/tsd.d.ts" />
22

33
import {View, Component} from 'angular2/angular2';
4+
import {Location, RouteConfig, RouterLink, Router} from 'angular2/router';
5+
import {LoggedInRouterOutlet} from './LoggedInOutlet';
46
import {Home} from '../home/home';
57
import {Login} from '../login/login';
68
import {Signup} from '../signup/signup';
7-
import {RouteConfig, RouterOutlet, RouterLink, Router} from 'angular2/router';
8-
import {BrowserLocation} from 'angular2/src/router/browser_location';
9-
import {LoggedInRouterOutlet} from './LoggedInOutlet';
109

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

@@ -15,33 +14,16 @@ let template = require('./app.html');
1514
selector: 'auth-app'
1615
})
1716
@View({
18-
template:`${template}`,
19-
directives: [LoggedInRouterOutlet]
17+
template: template,
18+
directives: [ LoggedInRouterOutlet ]
2019
})
2120
@RouteConfig([
22-
{ path: '/home', as: 'home', component: Home },
23-
{ path: '/login', as: 'login', component: Login },
24-
{ path: '/signup', as: 'signup', component: Signup }
21+
{ path: '/', redirectTo: '/home' },
22+
{ path: '/home', as: 'home', component: Home },
23+
{ path: '/login', as: 'login', component: Login },
24+
{ path: '/signup', as: 'signup', component: Signup }
2525
])
2626
export class App {
27-
router: Router;
28-
constructor(router: Router, browserLocation: BrowserLocation) {
29-
// we need to manually go to the correct uri until the router is fixed
30-
this.router = router;
31-
let uri = browserLocation.path();
32-
if (uri === '' || uri === '/') {
33-
router.navigate('/home');
34-
} else {
35-
router.navigate(uri);
36-
}
37-
}
38-
39-
goTo(event, url) {
40-
event.preventDefault();
41-
this.router.navigate(url).then(() => {
42-
console.log("Router successfully to", url);
43-
}, () => {
44-
console.log("Error going to URL", url);
45-
});
27+
constructor(public router: Router) {
4628
}
4729
}

src/common/formInjectables.ts

Lines changed: 0 additions & 6 deletions
This file was deleted.

src/home/home.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,17 @@ let template = require('./home.html');
1313
selector: 'home'
1414
})
1515
@View({
16-
template:`<style>${styles}</style>\n${template}`,
17-
directives: [coreDirectives]
16+
styles: [ styles ],
17+
template: template,
18+
directives: [ coreDirectives ]
1819
})
1920
export class Home {
2021
jwt: string;
2122
decodedJwt: string;
22-
router: Router;
2323
response: string;
2424
api: string;
2525

26-
constructor(router: Router) {
27-
this.router = router;
26+
constructor(public router: Router) {
2827
this.jwt = localStorage.getItem('jwt');
2928
this.decodedJwt = this.jwt && window.jwt_decode(this.jwt);
3029
}

src/index.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
/// <reference path="../typings/tsd.d.ts" />
22

3-
import {routerInjectables} from 'angular2/router';
4-
import {formInjectables} from './common/formInjectables';
53
import { bootstrap } from 'angular2/angular2';
64
import { bind } from 'angular2/di';
7-
import { PipeRegistry } from 'angular2/change_detection';
5+
import { routerInjectables } from 'angular2/router';
6+
import { formInjectables } from 'angular2/forms';
7+
import { httpInjectables } from 'angular2/http';
88

99
import { App } from './app/app';
1010

1111
bootstrap(
1212
App,
1313
[
1414
formInjectables,
15-
routerInjectables
15+
routerInjectables,
16+
httpInjectables
1617
]
1718
);

src/login/login.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ let template = require('./login.html');
1313
selector: 'login'
1414
})
1515
@View({
16-
template:`<style>${styles}</style>\n${template}`,
16+
styles: [ styles ],
17+
template: template,
1718
directives: [RouterLink]
1819
})
1920
export class Login {

src/signup/signup.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,12 @@ let template = require('./signup.html');
1212
selector: 'signup'
1313
})
1414
@View({
15-
directives: [RouterLink, coreDirectives],
16-
template:`<style>${styles}</style>\n${template}`
17-
15+
directives: [ RouterLink, coreDirectives ],
16+
styles: [ styles ],
17+
template: template
1818
})
1919
export class Signup {
20-
router: Router;
21-
22-
constructor(router: Router) {
23-
this.router = router;
20+
constructor(public router: Router) {
2421
}
2522

2623
signup(event, username, password) {

0 commit comments

Comments
 (0)