Login form with Tenant dropdown menu
This commit is contained in:
@@ -5,10 +5,11 @@ import { HttpEvent, HttpInterceptor, HttpHandler, HttpRequest } from '@angular/c
|
||||
/** rxjs Imports */
|
||||
import { Observable } from 'rxjs';
|
||||
|
||||
/** Environment Configuration */
|
||||
/** Custom Imports */
|
||||
import { environment } from '../../../environments/environment';
|
||||
import { SettingsService } from 'app/settings/settings.service';
|
||||
|
||||
/** Http request options headers. */
|
||||
/** Http request (default) options headers. */
|
||||
const httpOptions = {
|
||||
headers: {
|
||||
'Fineract-Platform-TenantId': environment.fineractPlatformTenantId
|
||||
@@ -26,12 +27,15 @@ const twoFactorAccessTokenHeader = 'Fineract-Platform-TFA-Token';
|
||||
@Injectable()
|
||||
export class AuthenticationInterceptor implements HttpInterceptor {
|
||||
|
||||
constructor() {}
|
||||
constructor(private settingsService: SettingsService) {}
|
||||
|
||||
/**
|
||||
* Intercepts a Http request and sets the request headers.
|
||||
*/
|
||||
intercept(request: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
|
||||
if (this.settingsService.tenantIdentifier) {
|
||||
httpOptions.headers['Fineract-Platform-TenantId'] = this.settingsService.tenantIdentifier;
|
||||
}
|
||||
request = request.clone({ setHeaders: httpOptions.headers });
|
||||
return next.handle(request);
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
<img src="assets/images/user_placeholder.png" alt="app-user-photo">
|
||||
</div>
|
||||
<span class="app-user-name mb-05">
|
||||
{{ username }}
|
||||
{{ tenantIdentifier }} / {{ username }}
|
||||
</span>
|
||||
<div #userPanel class="app-user-controls">
|
||||
<button class="xs-button" mat-icon-button matTooltip="{{ 'tooltips.Settings' | translate }}" [routerLink]="['/settings']">
|
||||
|
||||
@@ -14,6 +14,7 @@ import { ConfigurationWizardService } from '../../../configuration-wizard/config
|
||||
|
||||
/** Custom Imports */
|
||||
import { frequentActivities } from './frequent-activities';
|
||||
import { SettingsService } from 'app/settings/settings.service';
|
||||
|
||||
/**
|
||||
* Sidenav component.
|
||||
@@ -51,12 +52,14 @@ export class SidenavComponent implements OnInit, AfterViewInit {
|
||||
* @param {Router} router Router for navigation.
|
||||
* @param {MatDialog} dialog Mat Dialog
|
||||
* @param {AuthenticationService} authenticationService Authentication Service.
|
||||
* @param {SettingsService} settingsService Settings Service.
|
||||
* @param {ConfigurationWizardService} configurationWizardService ConfigurationWizard Service.
|
||||
* @param {PopoverService} popoverService PopoverService.
|
||||
*/
|
||||
constructor(private router: Router,
|
||||
public dialog: MatDialog,
|
||||
private authenticationService: AuthenticationService,
|
||||
private settingsService: SettingsService,
|
||||
private configurationWizardService: ConfigurationWizardService,
|
||||
private popoverService: PopoverService) {
|
||||
this.userActivity = JSON.parse(localStorage.getItem('mifosXLocation'));
|
||||
@@ -207,4 +210,12 @@ export class SidenavComponent implements OnInit, AfterViewInit {
|
||||
this.router.onSameUrlNavigation = 'reload';
|
||||
this.router.navigate(['/home']);
|
||||
}
|
||||
|
||||
get tenantIdentifier(): string {
|
||||
if (!this.settingsService.tenantIdentifier || this.settingsService.tenantIdentifier === '') {
|
||||
return 'default';
|
||||
}
|
||||
return this.settingsService.tenantIdentifier;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user