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

This commit is contained in:
Peng Xiao authored and GitHub committed 2023-04-13 15:14:46 +00:00
1 parent 934e242116
commit 42756045bb
7 files changed
+27 -32

No files matched your search

+7 -4
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 = () => {