fix: failed to load blobs in electron (#1927)

This commit is contained in:
Peng Xiao
2023-04-13 23:14:46 +08:00
committed by GitHub
parent 934e242116
commit 42756045bb
7 changed files with 27 additions and 32 deletions

View File

@@ -67,10 +67,13 @@ export const setLoginStorage = (login: LoginResponse) => {
};
const signInWithElectron = async (firebaseAuth: FirebaseAuth) => {
const code = await window.apis?.googleSignIn();
const credential = GoogleAuthProvider.credential(code);
const user = await signInWithCredential(firebaseAuth, credential);
return await user.user.getIdToken();
if (window.apis) {
const { url, requestInit } = await window.apis.getGoogleOauthCode();
const { id_token } = await fetch(url, requestInit).then(res => res.json());
const credential = GoogleAuthProvider.credential(id_token);
const user = await signInWithCredential(firebaseAuth, credential);
return await user.user.getIdToken();
}
};
export const clearLoginStorage = () => {