-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from MycroftAI/dev
2018.3 to master
- Loading branch information
Showing
90 changed files
with
2,211 additions
and
1,287 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { NgModule } from '@angular/core'; | ||
import { Routes, RouterModule } from '@angular/router'; | ||
|
||
import { LoginComponent } from "./login/login.component"; | ||
import { LogoutComponent } from "./logout/logout.component"; | ||
// import { PageNotFoundComponent } from "./page-not-found/page-not-found.component"; | ||
|
||
const routes: Routes = [ | ||
{ path: 'login', component: LoginComponent }, | ||
{ path: 'logout', component: LogoutComponent }, | ||
// { path: '**', component: PageNotFoundComponent } | ||
]; | ||
|
||
@NgModule({ | ||
imports: [ RouterModule.forRoot(routes) ], | ||
exports: [ RouterModule ] | ||
}) | ||
export class AppRoutingModule { | ||
} |
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 was deleted.
Oops, something went wrong.
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,91 @@ | ||
import { Injectable } from '@angular/core'; | ||
import { HttpClient, HttpHeaders} from "@angular/common/http"; | ||
|
||
import { Observable } from 'rxjs'; | ||
|
||
export interface AuthResponse { | ||
expiration: number; | ||
seleneToken: string; | ||
tartarusToken: string; | ||
} | ||
|
||
export interface SocialLoginData { | ||
uuid: string; | ||
accessToken: string; | ||
refreshToken: string; | ||
expiration: string; | ||
} | ||
|
||
const antisocialAuthUrl = '/api/antisocial'; | ||
const facebookAuthUrl = '/api/social/facebook'; | ||
const githubAuthUrl = '/api/social/github'; | ||
const googleAuthUrl = '/api/social/google'; | ||
const generateTokensUrl = 'api/social/tokens'; | ||
const logoutUrl = '/api/logout'; | ||
|
||
|
||
@Injectable() | ||
export class AppService { | ||
private cookieDomain: string = document.domain.replace('login.', ''); | ||
|
||
constructor(private http: HttpClient) { } | ||
|
||
navigateToRedirectURI(delay: number): void { | ||
let redirectURI = localStorage.getItem('redirect'); | ||
localStorage.removeItem('redirect'); | ||
setTimeout(() => { window.location.assign(redirectURI) }, delay); | ||
} | ||
|
||
authorizeAntisocial (username, password): Observable<AuthResponse> { | ||
let rawCredentials = `${username}:${password}`; | ||
const codedCredentials = btoa(rawCredentials); | ||
const httpHeaders = new HttpHeaders( | ||
{"Authorization": "Basic " + codedCredentials} | ||
); | ||
return this.http.get<AuthResponse>(antisocialAuthUrl, {headers: httpHeaders}) | ||
} | ||
|
||
authenticateWithFacebook() { | ||
window.location.assign(facebookAuthUrl); | ||
} | ||
|
||
authenticateWithGithub() { | ||
window.location.assign(githubAuthUrl); | ||
} | ||
|
||
authenticateWithGoogle() { | ||
window.location.assign(googleAuthUrl); | ||
} | ||
|
||
generateSocialLoginTokens(socialLoginData: any) { | ||
return this.http.post<AuthResponse>( | ||
generateTokensUrl, | ||
socialLoginData | ||
); | ||
} | ||
|
||
generateTokenCookies(authResponse: AuthResponse) { | ||
let expirationDate = new Date(authResponse.expiration * 1000); | ||
document.cookie = 'seleneToken=' + authResponse.seleneToken + | ||
'; expires=' + expirationDate.toUTCString() + | ||
'; domain=' + this.cookieDomain; | ||
document.cookie = 'tartarusToken=' + authResponse.tartarusToken + | ||
'; expires=' + expirationDate.toUTCString() + | ||
'; domain=' + this.cookieDomain; | ||
} | ||
|
||
logout(): Observable<any> { | ||
return this.http.get(logoutUrl); | ||
} | ||
|
||
expireTokenCookies(): void { | ||
let expiration = new Date(); | ||
document.cookie = 'seleneToken=""' + | ||
'; expires=' + expiration.toUTCString() + | ||
'; domain=' + this.cookieDomain; | ||
document.cookie = 'tartarusToken=""' + | ||
'; expires=' + expiration.toUTCString() + | ||
'; domain=' + this.cookieDomain; | ||
|
||
} | ||
} |
75 changes: 0 additions & 75 deletions
75
login/frontend/v1/login-ui/src/app/auth/auth.component.scss
This file was deleted.
Oops, something went wrong.
25 changes: 0 additions & 25 deletions
25
login/frontend/v1/login-ui/src/app/auth/auth.component.spec.ts
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
13 changes: 0 additions & 13 deletions
13
login/frontend/v1/login-ui/src/app/auth/auth.module.spec.ts
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.