-
Notifications
You must be signed in to change notification settings - Fork 125
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1296f97
commit 7902957
Showing
11 changed files
with
129 additions
and
49 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
import { Auth } from './services/auth.service'; | ||
import { BrowserXhr } from '@angular/http'; | ||
import { BrowserXhrWithProgress, ProgressService } from './services/progress.service'; | ||
import { ViewVehicleComponent } from './components/view-vehicle/view-vehicle'; | ||
|
@@ -54,6 +55,7 @@ Raven.config('https://[email protected]/155312').instal | |
providers: [ | ||
{ provide: ErrorHandler, useClass: AppErrorHandler }, | ||
{ provide: BrowserXhr, useClass: BrowserXhrWithProgress }, | ||
Auth, | ||
VehicleService, | ||
PhotoService, | ||
ProgressService | ||
|
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,51 @@ | ||
// app/auth.service.ts | ||
|
||
import { Injectable } from '@angular/core'; | ||
import { tokenNotExpired } from 'angular2-jwt'; | ||
|
||
// Avoid name not found warnings | ||
import Auth0Lock from 'auth0-lock'; | ||
|
||
@Injectable() | ||
export class Auth { | ||
profile: any; | ||
|
||
// Configure Auth0 | ||
lock = new Auth0Lock('RfRu3un13aOO73C7X2mH41qxfHRbUc33', 'vegaproject.auth0.com', {}); | ||
|
||
constructor() { | ||
this.profile = JSON.parse(localStorage.getItem('profile')); | ||
|
||
// Add callback for lock `authenticated` event | ||
this.lock.on("authenticated", (authResult) => { | ||
localStorage.setItem('token', authResult.accessToken); | ||
|
||
this.lock.getUserInfo(authResult.accessToken, (error, profile) => { | ||
if (error) | ||
throw error; | ||
|
||
console.log(profile); | ||
localStorage.setItem('profile', JSON.stringify(profile)); | ||
this.profile = profile; | ||
}); | ||
}); | ||
} | ||
|
||
public login() { | ||
// Call the show method to display the widget. | ||
this.lock.show(); | ||
} | ||
|
||
public authenticated() { | ||
// Check if there's an unexpired JWT | ||
// This searches for an item in localStorage with key == 'token' | ||
return tokenNotExpired('token'); | ||
} | ||
|
||
public logout() { | ||
// Remove token from localStorage | ||
localStorage.removeItem('token'); | ||
localStorage.removeItem('profile'); | ||
this.profile = null; | ||
} | ||
} |
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
Hi sir, I've found the fix for the pre-rendering fails.
It is because of node-formidable (I think, it is dependency of
Auth0Lock
.)Workaround is here: node-formidable/formidable#337
Just add this line to
Webpack
configuration .Thank You Sir, for the Awesome Course . I've learned (& still learning - have not completed yet) from the course, specially Application Architecture.