You've already forked matrix-react-sdk
mirror of
https://github.com/matrix-org/matrix-react-sdk.git
synced 2025-08-07 21:23:00 +03:00
Add utility method mxLoginWithAccessToken to login with existing access token (#7261)
This commit is contained in:
committed by
GitHub
parent
b69ad0cd0b
commit
aa7cae08aa
@@ -538,8 +538,8 @@ export function hydrateSession(credentials: IMatrixClientCreds): Promise<MatrixC
|
||||
* fires on_logging_in, optionally clears localstorage, persists new credentials
|
||||
* to localstorage, starts the new client.
|
||||
*
|
||||
* @param {MatrixClientCreds} credentials
|
||||
* @param {Boolean} clearStorage
|
||||
* @param {IMatrixClientCreds} credentials
|
||||
* @param {Boolean} clearStorageEnabled
|
||||
*
|
||||
* @returns {Promise} promise which resolves to the new MatrixClient once it has been started
|
||||
*/
|
||||
@@ -918,3 +918,17 @@ export function stopMatrixClient(unsetClient = true): void {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Utility method to perform a login with an existing access_token
|
||||
window.mxLoginWithAccessToken = async (hsUrl: string, accessToken: string): Promise<void> => {
|
||||
const tempClient = createClient({
|
||||
baseUrl: hsUrl,
|
||||
accessToken,
|
||||
});
|
||||
const { user_id: userId } = await tempClient.whoami();
|
||||
await doSetLoggedIn({
|
||||
homeserverUrl: hsUrl,
|
||||
accessToken,
|
||||
userId,
|
||||
}, true);
|
||||
};
|
||||
|
Reference in New Issue
Block a user