1
0
mirror of https://github.com/bitwarden/web synced 2025-12-17 16:53:14 +00:00

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
2 changed files with 19 additions and 2 deletions

2
jslib

Submodule jslib updated: e93c534ec4...4aecc53dde

View File

@@ -14,6 +14,10 @@ import { StateService } from 'jslib/abstractions/state.service';
import { RegisterComponent as BaseRegisterComponent } from 'jslib/angular/components/register.component'; 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({ @Component({
selector: 'app-register', selector: 'app-register',
templateUrl: 'register.component.html', templateUrl: 'register.component.html',
@@ -22,6 +26,8 @@ export class RegisterComponent extends BaseRegisterComponent {
showCreateOrgMessage = false; showCreateOrgMessage = false;
showTerms = true; showTerms = true;
private policies: Policy[];
constructor(authService: AuthService, router: Router, constructor(authService: AuthService, router: Router,
i18nService: I18nService, cryptoService: CryptoService, i18nService: I18nService, cryptoService: CryptoService,
apiService: ApiService, private route: ActivatedRoute, apiService: ApiService, private route: ActivatedRoute,
@@ -32,7 +38,7 @@ export class RegisterComponent extends BaseRegisterComponent {
this.showTerms = !platformUtilsService.isSelfHost(); this.showTerms = !platformUtilsService.isSelfHost();
} }
ngOnInit() { async ngOnInit() {
const queryParamsSub = this.route.queryParams.subscribe((qParams) => { const queryParamsSub = this.route.queryParams.subscribe((qParams) => {
if (qParams.email != null && qParams.email.indexOf('@') > -1) { if (qParams.email != null && qParams.email.indexOf('@') > -1) {
this.email = qParams.email; this.email = qParams.email;
@@ -48,5 +54,16 @@ export class RegisterComponent extends BaseRegisterComponent {
queryParamsSub.unsubscribe(); 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 { }
}
} }
} }