Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
fa66232
Update webpack.config.js
Jun 13, 2015
e1907d6
Merge pull request #20 from xtrasmal/patch-1
mgonto Jun 15, 2015
b4dc28d
chore: update to alpha 29
PatrickJS Jul 7, 2015
1f3c37e
Merge pull request #24 from gdi2290/alpha-29-update
mgonto Jul 7, 2015
6eb299a
Update Readme.md
mgonto Jul 7, 2015
92203ee
Update to Angular 2.0.0-alpha.30
Jul 8, 2015
8c15345
Merge pull request #25 from NathanWalker/master
mgonto Jul 8, 2015
f2d440b
Update Readme.md
mgonto Jul 24, 2015
4d97d19
chore(dependencies): updated to latest and made immutable
valorkin Oct 19, 2015
fc56f85
chore(start): updated ng2 0.44
valorkin Oct 19, 2015
9aa60d3
feat(backend): added backend
valorkin Oct 19, 2015
52018bf
chore(start): added npm command to start server
valorkin Oct 19, 2015
477b1ca
chore(traceur): removed, angular2 doesn't need it anymore
valorkin Oct 19, 2015
bd00b5a
chore(auth): redirect to /login if not authenticated
valorkin Oct 19, 2015
4fdaabe
chore(ui): styles fixed
valorkin Oct 19, 2015
8a9d63b
chore(navigation): navigation fixed
valorkin Oct 19, 2015
78ecb66
Merge pull request #38 from valor-software/master
mgonto Oct 19, 2015
9a80ef0
(fix) Update to work with agular2 beta 0
chenkie Jan 8, 2016
2eb9dc2
(fix) Proper error handling in HTTP requests
chenkie Jan 8, 2016
aad6352
Merge pull request #40 from chenkie/master
chenkie Jan 8, 2016
fc3c035
Logical precedence problem fixed
neilyoung Jan 11, 2016
fa4ad60
Readme and license fix
Jan 12, 2016
7f9b43d
Merge pull request #47 from aguerere/fix-issue46-license-and-readme
chenkie Jan 14, 2016
f2a7166
Update LoggedInOutlet.ts
Jan 20, 2016
5ed9d2a
supress pre-built javascript message
enaukkarinen Feb 5, 2016
8161e67
Removed no trailing comma from tslint. Closes #55.
chenkie Feb 26, 2016
c043d04
Merge pull request #53 from enaukkarinen/prebuilt-message-supress
chenkie Feb 26, 2016
0bb7148
Updated to Angular 2 beta 9
chenkie Mar 11, 2016
91f67a3
Merge pull request #49 from MasterKale/master
chenkie Mar 27, 2016
29f251c
Merge pull request #45 from neilyoung/master
chenkie Apr 18, 2016
4ed4b9c
Updated to rc.1. Closes #64.
chenkie May 18, 2016
0a3bc73
Update to rc.3
chenkie Jun 24, 2016
a87294d
Updated license
chenkie Jun 24, 2016
4474a12
Routes formatting
chenkie Jun 24, 2016
d7c6052
Upgrade to Angular 2 final and update articles section in readme
sonicoder86 Oct 2, 2016
3d5f962
Merge pull request #77 from blacksonic/master
chenkie Oct 4, 2016
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
Prev Previous commit
Next Next commit
Upgrade to Angular 2 final and update articles section in readme
  • Loading branch information
sonicoder86 committed Oct 2, 2016
commit d7c6052a7aab7f6ab31cb7c8d1c7292269967c18
6 changes: 5 additions & 1 deletion Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ This sample shows how to create an angular 2 app that:
* **Calls APIs** authenticated and not.
* Extends the **RouterOutlet** for route pipeline changes.

