mirror of https://github.com/vector-im/riot-web
				
				
				
			Un-break crypto for soft logout
							parent
							
								
									aba61fa390
								
							
						
					
					
						commit
						bd1568f4e4
					
				| 
						 | 
				
			
			@ -516,7 +516,7 @@ export async function setLoggedIn(credentials: IMatrixClientCreds): Promise<Matr
 | 
			
		|||
 *
 | 
			
		||||
 * @returns {Promise} promise which resolves to the new MatrixClient once it has been started
 | 
			
		||||
 */
 | 
			
		||||
export function hydrateSession(credentials: IMatrixClientCreds): Promise<MatrixClient> {
 | 
			
		||||
export async function hydrateSession(credentials: IMatrixClientCreds): Promise<MatrixClient> {
 | 
			
		||||
    const oldUserId = MatrixClientPeg.get().getUserId();
 | 
			
		||||
    const oldDeviceId = MatrixClientPeg.get().getDeviceId();
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -529,6 +529,11 @@ export function hydrateSession(credentials: IMatrixClientCreds): Promise<MatrixC
 | 
			
		|||
        logger.warn("Clearing all data: Old session belongs to a different user/session");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if (!credentials.pickleKey) {
 | 
			
		||||
        logger.info("Lifecycle#hydrateSession: Pickle key not provided - trying to get one");
 | 
			
		||||
        credentials.pickleKey = await PlatformPeg.get().getPickleKey(credentials.userId, credentials.deviceId);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    return doSetLoggedIn(credentials, overwrite);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -233,7 +233,15 @@ class MatrixClientPegClass implements IMatrixClientPeg {
 | 
			
		|||
    }
 | 
			
		||||
 | 
			
		||||
    public getCredentials(): IMatrixClientCreds {
 | 
			
		||||
        let copiedCredentials = this.currentClientCreds;
 | 
			
		||||
        if (this.currentClientCreds?.userId !== this.matrixClient?.credentials?.userId) {
 | 
			
		||||
            // cached credentials belong to a different user - don't use them
 | 
			
		||||
            copiedCredentials = null;
 | 
			
		||||
        }
 | 
			
		||||
        return {
 | 
			
		||||
            // Copy the cached credentials before overriding what we can.
 | 
			
		||||
            ...(copiedCredentials ?? {}),
 | 
			
		||||
 | 
			
		||||
            homeserverUrl: this.matrixClient.baseUrl,
 | 
			
		||||
            identityServerUrl: this.matrixClient.idBaseUrl,
 | 
			
		||||
            userId: this.matrixClient.credentials.userId,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue