load policies on register if org invite (#475)

This commit is contained in:
Kyle Spearrin 2020-03-02 11:51:05 -05:00 committed by GitHub
parent aac011d3b3
commit c9699647d7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 2 deletions

2
jslib

@ -1 +1 @@
Subproject commit e93c534ec4f724eaa8b494f516b187bea67b132c
Subproject commit 4aecc53ddef892d22457cf32b4f8d140c9253688

View File

@ -14,6 +14,10 @@ import { StateService } from 'jslib/abstractions/state.service';
import { RegisterComponent as BaseRegisterComponent } from 'jslib/angular/components/register.component';
import { Policy } from 'jslib/models/domain/policy';
import { PolicyData } from 'jslib/models/data/policyData';
@Component({
selector: 'app-register',
templateUrl: 'register.component.html',
@ -22,6 +26,8 @@ export class RegisterComponent extends BaseRegisterComponent {
showCreateOrgMessage = false;
showTerms = true;
private policies: Policy[];
constructor(authService: AuthService, router: Router,
i18nService: I18nService, cryptoService: CryptoService,
apiService: ApiService, private route: ActivatedRoute,
@ -32,7 +38,7 @@ export class RegisterComponent extends BaseRegisterComponent {
this.showTerms = !platformUtilsService.isSelfHost();
}
ngOnInit() {
async ngOnInit() {
const queryParamsSub = this.route.queryParams.subscribe((qParams) => {
if (qParams.email != null && qParams.email.indexOf('@') > -1) {
this.email = qParams.email;
@ -48,5 +54,16 @@ export class RegisterComponent extends BaseRegisterComponent {
queryParamsSub.unsubscribe();
}
});
const invite = await this.stateService.get<any>('orgInvitation');
if (invite != null) {
try {
const policies = await this.apiService.getPoliciesByToken(invite.organizationId, invite.token,
invite.email, invite.organizationUserId);
if (policies.data != null) {
const policiesData = policies.data.map((p) => new PolicyData(p));
this.policies = policiesData.map((p) => new Policy(p));
}
} catch { }
}
}
}