1
0
mirror of https://github.com/bitwarden/web synced 2025-12-10 05:13:40 +00:00

org invite accept flow on login/register

This commit is contained in:
Kyle Spearrin
2018-07-13 10:51:52 -04:00
parent a1495a8f0c
commit 3cfe8bf751
7 changed files with 47 additions and 21 deletions

2
jslib

Submodule jslib updated: 6db55bbae8...a949f499ac

View File

@@ -19,10 +19,10 @@
<p>{{'joinOrganizationDesc' | i18n}}</p> <p>{{'joinOrganizationDesc' | i18n}}</p>
<hr> <hr>
<div class="d-flex"> <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}} {{'logIn' | i18n}}
</a> </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}} {{'createAccount' | i18n}}
</a> </a>
</div> </div>

View File

@@ -14,6 +14,7 @@ import {
import { ApiService } from 'jslib/abstractions/api.service'; import { ApiService } from 'jslib/abstractions/api.service';
import { I18nService } from 'jslib/abstractions/i18n.service'; import { I18nService } from 'jslib/abstractions/i18n.service';
import { StateService } from 'jslib/abstractions/state.service';
import { UserService } from 'jslib/abstractions/user.service'; import { UserService } from 'jslib/abstractions/user.service';
import { OrganizationUserAcceptRequest } from 'jslib/models/request/organizationUserAcceptRequest'; import { OrganizationUserAcceptRequest } from 'jslib/models/request/organizationUserAcceptRequest';
@@ -31,7 +32,8 @@ export class AcceptOrganizationComponent implements OnInit {
constructor(private router: Router, private toasterService: ToasterService, constructor(private router: Router, private toasterService: ToasterService,
private i18nService: I18nService, private route: ActivatedRoute, private i18nService: I18nService, private route: ActivatedRoute,
private apiService: ApiService, private userService: UserService) { } private apiService: ApiService, private userService: UserService,
private stateService: StateService) { }
ngOnInit() { ngOnInit() {
let fired = false; let fired = false;
@@ -40,8 +42,8 @@ export class AcceptOrganizationComponent implements OnInit {
return; return;
} }
fired = true; fired = true;
let error = qParams.organizationId == null || qParams.organizationUserId == null || await this.stateService.remove('orgInvitation');
qParams.token == null; let error = qParams.organizationId == null || qParams.organizationUserId == null || qParams.token == null;
if (!error) { if (!error) {
this.authed = await this.userService.isAuthenticated(); this.authed = await this.userService.isAuthenticated();
if (this.authed) { if (this.authed) {
@@ -63,6 +65,7 @@ export class AcceptOrganizationComponent implements OnInit {
error = true; error = true;
} }
} else { } else {
await this.stateService.save('orgInvitation', qParams);
this.email = qParams.email; this.email = qParams.email;
this.orgName = qParams.organizationName; this.orgName = qParams.organizationName;
} }
@@ -76,12 +79,4 @@ export class AcceptOrganizationComponent implements OnInit {
this.loading = false; this.loading = false;
}); });
} }
login() {
//
}
register() {
//
}
} }

View File

@@ -33,7 +33,7 @@
<i class="fa fa-sign-in"></i> {{'logIn' | i18n}}</span> <i class="fa fa-sign-in"></i> {{'logIn' | i18n}}</span>
<i class="fa fa-spinner fa-spin" [hidden]="!form.loading"></i> <i class="fa fa-spinner fa-spin" [hidden]="!form.loading"></i>
</button> </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}} <i class="fa fa-pencil-square-o"></i> {{'createAccount' | i18n}}
</a> </a>
</div> </div>

View File

