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
fix: TTA-180 fixing tests
  • Loading branch information
Rodrigo Lins committed Oct 13, 2022
commit 6c09fce641ff096ab253bc8c59f67fc211bdd160
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()}}">Login</a></button>
<a href="{{loginAuth()}}"><button class="btn btn-primary">Login</button></a>
</div>
</div>
3 changes: 2 additions & 1 deletion src/app/modules/login/login.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export class LoginComponent implements OnInit {
isProduction = environment.production === EnvironmentType.TT_PROD_LEGACY;
cliendId = CLIENT_URL;
authUrl = environment.authUrl;
authAppName = environment.authAppName;
auth2: any;


Expand Down Expand Up @@ -67,7 +68,7 @@ export class LoginComponent implements OnInit {
}

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

}
10 changes: 8 additions & 2 deletions src/app/modules/login/services/login.service.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { HttpClient } from '@angular/common/http';
import { HttpClientTestingModule } from '@angular/common/http/testing';
import { RouterTestingModule } from '@angular/router/testing';
import { TestBed } from '@angular/core/testing';
import { Router } from '@angular/router';
import { JwtHelperService } from '@auth0/angular-jwt';
import { SocialAuthService } from 'angularx-social-login';
import { CookieService } from 'ngx-cookie-service';
Expand All @@ -12,6 +14,7 @@ describe('LoginService', () => {
let service: LoginService;
let cookieService: CookieService;
let socialAuthService: SocialAuthService;
let router: Router;
let account;
const socialAuthServiceStub = jasmine.createSpyObj('SocialAuthService', ['signOut', 'signIn']);
const httpClientSpy = jasmine.createSpyObj('HttpClient', ['post', 'get']);
Expand All @@ -23,16 +26,17 @@ describe('LoginService', () => {

beforeEach(() => {
TestBed.configureTestingModule({
imports: [HttpClientTestingModule],
imports: [HttpClientTestingModule, RouterTestingModule.withRoutes([])],
providers: [
{ providers: CookieService, useValue: cookieStoreStub },
{ provide: SocialAuthService, useValue: socialAuthServiceStub },
{ provide: HttpClient, useValue: httpClientSpy }
{ provide: HttpClient, useValue: httpClientSpy },
],
});
service = TestBed.inject(LoginService);
cookieService = TestBed.inject(CookieService);
socialAuthService = TestBed.inject(SocialAuthService);
router = TestBed.inject(Router);
account = 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpZCI6ImFiYyIsIm5hbWUiOiJhYmMiLCJlbWFpbCI6ImFiYyIsImdyb3VwcyI6WyJhYmMiXX0.UNxyDT8XzXJhI1F3LySBU7TJlpENPUPHj8my7Obw2ZM';
let store = {};
const mockLocalStorage = {
Expand Down Expand Up @@ -121,7 +125,9 @@ describe('LoginService', () => {
});

it('should logout with social angularx-social-login', () => {
service.router = router;
spyOn(cookieService, 'deleteAll').and.returnValue();
spyOn(service, 'invalidateSessionCookie').and.returnValue(of(true));

service.logout();

Expand Down
14 changes: 10 additions & 4 deletions src/app/modules/login/services/login.service.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { HttpClient } from '@angular/common/http';
import { Injectable, NgZone } from '@angular/core';
import { Injectable } 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 { Observable, of } from 'rxjs';
import { of } from 'rxjs';
import { Router } from '@angular/router';

@Injectable({
Expand All @@ -17,7 +17,6 @@ export class LoginService {
isLegacyProd: boolean = environment.production === EnvironmentType.TT_PROD_LEGACY;
localStorageKey = this.isLegacyProd ? 'user2' : 'user';
router: Router;
ngZone: NgZone;

constructor(
private http?: HttpClient,
Expand All @@ -29,7 +28,14 @@ export class LoginService {

logout() {
localStorage.clear();
this.http.post(`${this.baseUrl}/logout`, null, { withCredentials: true }).subscribe();
this.cookieService.deleteAll();
this.invalidateSessionCookie().subscribe(() => {
this.router.navigate(['login']);
});
}

invalidateSessionCookie() {
return this.http.post(`${this.baseUrl}/logout`, null, { withCredentials: true });
}

isLogin() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
<h3 class="font-poppins text-base ml-4 pl-3 -mt-6 text-left" >{{ item.text }}</h3>
</a>
<div class="bg-whiteTW pt-2 absolute bottom-4 dark:bg-grayTW-dark flex justify-center items-center">
<a class="flex pl-4 text-blackTW hover:text-grayTW dark:text-whiteTW" href="#">
<button class="logout flex pl-4 text-blackTW hover:text-grayTW dark:text-whiteTW" (click)="logout()">
<em class="fas fa-sign-out-alt"></em>
<span class="font-poppins pl-3 font-medium dark:text-whiteTW" (click)="logout()">Sign out</span>
</a>
<span class="font-poppins pl-3 font-medium dark:text-whiteTW">Sign out</span>
</button>
<app-dark-mode class="ml-4"></app-dark-mode>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ body {
overflow-x: hidden;
}

button.logout:active {
outline: none;
}

#sidebar-wrapper {
min-height: 100vh;
margin-left: -15rem;
Expand Down Expand Up @@ -76,4 +80,4 @@ body {
height: -webkit-calc(100vh - 1vh);
height: -o-calc(100vh - 1vh);
height: calc(100vh - 1vh);
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Component, OnDestroy, OnInit } from '@angular/core';
import { ItemSidebar } from './models/item-sidebar.model';
import { NavigationStart, Router } from '@angular/router';
import { Observable, Subscription } from 'rxjs';
import { Observable, Subscription, timer } from 'rxjs';
import { filter, map } from 'rxjs/operators';
import { UserInfoService } from 'src/app/modules/user/services/user-info.service';
import { AzureAdB2CService } from '../../../login/services/azure.ad.b2c.service';
Expand Down Expand Up @@ -42,6 +42,7 @@ export class SidebarComponent implements OnInit, OnDestroy {

ngOnDestroy(): void {
this.sidebarItems$.unsubscribe();
this.logout();
}

toggleSideBar() {
Expand Down
2 changes: 2 additions & 0 deletions src/environments/environment.prod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ export const environment = {
production: EnvironmentType.TT_PROD,
timeTrackerApiUrl: process.env["API_URL"],
stackexchangeApiUrl: 'https://api.stackexchange.com',
authUrl: 'https://api.auth.ioet.com',
authAppName: 'timeTracker',
};

export const AUTHORITY = process.env["AUTHORITY"];
Expand Down
1 change: 1 addition & 0 deletions src/environments/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export const environment = {
timeTrackerApiUrl: process.env['API_URL'],
stackexchangeApiUrl: 'https://api.stackexchange.com',
authUrl: 'https://uat-backend.auth.ioet.com',
authAppName: 'timeTracker',
};

export const AUTHORITY = process.env['AUTHORITY'];
Expand Down