diff --git a/src/app/core/authentication/authentication.service.ts b/src/app/core/authentication/authentication.service.ts index 1f5cb20b5..505e50f73 100644 --- a/src/app/core/authentication/authentication.service.ts +++ b/src/app/core/authentication/authentication.service.ts @@ -92,16 +92,13 @@ export class AuthenticationService { this.storage = this.rememberMe ? localStorage : sessionStorage; if (environment.oauth.enabled) { - return this.http.disableApiPrefix().post( - `${environment.oauth.serverUrl} - /oauth/token?username=${loginContext.username}&password=${loginContext.password} - &client_id=community-app&grant_type=password&client_secret=123`, {} - ).pipe( - map((tokenResponse: OAuth2Token) => { - this.getUserDetails(tokenResponse); - return of(true); - }) - ); + return this.http.disableApiPrefix().post(`${environment.oauth.serverUrl}/oauth/token?username=${loginContext.username}&password=${loginContext.password}&client_id=community-app&grant_type=password&client_secret=123`, {}) + .pipe( + map((tokenResponse: OAuth2Token) => { + this.getUserDetails(tokenResponse); + return of(true); + }) + ); } else { return this.http.post(`/authentication?username=${loginContext.username}&password=${loginContext.password}`, {}) .pipe( @@ -131,11 +128,8 @@ export class AuthenticationService { refreshOAuthAccessToken() { const oAuthRefreshToken = JSON.parse(this.storage.getItem(oAuthTokenDetailsStorageKey)).refresh_token; this.authenticationInterceptor.removeAuthorization(); - this.http.disableApiPrefix().post( - `${environment.oauth.serverUrl} - /oauth/token?client_id=community-app&grant_type=refresh_token&client_secret=123 - &refresh_token=${oAuthRefreshToken}`, {} - ).subscribe((tokenResponse: OAuth2Token) => { + this.http.disableApiPrefix().post(`${environment.oauth.serverUrl}/oauth/token?client_id=community-app&grant_type=refresh_token&client_secret=123&refresh_token=${oAuthRefreshToken}`, {}) + .subscribe((tokenResponse: OAuth2Token) => { this.storage.setItem(oAuthTokenDetailsStorageKey, JSON.stringify(tokenResponse)); this.authenticationInterceptor.setAuthorizationToken(tokenResponse.access_token); this.refreshTokenOnExpiry(tokenResponse.expires_in); diff --git a/src/app/self-service/user.service.ts b/src/app/self-service/user.service.ts index d9d1bb5d1..ac421f2d5 100644 --- a/src/app/self-service/user.service.ts +++ b/src/app/self-service/user.service.ts @@ -1,21 +1,8 @@ import { Injectable } from '@angular/core'; -import { HttpHeaders, HttpClient } from '@angular/common/http'; +import { HttpClient } from '@angular/common/http'; import { Observable } from 'rxjs/internal/Observable'; import { map } from 'rxjs/internal/operators/map'; -const username = 'mifos'; -const password = 'password'; -const token = btoa(`${username}:${password}`); - -const httpOptions = { - headers: new HttpHeaders({ - 'Content-Type': 'application/json', - 'Authorization': `Basic ${token}`, - 'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE, OPTIONS', - 'Access-Control-Allow-Origin': '*' - }) -}; - @Injectable({ providedIn: 'root' }) @@ -24,20 +11,18 @@ export class UserService { constructor(private http: HttpClient) { } getUsers(): Observable { - return this.http.get( - `https://demo.openmf.org/fineract-provider/api/v1/users? - fields=id,firstname,lastname,email,officeName,staff&tenantIdentifier=default&pretty=true`, - httpOptions).pipe( - map((res) => { - res.forEach((user: any) => { - user.name = `${user.firstname} ${user.lastname}`; - user.staff = user.staff ? `${user.staff.firstname} ${user.staff.lastname}` : ''; - delete user.firstname; - delete user.lastname; - }); - return res; - }) - ); + return this.http.get(`/users?fields=id,firstname,lastname,email,officeName,staff&tenantIdentifier=default&pretty=true`) + .pipe( + map((res) => { + res.forEach((user: any) => { + user.name = `${user.firstname} ${user.lastname}`; + user.staff = user.staff ? `${user.staff.firstname} ${user.staff.lastname}` : ''; + delete user.firstname; + delete user.lastname; + }); + return res; + }) + ); } } diff --git a/tslint.json b/tslint.json index 428eb17ac..143ecec79 100644 --- a/tslint.json +++ b/tslint.json @@ -30,7 +30,7 @@ "label-position": true, "max-line-length": [ true, - 135 + 250 ], "member-access": false, "member-ordering": [