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
TTA-180: fixing endpoints to send credentials
  • Loading branch information
reihtw committed Oct 6, 2022
commit 3c9764b3fd48a05f4108fa004baed11710aae22a
16 changes: 16 additions & 0 deletions proxy.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
const PROXY_CONFIG = [
{
context: [
'/api',
],
target: 'http://127.0.0.1:7071',
changeOrigin: true,
withCredentials: true,
secure: false,
headers: {
'Connection': 'keep-alive'
}
}
]

module.exports = PROXY_CONFIG;
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export class ActivityService {
constructor(private http: HttpClient) {}

getActivities(): Observable<Activity[]> {
return this.http.get<Activity[]>(this.baseUrl);
return this.http.get<Activity[]>(this.baseUrl, { withCredentials: true });
}

createActivity(activityData): Observable<any> {
Expand All @@ -23,12 +23,12 @@ export class ActivityService {
tenant_id: '4225ab1e-1033-4a5f-8650-0dd4950f38c8',
};

return this.http.post(this.baseUrl, body);
return this.http.post(this.baseUrl, body, { withCredentials: true });
}

deleteActivity(acitivityId: string): Observable<any> {
const url = `${this.baseUrl}/${acitivityId}`;
return this.http.delete(url);
return this.http.delete(url, { withCredentials: true });
}

updateActivity(activityData): Observable<any> {
Expand All @@ -38,6 +38,6 @@ export class ActivityService {
...activityData,
};

return this.http.put(url, body);
return this.http.put(url, body, { withCredentials: true });
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,20 @@ export class ProjectTypeService {

getProjectTypes(customerId: any): Observable<ProjectType[]> {
const params = new HttpParams().set('customer_id', customerId.customerId);
return this.http.get<ProjectType[]>(this.baseUrl, { params });
return this.http.get<ProjectType[]>(this.baseUrl, { params, withCredentials: true });
}

createProjectType(projectTypeData): Observable<any> {
return this.http.post(this.baseUrl, projectTypeData);
return this.http.post(this.baseUrl, projectTypeData, { withCredentials: true });
}

deleteProjectType(projectTypeId: string): Observable<any> {
const url = `${this.baseUrl}/${projectTypeId}`;
return this.http.delete(url);
return this.http.delete(url, { withCredentials: true });
}

updateProjectType(projectTypeData): Observable<any> {
const url = `${this.baseUrl}/${projectTypeData.id}`;
return this.http.put(url, projectTypeData);
return this.http.put(url, projectTypeData, { withCredentials: true });
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,19 @@ export class ProjectService {

getProjects(customerId: any): Observable<Project[]> {
const params = new HttpParams().set('customer_id', customerId.customerId);
return this.http.get<Project[]>(this.url, { params });
return this.http.get<Project[]>(this.url, { params, withCredentials: true });
}

getAllProjects(): Observable<Project[]> {
return this.http.get<Project[]>(this.url);
return this.http.get<Project[]>(this.url, { withCredentials: true });
}

getRecentProjects(): Observable<Project[]> {
return this.http.get<Project[]>(`${this.url}/recent`);
return this.http.get<Project[]>(`${this.url}/recent`, { withCredentials: true });
}

createProject(projectData): Observable<any> {
return this.http.post<Project[]>(this.url, projectData);
return this.http.post<Project[]>(this.url, projectData, { withCredentials: true });
}

updateProject(projectData): Observable<any> {
Expand All @@ -39,12 +39,12 @@ export class ProjectService {
projectData.status = 1;
}
}
return this.http.put(`${this.url}/${id}`, projectData);
return this.http.put(`${this.url}/${id}`, projectData, { withCredentials: true });
}

deleteProject(projectId: string): Observable<any> {
return this.isDevelopmentOrProd
? this.http.put(`${this.url}/${projectId}`, { status: 0 })
: this.http.delete(`${this.url}/${projectId}`);
: this.http.delete(`${this.url}/${projectId}`, { withCredentials: true });
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,20 @@ export class CustomerService {
constructor(private http: HttpClient) {}

createCustomer(customerData): Observable<any> {
return this.http.post(this.baseUrl, customerData);
return this.http.post(this.baseUrl, customerData, { withCredentials: true });
}

getCustomers(): Observable<any> {
return this.http.get(this.baseUrl);
return this.http.get(this.baseUrl, { withCredentials: true });
}

deleteCustomer(customerId: string): Observable<any> {
const url = `${this.baseUrl}/${customerId}`;
return this.http.delete(url);
return this.http.delete(url, { withCredentials: true });
}

updateCustomer(customerData): Observable<any> {
const url = `${this.baseUrl}/${customerData.id}`;
return this.http.put(url, customerData);
return this.http.put(url, customerData, { withCredentials: true });
}
}
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">
<a ng-href="{cliendId}}">Login</a>
<a href="https://uat-backend.auth.ioet.com/authn/login/timeTracker">Login</a>
</div>
</div>
10 changes: 9 additions & 1 deletion src/app/modules/login/login.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,14 @@ export class LoginComponent implements OnInit {
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 @@ -107,7 +115,7 @@ export class LoginComponent implements OnInit {
}

loginAuth(): void {

}

}
6 changes: 3 additions & 3 deletions src/app/modules/login/services/login.service.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { HttpClient } from '@angular/common/http';
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { CookieService } from 'ngx-cookie-service';
import { EnvironmentType, UserEnum } from 'src/environments/enum';
Expand Down Expand Up @@ -92,7 +92,7 @@ export class LoginService {
token: tokenString,
};

return this.http.post(`${this.baseUrl}/login`, body);
return this.http.post(`${this.baseUrl}/login`, body, { withCredentials: true });
}

setCookies() {
Expand All @@ -109,7 +109,7 @@ export class LoginService {

isValidToken(token: string) {
const body = { token };
return this.http.post(`${this.baseUrl}/validate-token`, body).pipe(
return this.http.post(`${this.baseUrl}/validate-token`, body, { withCredentials: true }).pipe(
map((response) => {
const responseString = JSON.stringify(response);
const responseJson = JSON.parse(responseString);
Expand Down
21 changes: 11 additions & 10 deletions src/app/modules/time-clock/services/entry.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,49 +23,49 @@ export class EntryService {
urlInProductionLegacy = environment.production === EnvironmentType.TT_PROD_LEGACY;

loadActiveEntry(): Observable<any> {
return this.http.get(`${this.baseUrl}/running`);
return this.http.get(`${this.baseUrl}/running`, { withCredentials: true });
}

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

createEntry(entryData): Observable<any> {
return this.http.post(this.baseUrl, entryData);
return this.http.post(this.baseUrl, entryData, { withCredentials: true });
}

updateEntry(entryData): Observable<any> {
const {id} = entryData;
return this.http.put(`${this.baseUrl}/${id}`, entryData);
return this.http.put(`${this.baseUrl}/${id}`, entryData, { withCredentials: true });
}

deleteEntry(entryId: string): Observable<any> {
const url = `${this.baseUrl}/${entryId}`;
return this.http.delete(url);
return this.http.delete(url, { withCredentials: true });
}

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

restartEntry(idEntry: string): Observable<Entry> {
const url = `${this.baseUrl}/${idEntry}/restart`;
return this.http.post<Entry>(url, null);
return this.http.post<Entry>(url, null, { withCredentials: true });
}

summary(): Observable<TimeEntriesSummary> {
const timeOffset = new Date().getTimezoneOffset();
const summaryUrl = `${this.baseUrl}/summary?time_offset=${timeOffset}`;
return this.http.get<TimeEntriesSummary>(summaryUrl);
return this.http.get<TimeEntriesSummary>(summaryUrl, { withCredentials: true });
}

findEntriesByProjectId(projectId: string): Observable<Entry[]> {
const startDate = this.getDateLastMonth();
const endDate = this.getCurrentDate();
const findEntriesByProjectURL = `${this.baseUrl}?limit=2&project_id=${projectId}&start_date=${startDate}&end_date=${endDate}`;
return this.http.get<Entry[]>(findEntriesByProjectURL);
return this.http.get<Entry[]>(findEntriesByProjectURL, { withCredentials: true });
}

loadEntriesByTimeRange(range: TimeEntriesTimeRange, userId: string): Observable<any> {
Expand All @@ -79,7 +79,8 @@ export class EntryService {
user_id: userId,
limit: `${MAX_NUMBER_OF_ENTRIES_FOR_REPORTS}`,
timezone_offset : new Date().getTimezoneOffset().toString(),
}
},
withCredentials: true
}
);
}
Expand Down
2 changes: 1 addition & 1 deletion src/app/modules/user/services/user.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ export class UserService {

loadUser(userId: any): Observable<User> {
const url = `${this.baseUrl}/${userId}`;
return this.http.get<User>(url);
return this.http.get<User>(url, { withCredentials: true });
}
}
10 changes: 5 additions & 5 deletions src/app/modules/users/services/users.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,30 +15,30 @@ export class UsersService {
baseUrl = `${environment.timeTrackerApiUrl}/users`;

loadUsers(): Observable<any> {
return this.http.get(this.baseUrl);
return this.http.get(this.baseUrl, { withCredentials: true });
}

grantRole(userId: string, roleId: string): Observable<any> {
const url = this.isProductionLegacy ? `${this.baseUrl}/${userId}/roles/${roleId}/grant`
: `${this.baseUrl}/${userId}/${roleId}/grant`;
return this.http.post(url, null);
return this.http.post(url, null, { withCredentials: true });
}

revokeRole(userId: string, roleId: string): Observable<any> {
const url = this.isProductionLegacy ? `${this.baseUrl}/${userId}/roles/${roleId}/revoke`
: `${this.baseUrl}/${userId}/${roleId}/revoke`;
return this.http.post(url, null);
return this.http.post(url, null, { withCredentials: true });
}

addUserToGroup(userId: string, group: string): Observable<User> {
return this.http.post<User>(`${this.baseUrl}/${userId}/groups/add`, {
group_name: group,
});
}, { withCredentials: true });
}

removeUserFromGroup(userId: string, group: string): Observable<User> {
return this.http.post<User>(`${this.baseUrl}/${userId}/groups/remove`, {
group_name: group,
});
}, { withCredentials: true });
}
}
2 changes: 1 addition & 1 deletion src/environments/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { EnvironmentType } from './enum';
/* tslint:disable:no-string-literal */
export const environment = {
production: EnvironmentType.TT_DEV,
timeTrackerApiUrl: process.env['API_URL'],
timeTrackerApiUrl: 'http://timetracker-dev.ioet.com:7071/api',
stackexchangeApiUrl: 'https://api.stackexchange.com',
};

Expand Down