Skip to content
Merged
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
2a85d69
refactor: TTA-180 change Client URL for Auth URL
Oct 5, 2022
3c9764b
TTA-180: fixing endpoints to send credentials
reihtw Oct 6, 2022
2e694fb
refactor: TTA-115 refactor backend URL for dev
Oct 6, 2022
a78dbf4
refactor: TTA-115 pass the environment auth variable link to the a tag
Oct 7, 2022
12c9efd
fix: TTA-115 fix error Type 'string' is not assignable to type 'void …
Oct 7, 2022
0d6d4ab
feat: TTA-180 creating logout
reihtw Oct 11, 2022
6c09fce
fix: TTA-180 fixing tests
Oct 13, 2022
7e680fb
fix: TTA-180 fixing environment variables
Oct 14, 2022
7e358e2
fix: TTA-180 fixing environment variables
Oct 14, 2022
7c5b242
fix: TTA-180 fixing environment variables
Oct 14, 2022
1dc6a4a
fix: TTA-180 fixing environment variables
Oct 14, 2022
fa24348
fix: TTA-180 fixing environment variables
Oct 14, 2022
88c5313
fix: TTA-180 fixing environment variables
Oct 14, 2022
97cffc0
feat: TTA-180 updating README.md
Oct 14, 2022
ed0056b
fix: TTA-180 removing unused variables
Oct 19, 2022
17e5932
fix: TTA-180 increasing test coveragew
Oct 19, 2022
342aa8a
fix: TTA-180 increasing test coveragew
Oct 19, 2022
8f50329
fix: TTA-180 CR fixes
Oct 20, 2022
033eb86
config: TTA-180 added secrets for stage and prod
andresacg30 Oct 24, 2022
8d1bd76
fix: TTA-181 change husky hint when commit message is wrong (#937)
mmaquina Oct 5, 2022
c37c815
chore(release): 1.75.21 [skip ci]nn
semantic-release-bot Oct 5, 2022
faff696
fix: TTA 183 get summary returns 404 at begginning of the month (#938)
nicolsss Oct 6, 2022
26722ef
chore(release): 1.75.22 [skip ci]nn
semantic-release-bot Oct 6, 2022
ef0e2be
Update README.md
mmaquina Oct 7, 2022
d702df0
Update README.md
mmaquina Oct 7, 2022
21c261b
fix: Tta 193 add loading page to new ip check load time (#939)
andresacg30 Oct 17, 2022
b3d2e44
chore(release): 1.75.24 [skip ci]nn
semantic-release-bot Oct 21, 2022
cbef44b
adding Andres Cabrera ppk to STAGE secrets
rodolfoIOET Oct 21, 2022
26e53ab
adding Andres Cabrera ppk to PROD secrets
rodolfoIOET Oct 21, 2022
11a8950
Added secrets for auth app on stage and prod
andresacg30 Oct 24, 2022
ddd131b
Revert "Tta 180 integrate time tracker with auth app (#940)" (#942)
andresacg30 Oct 24, 2022
14c2fde
revert adding stage and prod envs
andresacg30 Oct 24, 2022
1fc5b78
config: TTA-180 added secrets for stage and prod
andresacg30 Oct 24, 2022
7193ce1
Tta 180 integrate time tracker with auth app (#940)
Oct 21, 2022
5cf09eb
Added secrets for auth app on stage and prod
andresacg30 Oct 24, 2022
337e2e1
update env variables
andresacg30 Oct 24, 2022
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
feat: TTA-180 creating logout
  • Loading branch information
reihtw committed Oct 11, 2022
commit 0d6d4abdbacf4498cbad113353b2b018fd5b7a25
Binary file modified .dev.env
Binary file not shown.
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ services:
API_URL: ${API_URL}
CLIENT_ID: ${CLIENT_ID}
CLIENT_URL: ${CLIENT_URL}
AUTH_URL: ${AUTH_URL}
SCOPES: ${SCOPES}
STACK_EXCHANGE_ID: ${STACK_EXCHANGE_ID}
STACK_EXCHANGE_ACCESS_TOKEN: ${STACK_EXCHANGE_ACCESS_TOKEN}
Expand Down
16 changes: 0 additions & 16 deletions proxy.conf.js

This file was deleted.

2 changes: 1 addition & 1 deletion src/app/modules/login/login.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ <h3>Please log in</h3>
<button (click)="login() " class="btn btn-primary">login</button>
</div>
<div *ngIf="!isProduction">
<button class="btn btn-primary"><a href="{{loginAuth()}}"></a></button>
<button class="btn btn-primary"><a href="{{loginAuth()}}">Login</a></button>
</div>
</div>
69 changes: 10 additions & 59 deletions src/app/modules/login/login.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { AzureAdB2CService } from './services/azure.ad.b2c.service';
import { Router } from '@angular/router';
import { FeatureToggleCookiesService } from '../shared/feature-toggles/feature-toggle-cookies/feature-toggle-cookies.service';

import { environment, CLIENT_URL, AUTH_URL } from 'src/environments/environment';
import { environment, CLIENT_URL } from 'src/environments/environment';
import { EnvironmentType } from 'src/environments/enum';
import { LoginService } from './services/login.service';
import { UserService } from '../user/services/user.service';
Expand All @@ -22,7 +22,7 @@ declare global {
export class LoginComponent implements OnInit {
isProduction = environment.production === EnvironmentType.TT_PROD_LEGACY;
cliendId = CLIENT_URL;
authUrl = AUTH_URL;
authUrl = environment.authUrl;
auth2: any;


Expand All @@ -35,65 +35,16 @@ export class LoginComponent implements OnInit {
private ngZone?: NgZone
) {}


googleAuthSDK() {
const sdkLoaded = 'googleSDKLoaded';
const gapi = 'gapi';

(window as any)[sdkLoaded] = () => {
(window as any)[gapi].load('auth2', () => {
this.auth2 = ( window as any)[gapi].auth2.init({
client_id: this.cliendId,
plugin_name: 'login',
cookiepolicy: 'single_host_origin',
scope: 'profile email'
});
});
};

(async (d, s, id) => {
const keyGoogle = 'src';
const gjs = d.getElementsByTagName(s)[1];
let js = gjs;
if (d.getElementById(id)) { return; }
js = d.createElement(s); js.id = id;
js[keyGoogle] = 'https://accounts.google.com/gsi/client';
gjs.parentNode.insertBefore(js, gjs);
})(document, 'script', 'async defer');
}

ngOnInit() {

this.googleAuthSDK();
if (this.isProduction && this.azureAdB2CService.isLogin()) {
this.router.navigate(['']);
} else {
this.loginService.isLogin().subscribe(isLogin => {
if (isLogin) {
this.router.navigate(['']);
}
if (!this.isProduction) {
this.loginService.getUser(null).subscribe((resp) => {
this.loginService.setCookies();
const tokenObject = JSON.stringify(resp);
const tokenJson = JSON.parse(tokenObject);
this.loginService.setLocalStorage('user', tokenJson.token);
this.ngZone.run(() => this.router.navigate(['']));
});
}
window.handleCredentialResponse = (response) => {
const {credential = ''} = response;
this.featureToggleCookiesService.setCookies();
this.loginService.setLocalStorage('idToken', credential);
this.loginService.getUser(credential).subscribe((resp) => {
this.loginService.setCookies();
const tokenObject = JSON.stringify(resp);
const tokenJson = JSON.parse(tokenObject);
this.loginService.setLocalStorage('user', tokenJson.token);
this.ngZone.run(() => this.router.navigate(['']));
});
};
this.loginService.getUser('test').subscribe((resp) => {
this.loginService.setCookies();
const tokenObject = JSON.stringify(resp);
console.log(tokenObject)
const tokenJson = JSON.parse(tokenObject);
this.loginService.setLocalStorage('user', tokenJson.token);
this.ngZone.run(() => this.router.navigate(['']));
});
}

login(): void {
Expand All @@ -116,7 +67,7 @@ export class LoginComponent implements OnInit {
}

loginAuth(): string {
return this.authUrl;
return `${this.authUrl}/authn/login/timeTracker`;
}

}
12 changes: 7 additions & 5 deletions src/app/modules/login/services/login.service.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { Injectable, NgZone } from '@angular/core';
import { CookieService } from 'ngx-cookie-service';
import { EnvironmentType, UserEnum } from 'src/environments/enum';
import { environment } from 'src/environments/environment';
import { JwtHelperService } from '@auth0/angular-jwt';
import { map } from 'rxjs/operators';
import { of } from 'rxjs';
import { Observable, of } from 'rxjs';
import { Router } from '@angular/router';

@Injectable({
providedIn: 'root'
Expand All @@ -15,6 +16,8 @@ export class LoginService {
helper: JwtHelperService;
isLegacyProd: boolean = environment.production === EnvironmentType.TT_PROD_LEGACY;
localStorageKey = this.isLegacyProd ? 'user2' : 'user';
router: Router;
ngZone: NgZone;

constructor(
private http?: HttpClient,
Expand All @@ -25,8 +28,8 @@ export class LoginService {
}

logout() {
this.cookieService.deleteAll();
localStorage.clear();
this.http.post(`${this.baseUrl}/logout`, null, { withCredentials: true }).subscribe();
}

isLogin() {
Expand Down Expand Up @@ -120,5 +123,4 @@ export class LoginService {
})
);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ <h3 class="font-poppins text-base ml-4 pl-3 -mt-6 text-left" >{{ item.text }}</h
<div id="page-content-wrapper">
<div class="container-fluid px-0 full-height">
<div class="content_app h-100">
<div class="m-1 p-5 rounded-md bg-whiteTW dark:bg-grayTW-dark">
<div class="m-1 p-5 rounded-md bg-whiteTW dark:bg-grayTW-dark">
<router-outlet></router-outlet>
</div>
</div>
</div>
</div>
</div>
</div>
8 changes: 6 additions & 2 deletions src/app/modules/time-clock/services/entry.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ export class EntryService {

loadEntries(date): Observable<any> {
const timezoneOffset = new Date().getTimezoneOffset();
return this.http.get(`${this.baseUrl}?month=${date.month}&year=${date.year}&timezone_offset=${timezoneOffset}`, { withCredentials: true });
return this.http.get(
`${this.baseUrl}?month=${date.month}&year=${date.year}&timezone_offset=${timezoneOffset}`,
{ withCredentials: true }
);
}

createEntry(entryData): Observable<any> {
Expand All @@ -47,7 +50,8 @@ export class EntryService {

stopEntryRunning(idEntry: string): Observable<any> {
return (this.urlInProductionLegacy ?
this.http.post(`${this.baseUrl}/${idEntry}/stop`, null, { withCredentials: true }) : this.http.put(`${this.baseUrl}/stop`, null, { withCredentials: true }) );
this.http.post(`${this.baseUrl}/${idEntry}/stop`, null, { withCredentials: true }) :
this.http.put(`${this.baseUrl}/stop`, null, { withCredentials: true }) );
}

restartEntry(idEntry: string): Observable<Entry> {
Expand Down
5 changes: 3 additions & 2 deletions src/environments/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@ import { EnvironmentType } from './enum';
/* tslint:disable:no-string-literal */
export const environment = {
production: EnvironmentType.TT_DEV,
timeTrackerApiUrl: process.env["API_URL"],
timeTrackerApiUrl: process.env['API_URL'],
stackexchangeApiUrl: 'https://api.stackexchange.com',
authUrl: 'https://uat-backend.auth.ioet.com',
};

export const AUTHORITY = process.env['AUTHORITY'];
export const CLIENT_ID = process.env['CLIENT_ID'];
export const CLIENT_URL = process.env['CLIENT_URL'];
export let AUTH_URL = process.env['AUTH_URL'];
export const AUTH_URL = process.env['AUTH_URL'];
export const SCOPES = process.env['SCOPES'].split(',');
export const STACK_EXCHANGE_ID = process.env['STACK_EXCHANGE_ID'];
export const STACK_EXCHANGE_ACCESS_TOKEN = process.env['STACK_EXCHANGE_ACCESS_TOKEN'];
Expand Down
4 changes: 4 additions & 0 deletions src/polyfills.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,7 @@ import 'zone.js/dist/zone'; // Included with Angular CLI.
/***************************************************************************************************
* APPLICATION IMPORTS
*/

(window as any).process = {
env: { DEBUG: undefined },
};