From 6f0675e1760a82443268d6ffa3382f3234cfd59d Mon Sep 17 00:00:00 2001 From: Jason Kulatunga Date: Mon, 7 Nov 2022 08:36:58 -0800 Subject: [PATCH] skip encryption manager for cloud users. --- .../src/app/pages/auth-signin/auth-signin.component.ts | 10 ++++++++++ frontend/src/app/services/auth.service.ts | 4 ++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/frontend/src/app/pages/auth-signin/auth-signin.component.ts b/frontend/src/app/pages/auth-signin/auth-signin.component.ts index 87d496f4..32bfebdc 100644 --- a/frontend/src/app/pages/auth-signin/auth-signin.component.ts +++ b/frontend/src/app/pages/auth-signin/auth-signin.component.ts @@ -7,6 +7,7 @@ import {ToastNotification, ToastType} from '../../models/fasten/toast'; import {environment} from '../../../environments/environment'; import {AuthService} from '../../services/auth.service'; import {Location} from '@angular/common'; +import {PouchdbCrypto} from '../../../lib/database/plugins/crypto'; @Component({ selector: 'app-auth-signin', @@ -41,6 +42,15 @@ export class AuthSigninComponent implements OnInit { this.resetUrlOnCallback() this.authService.IdpCallback(idpType, state, code) + .then(() => { + //for cloud users ONLY, skip the encryption manager. + //TODO: replace Pouchdb. + let userId = this.authService.GetCurrentUser().sub + return PouchdbCrypto.CryptConfig(userId, userId) + }) + .then((cryptoConfig) => { + PouchdbCrypto.StoreCryptConfig(cryptoConfig) + }) .then(() => this.router.navigateByUrl('/dashboard')) .catch((err)=>{ console.error("idpCallback error:", err) diff --git a/frontend/src/app/services/auth.service.ts b/frontend/src/app/services/auth.service.ts index 85dcf470..ec6d70a7 100644 --- a/frontend/src/app/services/auth.service.ts +++ b/frontend/src/app/services/auth.service.ts @@ -55,7 +55,7 @@ export class AuthService { window.location.href = authorizationUrl.toString(); } - public async IdpCallback(idp_type: string, state: string, code: string) { + public async IdpCallback(idp_type: string, state: string, code: string): Promise { const expectedSourceStateInfo = JSON.parse(localStorage.getItem(state)) localStorage.removeItem(state) @@ -99,7 +99,7 @@ export class AuthService { this.setAuthToken(resp.data) - return resp + return resp.data }