@@ -9,6 +9,7 @@ import { Angulartics2 } from 'angulartics2';
import { AuthService } from 'jslib/abstractions/auth.service'; import { AuthService } from 'jslib/abstractions/auth.service';
import { I18nService } from 'jslib/abstractions/i18n.service'; import { I18nService } from 'jslib/abstractions/i18n.service';
import { StateService } from 'jslib/abstractions/state.service';
import { StorageService } from 'jslib/abstractions/storage.service'; import { StorageService } from 'jslib/abstractions/storage.service';
import { LoginComponent as BaseLoginComponent } from 'jslib/angular/components/login.component'; import { LoginComponent as BaseLoginComponent } from 'jslib/angular/components/login.component';
@@ -21,9 +22,9 @@ export class LoginComponent extends BaseLoginComponent {
constructor(authService: AuthService, router: Router, constructor(authService: AuthService, router: Router,
analytics: Angulartics2, toasterService: ToasterService, analytics: Angulartics2, toasterService: ToasterService,
i18nService: I18nService, private route: ActivatedRoute, i18nService: I18nService, private route: ActivatedRoute,
storageService: StorageService) { storageService: StorageService, private stateService: StateService) {
super(authService, router, analytics, toasterService, i18nService, storageService); super(authService, router, analytics, toasterService, i18nService, storageService);
this.successRoute = '/vault'; this.onSuccessfulLoginNavigate = this.goAfterLogIn;
} }
async ngOnInit() { async ngOnInit() {
@@ -34,4 +35,13 @@ export class LoginComponent extends BaseLoginComponent {
await super.ngOnInit(); 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]);
}
}
} }

View File

@@ -1,5 +1,8 @@
import { Component } from '@angular/core'; import { Component } from '@angular/core';
import { Router } from '@angular/router'; import {
ActivatedRoute,
Router,
} from '@angular/router';
import { ToasterService } from 'angular2-toaster'; import { ToasterService } from 'angular2-toaster';
import { Angulartics2 } from 'angulartics2'; import { Angulartics2 } from 'angulartics2';
@@ -19,7 +22,15 @@ export class RegisterComponent extends BaseRegisterComponent {
constructor(authService: AuthService, router: Router, constructor(authService: AuthService, router: Router,
analytics: Angulartics2, toasterService: ToasterService, analytics: Angulartics2, toasterService: ToasterService,
i18nService: I18nService, cryptoService: CryptoService, i18nService: I18nService, cryptoService: CryptoService,
apiService: ApiService) { apiService: ApiService, private route: ActivatedRoute) {
super(authService, router, analytics, toasterService, i18nService, cryptoService, apiService); 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;
}
});
}
} }

View File

@@ -21,7 +21,7 @@ import { AuthService } from 'jslib/abstractions/auth.service';
import { EnvironmentService } from 'jslib/abstractions/environment.service'; import { EnvironmentService } from 'jslib/abstractions/environment.service';
import { I18nService } from 'jslib/abstractions/i18n.service'; import { I18nService } from 'jslib/abstractions/i18n.service';
import { PlatformUtilsService } from 'jslib/abstractions/platformUtils.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'; 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, constructor(authService: AuthService, router: Router,
analytics: Angulartics2, toasterService: ToasterService, analytics: Angulartics2, toasterService: ToasterService,
i18nService: I18nService, apiService: ApiService, i18nService: I18nService, apiService: ApiService,
platformUtilsService: PlatformUtilsService, private syncService: SyncService, platformUtilsService: PlatformUtilsService, private stateService: StateService,
environmentService: EnvironmentService, private componentFactoryResolver: ComponentFactoryResolver) { environmentService: EnvironmentService, private componentFactoryResolver: ComponentFactoryResolver) {
super(authService, router, analytics, toasterService, i18nService, apiService, super(authService, router, analytics, toasterService, i18nService, apiService,
platformUtilsService, window, environmentService); platformUtilsService, window, environmentService);
this.onSuccessfulLoginNavigate = this.goAfterLogIn;
} }
anotherMethod() { anotherMethod() {
@@ -56,4 +57,13 @@ export class TwoFactorComponent extends BaseTwoFactorComponent {
modal.close(); 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]);
}
}
} }