-
- Dario Herrera
+
+
+ {{name}}
-
diff --git a/src/app/modules/shared/components/user/user.component.spec.ts b/src/app/modules/shared/components/user/user.component.spec.ts
index bf5e41717..9b44146e0 100644
--- a/src/app/modules/shared/components/user/user.component.spec.ts
+++ b/src/app/modules/shared/components/user/user.component.spec.ts
@@ -1,14 +1,28 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
-
+import { of } from 'rxjs';
import { UserComponent } from './user.component';
+import { AzureAdB2CService } from '../../../login/services/azure.ad.b2c.service';
describe('UserComponent', () => {
let component: UserComponent;
let fixture: ComponentFixture
;
+ let azureAdB2CService: AzureAdB2CService;
+
+ const azureAdB2CServiceStub = {
+ isLogin() {
+ return true;
+ },
+ signIn() {
+ return of();
+ }
+ };
beforeEach(async(() => {
TestBed.configureTestingModule({
- declarations: [ UserComponent ]
+ declarations: [ UserComponent ],
+ providers: [
+ { providers: AzureAdB2CService, useValue: azureAdB2CServiceStub}
+ ]
})
.compileComponents();
}));
@@ -17,9 +31,19 @@ describe('UserComponent', () => {
fixture = TestBed.createComponent(UserComponent);
component = fixture.componentInstance;
fixture.detectChanges();
+ azureAdB2CService = TestBed.inject(AzureAdB2CService);
});
- it('should be created', () => {
+ it('should be created user component ', () => {
expect(component).toBeTruthy();
});
+
+ it('should check onInit', () => {
+ spyOn(azureAdB2CService, 'isLogin').and.returnValue(true);
+ spyOn(azureAdB2CService, 'getName').and.returnValue('Name');
+ component.ngOnInit();
+ expect(azureAdB2CService.isLogin).toHaveBeenCalled;
+ expect(azureAdB2CService.getName).toHaveBeenCalled;
+ });
+
});
diff --git a/src/app/modules/shared/components/user/user.component.ts b/src/app/modules/shared/components/user/user.component.ts
index 5df0c83d0..dfab1c71d 100644
--- a/src/app/modules/shared/components/user/user.component.ts
+++ b/src/app/modules/shared/components/user/user.component.ts
@@ -1,4 +1,5 @@
import { Component, OnInit } from '@angular/core';
+import { AzureAdB2CService } from '../../../login/services/azure.ad.b2c.service';
@Component({
selector: 'app-user',
@@ -7,9 +8,17 @@ import { Component, OnInit } from '@angular/core';
})
export class UserComponent implements OnInit {
- constructor() { }
+ name: string = ''
+ constructor(private azureAdB2CService: AzureAdB2CService) { }
ngOnInit(): void {
+ if(this.azureAdB2CService.isLogin()) {
+ this.name = this.azureAdB2CService.getName()
+ }
+ }
+
+ logout() {
+ this.azureAdB2CService.logout()
}
}
diff --git a/src/environments/environment.prod.ts b/src/environments/environment.prod.ts
index 3612073bc..84b2f5826 100644
--- a/src/environments/environment.prod.ts
+++ b/src/environments/environment.prod.ts
@@ -1,3 +1,9 @@
+import * as keys from './.keys.json';
+
export const environment = {
production: true
};
+
+export const AUTHORITY = keys.authority;
+export const CLIENT_ID = keys.client_id;
+export const SCOPES = keys.scopes;
\ No newline at end of file
diff --git a/src/environments/environment.ts b/src/environments/environment.ts
index 7b4f817ad..21d08f023 100644
--- a/src/environments/environment.ts
+++ b/src/environments/environment.ts
@@ -1,11 +1,16 @@
// This file can be replaced during build by using the `fileReplacements` array.
// `ng build --prod` replaces `environment.ts` with `environment.prod.ts`.
// The list of file replacements can be found in `angular.json`.
+import * as keys from './.keys.json';
export const environment = {
production: false
};
+export const AUTHORITY = keys.authority;
+export const CLIENT_ID = keys.client_id;
+export const SCOPES = keys.scopes;
+
/*
* For easier debugging in development mode, you can import the following file
* to ignore zone related error stack frames such as `zone.run`, `zoneDelegate.invokeTask`.
diff --git a/src/environments/keys.example.json b/src/environments/keys.example.json
new file mode 100644
index 000000000..c65a76e7f
--- /dev/null
+++ b/src/environments/keys.example.json
@@ -0,0 +1,6 @@
+{
+ "authority": "XXXXX",
+ "client_id": "XXXXX",
+ "scopes": ["XXXXX"]
+ }
+
\ No newline at end of file
diff --git a/tsconfig.json b/tsconfig.json
index 30956ae7e..582f5574d 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -21,6 +21,7 @@
},
"angularCompilerOptions": {
"fullTemplateTypeCheck": true,
- "strictInjectionParameters": true
+ "strictInjectionParameters": true,
+ "resolveJsonModule": true
}
}