> You can **learn more about how it works [in this blogpost](https://auth0.com/blog/2015/05/14/creating-your-first-real-world-angular-2-app-from-authentication-to-calling-an-api-and-everything-in-between/)**
You can **learn more about how it works in the following blogposts**

* [Angular 2 Authentication Tutorial](https://auth0.com/blog/angular-2-authentication/)
* [Protecting Routes using Guards in Angular 2](http://blog.thoughtram.io/angular/2016/07/18/guards-in-angular-2.html)
* [Angular 2 authentication revisited](https://medium.com/@blacksonic86/angular-2-authentication-revisited-611bf7373bf9)

## Running it

Expand Down
40 changes: 19 additions & 21 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,26 +24,24 @@
},
"homepage": "https://github.com/auth0/angular2-authentication-sample",
"dependencies": {
"@angular/common": "2.0.0-rc.3",
"@angular/compiler": "2.0.0-rc.3",
"@angular/core": "2.0.0-rc.3",
"@angular/http": "2.0.0-rc.3",
"@angular/platform-browser": "2.0.0-rc.3",
"@angular/platform-browser-dynamic": "2.0.0-rc.3",
"@angular/platform-server": "2.0.0-rc.3",
"@angular/router": "3.0.0-alpha.7",
"angular2-jwt": "0.1.16",
"bootstrap": "^3.3.6",
"core-js": "^2.4.0",
"es6-promise": "^3.1.2",
"es6-shim": "^0.33.13",
"es7-reflect-metadata": "^1.6.0",
"@angular/common": "2.0.1",
"@angular/compiler": "2.0.1",
"@angular/core": "2.0.1",
"@angular/forms": "2.0.1",
"@angular/http": "2.0.1",
"@angular/platform-browser": "2.0.1",
"@angular/platform-browser-dynamic": "2.0.1",
"@angular/platform-server": "2.0.1",
"@angular/router": "3.0.1",
"angular2-jwt": "0.1.23",
"bootstrap": "^3.3.7",
"core-js": "^2.4.1",
"jwt-decode": "^2.0.1",
"rxjs": "5.0.0-beta.6",
"zone.js": "~0.6.12"
"rxjs": "5.0.0-beta.12",
"zone.js": "~0.6.25"
},
"devDependencies": {
"css-loader": "^0.23.1",
"css-loader": "^0.25.0",
"exports-loader": "^0.6.3",
"expose-loader": "^0.7.1",
"file-loader": "^0.9.0",
Expand All @@ -52,14 +50,14 @@
"raw-loader": "^0.5.1",
"style-loader": "^0.13.1",
"ts-loader": "^0.8.1",
"tsconfig-lint": "^0.7.0",
"tsconfig-lint": "^0.12.0",
"tslint": "^3.7.1",
"tslint-loader": "^2.1.3",
"typedoc": "^0.4.3",
"typescript": "~1.8.10",
"typescript": "~2.0.3",
"typings": "^1.3.0",
"url-loader": "^0.5.7",
"webpack": "^1.13.1",
"webpack-dev-server": "^1.14.1"
"webpack": "^1.13.2",
"webpack-dev-server": "^1.16.1"
}
}
32 changes: 32 additions & 0 deletions src/app.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { BrowserModule } from '@angular/platform-browser';
import { RouterModule } from '@angular/router';
import { HttpModule } from '@angular/http';
import { FormsModule } from '@angular/forms';
import { NgModule } from '@angular/core';

import { AUTH_PROVIDERS } from 'angular2-jwt';

import { AuthGuard } from './common/auth.guard';
import { Home } from './home';
import { Login } from './login';
import { Signup } from './signup';
import { App } from './app';

import { routes } from './app.routes';

@NgModule({
bootstrap: [App],
declarations: [
Home, Login, Signup, App
],
imports: [
HttpModule, BrowserModule, FormsModule,
RouterModule.forRoot(routes, {
useHash: true
})
],
providers: [
AuthGuard, ...AUTH_PROVIDERS
]
})
export class AppModule {}
6 changes: 3 additions & 3 deletions src/app.routes.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { RouterConfig } from '@angular/router';
import { Routes } from '@angular/router';
import { Home } from './home';
import { Login } from './login';
import { Signup } from './signup';
import { AuthGuard } from './common/auth.guard';

export const routes: RouterConfig = [
{ path: '', component: Login },
export const routes: Routes = [
{ path: '', component: Login },
{ path: 'login', component: Login },
{ path: 'signup', component: Signup },
{ path: 'home', component: Home, canActivate: [AuthGuard] },
Expand Down
5 changes: 2 additions & 3 deletions src/app.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import { Component } from '@angular/core';
import { Router, ROUTER_DIRECTIVES } from '@angular/router';
import { Router } from '@angular/router';

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

@Component({
selector: 'auth-app',
template: template,
directives: [ ROUTER_DIRECTIVES ]
template: template
})

export class App {
Expand Down
6 changes: 2 additions & 4 deletions src/home/home.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Component } from '@angular/core';
import { CORE_DIRECTIVES } from '@angular/common';
import { Http, Headers } from '@angular/http';
import { Http } from '@angular/http';
import { Router } from '@angular/router';
import { AuthHttp } from 'angular2-jwt';

Expand All @@ -9,7 +8,6 @@ const template = require('./home.html');

@Component({
selector: 'home',
directives: [ CORE_DIRECTIVES ],
template: template,
styles: [ styles ]
})
Expand All @@ -26,7 +24,7 @@ export class Home {

logout() {
localStorage.removeItem('id_token');
this.router.navigate(['/login']);
this.router.navigate(['login']);
}

callAnonymousApi() {
Expand Down
21 changes: 3 additions & 18 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,5 @@
import { bootstrap } from '@angular/platform-browser-dynamic';
import { provideRouter } from '@angular/router';
import { FORM_PROVIDERS } from '@angular/common';
import { HTTP_PROVIDERS } from '@angular/http';
import { AUTH_PROVIDERS } from 'angular2-jwt';
import { AuthGuard } from './common/auth.guard';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';

import { App } from './app';
import { routes } from './app.routes';
import { AppModule } from './app.module';

bootstrap(
App,
[
provideRouter(routes),
FORM_PROVIDERS,
HTTP_PROVIDERS,
AUTH_PROVIDERS,
AuthGuard
]
);
platformBrowserDynamic().bootstrapModule(AppModule);
10 changes: 4 additions & 6 deletions src/login/login.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
import { Component } from '@angular/core';
import { Router, ROUTER_DIRECTIVES } from '@angular/router';
import { CORE_DIRECTIVES, FORM_DIRECTIVES } from '@angular/common';
import { Http, Headers } from '@angular/http';
import { Router } from '@angular/router';
import { Http } from '@angular/http';
import { contentHeaders } from '../common/headers';

const styles = require('./login.css');
const template = require('./login.html');

@Component({
selector: 'login',
directives: [ ROUTER_DIRECTIVES, CORE_DIRECTIVES, FORM_DIRECTIVES ],
template: template,
styles: [ styles ]
})
Expand All @@ -24,7 +22,7 @@ export class Login {
.subscribe(
response => {
localStorage.setItem('id_token', response.json().id_token);
this.router.navigate(['/home']);
this.router.navigate(['home']);
},
error => {
alert(error.text());
Expand All @@ -35,6 +33,6 @@ export class Login {

signup(event) {
event.preventDefault();
this.router.navigate(['/signup']);
this.router.navigate(['signup']);
}
}
6 changes: 2 additions & 4 deletions src/signup/signup.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Component } from '@angular/core';
import { Router } from '@angular/router';
import { CORE_DIRECTIVES, FORM_DIRECTIVES } from '@angular/common';
import { Http } from '@angular/http';
import { contentHeaders } from '../common/headers';

Expand All @@ -9,7 +8,6 @@ const template = require('./signup.html');

@Component({
selector: 'signup',
directives: [ CORE_DIRECTIVES, FORM_DIRECTIVES ],
template: template,
styles: [ styles ]
})
Expand All @@ -24,7 +22,7 @@ export class Signup {
.subscribe(
response => {
localStorage.setItem('id_token', response.json().id_token);
this.router.navigate(['/home']);
this.router.navigate(['home']);
},
error => {
alert(error.text());
Expand All @@ -35,7 +33,7 @@ export class Signup {

login(event) {
event.preventDefault();
this.router.navigate(['/login']);
this.router.navigate(['login']);
}

}
9 changes: 4 additions & 5 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ module.exports = {
entry: {
'vendor': [
// Polyfills
'core-js/es6',
'core-js/es7/reflect',
'core-js/client/shim',
'zone.js/dist/zone',
'zone.js/dist/long-stack-trace-zone',
// Angular2
Expand Down Expand Up @@ -88,7 +87,7 @@ module.exports = {
/zone\.js\/dist\/.+/,
/reflect-metadata/,
/es(6|7)-.+/,
/.zone-microtask/,
/.zone-microtask/,
/.long-stack-trace-zone/
]
},
Expand All @@ -97,13 +96,13 @@ module.exports = {
new CommonsChunkPlugin({ name: 'vendor', filename: 'vendor.js', minChunks: Infinity }),
new CommonsChunkPlugin({ name: 'common', filename: 'common.js', minChunks: 2, chunks: ['app', 'vendor'] })
],

// Other module loader config
tslint: {
emitErrors: false,
failOnHint: false
},

// our Development Server configs
// our Webpack Development Server config
devServer: {
Expand Down