mirror of
https://github.com/bitwarden/browser.git
synced 2024-11-23 11:56:00 +01:00
org invite accept flow on login/register
This commit is contained in:
parent
a1495a8f0c
commit
3cfe8bf751
2
jslib
2
jslib
@ -1 +1 @@
|
||||
Subproject commit 6db55bbae8b54f76b4fe84102999446c4aad419e
|
||||
Subproject commit a949f499acb28ddb1ce7197fd35c0d02df957618
|
@ -19,10 +19,10 @@
|
||||
<p>{{'joinOrganizationDesc' | i18n}}</p>
|
||||
<hr>
|
||||
<div class="d-flex">
|
||||
<a routerLink="/" class="btn btn-primary btn-block">
|
||||
<a routerLink="/" [queryParams]="{email: email}" class="btn btn-primary btn-block">
|
||||
{{'logIn' | i18n}}
|
||||
</a>
|
||||
<a routerLink="/" class="btn btn-primary btn-block ml-2 mt-0">
|
||||
<a routerLink="/register" [queryParams]="{email: email}" class="btn btn-primary btn-block ml-2 mt-0">
|
||||
{{'createAccount' | i18n}}
|
||||
</a>
|
||||
</div>
|
||||
|
@ -14,6 +14,7 @@ import {
|
||||
|
||||
import { ApiService } from 'jslib/abstractions/api.service';
|
||||
import { I18nService } from 'jslib/abstractions/i18n.service';
|
||||
import { StateService } from 'jslib/abstractions/state.service';
|
||||
import { UserService } from 'jslib/abstractions/user.service';
|
||||
|
||||
import { OrganizationUserAcceptRequest } from 'jslib/models/request/organizationUserAcceptRequest';
|
||||
@ -31,7 +32,8 @@ export class AcceptOrganizationComponent implements OnInit {
|
||||
|
||||
constructor(private router: Router, private toasterService: ToasterService,
|
||||
private i18nService: I18nService, private route: ActivatedRoute,
|
||||
private apiService: ApiService, private userService: UserService) { }
|
||||
private apiService: ApiService, private userService: UserService,
|
||||
private stateService: StateService) { }
|
||||
|
||||
ngOnInit() {
|
||||
let fired = false;
|
||||
@ -40,8 +42,8 @@ export class AcceptOrganizationComponent implements OnInit {
|
||||
return;
|
||||
}
|
||||
fired = true;
|
||||
let error = qParams.organizationId == null || qParams.organizationUserId == null ||
|
||||
qParams.token == null;
|
||||
await this.stateService.remove('orgInvitation');
|
||||
let error = qParams.organizationId == null || qParams.organizationUserId == null || qParams.token == null;
|
||||
if (!error) {
|
||||
this.authed = await this.userService.isAuthenticated();
|
||||
if (this.authed) {
|
||||
@ -63,6 +65,7 @@ export class AcceptOrganizationComponent implements OnInit {
|
||||
error = true;
|
||||
}
|
||||
} else {
|
||||
await this.stateService.save('orgInvitation', qParams);
|
||||
this.email = qParams.email;
|
||||
this.orgName = qParams.organizationName;
|
||||
}
|
||||
@ -76,12 +79,4 @@ export class AcceptOrganizationComponent implements OnInit {
|
||||
this.loading = false;
|
||||
});
|
||||
}
|
||||
|
||||
login() {
|
||||
//
|
||||
}
|
||||
|
||||
register() {
|
||||
//
|
||||
}
|
||||
}
|
||||
|
@ -33,7 +33,7 @@
|
||||
<i class="fa fa-sign-in"></i> {{'logIn' | i18n}}</span>
|
||||
<i class="fa fa-spinner fa-spin" [hidden]="!form.loading"></i>
|
||||
</button>
|
||||
<a routerLink="/register" class="btn btn-outline-secondary btn-block ml-2 mt-0">
|
||||
<a routerLink="/register" [queryParams]="{email: email}" class="btn btn-outline-secondary btn-block ml-2 mt-0">
|
||||
<i class="fa fa-pencil-square-o"></i> {{'createAccount' | i18n}}
|
||||
</a>
|
||||
</div>
|
||||
|
@ -9,6 +9,7 @@ import { Angulartics2 } from 'angulartics2';
|
||||
|
||||
import { AuthService } from 'jslib/abstractions/auth.service';
|
||||
import { I18nService } from 'jslib/abstractions/i18n.service';
|
||||
import { StateService } from 'jslib/abstractions/state.service';
|
||||
import { StorageService } from 'jslib/abstractions/storage.service';
|
||||
|
||||
import { LoginComponent as BaseLoginComponent } from 'jslib/angular/components/login.component';
|
||||
@ -21,9 +22,9 @@ export class LoginComponent extends BaseLoginComponent {
|
||||
constructor(authService: AuthService, router: Router,
|
||||
analytics: Angulartics2, toasterService: ToasterService,
|
||||
i18nService: I18nService, private route: ActivatedRoute,
|
||||
storageService: StorageService) {
|
||||
storageService: StorageService, private stateService: StateService) {
|
||||
super(authService, router, analytics, toasterService, i18nService, storageService);
|
||||
this.successRoute = '/vault';
|
||||
this.onSuccessfulLoginNavigate = this.goAfterLogIn;
|
||||
}
|
||||
|
||||
async ngOnInit() {
|
||||
@ -34,4 +35,13 @@ export class LoginComponent extends BaseLoginComponent {
|
||||
await super.ngOnInit();
|
||||
});
|
||||
}
|
||||
|
||||
async goAfterLogIn() {
|
||||
const invite = await this.stateService.get<any>('orgInvitation');
|
||||
if (invite != null) {
|
||||
this.router.navigate(['accept-organization'], { queryParams: invite });
|
||||
} else {
|
||||
this.router.navigate([this.successRoute]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,8 @@
|
||||
import { Component } from '@angular/core';
|
||||
import { Router } from '@angular/router';
|
||||
import {
|
||||
ActivatedRoute,
|
||||
Router,
|
||||
} from '@angular/router';
|
||||
|
||||
import { ToasterService } from 'angular2-toaster';
|
||||
import { Angulartics2 } from 'angulartics2';
|
||||
@ -19,7 +22,15 @@ export class RegisterComponent extends BaseRegisterComponent {
|
||||
constructor(authService: AuthService, router: Router,
|
||||
analytics: Angulartics2, toasterService: ToasterService,
|
||||
i18nService: I18nService, cryptoService: CryptoService,
|
||||
apiService: ApiService) {
|
||||
apiService: ApiService, private route: ActivatedRoute) {
|
||||
super(authService, router, analytics, toasterService, i18nService, cryptoService, apiService);
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.route.queryParams.subscribe((qParams) => {
|
||||
if (qParams.email != null && qParams.email.indexOf('@') > -1) {
|
||||
this.email = qParams.email;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ import { AuthService } from 'jslib/abstractions/auth.service';
|
||||
import { EnvironmentService } from 'jslib/abstractions/environment.service';
|
||||
import { I18nService } from 'jslib/abstractions/i18n.service';
|
||||
import { PlatformUtilsService } from 'jslib/abstractions/platformUtils.service';
|
||||
import { SyncService } from 'jslib/abstractions/sync.service';
|
||||
import { StateService } from 'jslib/abstractions/state.service';
|
||||
|
||||
import { TwoFactorComponent as BaseTwoFactorComponent } from 'jslib/angular/components/two-factor.component';
|
||||
|
||||
@ -35,10 +35,11 @@ export class TwoFactorComponent extends BaseTwoFactorComponent {
|
||||
constructor(authService: AuthService, router: Router,
|
||||
analytics: Angulartics2, toasterService: ToasterService,
|
||||
i18nService: I18nService, apiService: ApiService,
|
||||
platformUtilsService: PlatformUtilsService, private syncService: SyncService,
|
||||
platformUtilsService: PlatformUtilsService, private stateService: StateService,
|
||||
environmentService: EnvironmentService, private componentFactoryResolver: ComponentFactoryResolver) {
|
||||
super(authService, router, analytics, toasterService, i18nService, apiService,
|
||||
platformUtilsService, window, environmentService);
|
||||
this.onSuccessfulLoginNavigate = this.goAfterLogIn;
|
||||
}
|
||||
|
||||
anotherMethod() {
|
||||
@ -56,4 +57,13 @@ export class TwoFactorComponent extends BaseTwoFactorComponent {
|
||||
modal.close();
|
||||
});
|
||||
}
|
||||
|
||||
async goAfterLogIn() {
|
||||
const invite = await this.stateService.get<any>('orgInvitation');
|
||||
if (invite != null) {
|
||||
this.router.navigate(['accept-organization'], { queryParams: invite });
|
||||
} else {
|
||||
this.router.navigate([this.successRoute]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user