skip encryption manager for cloud users.

This commit is contained in:
Jason Kulatunga 2022-11-07 08:36:58 -08:00
parent 3a13d2d4ac
commit 6f0675e176
2 changed files with 12 additions and 2 deletions

View File

@ -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)

View File

@ -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<string> {
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
}