diff --git a/jslib b/jslib
index 6db55bbae8..a949f499ac 160000
--- a/jslib
+++ b/jslib
@@ -1 +1 @@
-Subproject commit 6db55bbae8b54f76b4fe84102999446c4aad419e
+Subproject commit a949f499acb28ddb1ce7197fd35c0d02df957618
diff --git a/src/app/accounts/accept-organization.component.html b/src/app/accounts/accept-organization.component.html
index 2a7c8b713a..c2787bc74a 100644
--- a/src/app/accounts/accept-organization.component.html
+++ b/src/app/accounts/accept-organization.component.html
@@ -19,10 +19,10 @@
{{'joinOrganizationDesc' | i18n}}
diff --git a/src/app/accounts/accept-organization.component.ts b/src/app/accounts/accept-organization.component.ts
index f119cbfa3b..30e28cca8d 100644
--- a/src/app/accounts/accept-organization.component.ts
+++ b/src/app/accounts/accept-organization.component.ts
@@ -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() {
- //
- }
}
diff --git a/src/app/accounts/login.component.html b/src/app/accounts/login.component.html
index f01cad7923..781db5b437 100644
--- a/src/app/accounts/login.component.html
+++ b/src/app/accounts/login.component.html
@@ -33,7 +33,7 @@
{{'logIn' | i18n}}
-
+
{{'createAccount' | i18n}}
diff --git a/src/app/accounts/login.component.ts b/src/app/accounts/login.component.ts
index 4901aa787f..91167db8c4 100644
--- a/src/app/accounts/login.component.ts
+++ b/src/app/accounts/login.component.ts
@@ -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('orgInvitation');
+ if (invite != null) {
+ this.router.navigate(['accept-organization'], { queryParams: invite });
+ } else {
+ this.router.navigate([this.successRoute]);
+ }
+ }
}
diff --git a/src/app/accounts/register.component.ts b/src/app/accounts/register.component.ts
index 0867b5903c..a63257a566 100644
--- a/src/app/accounts/register.component.ts
+++ b/src/app/accounts/register.component.ts
@@ -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;
+ }
+ });
+ }
}
diff --git a/src/app/accounts/two-factor.component.ts b/src/app/accounts/two-factor.component.ts
index 932a9dd775..10cd47709d 100644
--- a/src/app/accounts/two-factor.component.ts
+++ b/src/app/accounts/two-factor.component.ts
@@ -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('orgInvitation');
+ if (invite != null) {
+ this.router.navigate(['accept-organization'], { queryParams: invite });
+ } else {
+ this.router.navigate([this.successRoute]);
+ }
+ }
}