Add Google Drive scope check
parent
9a82e00f15
commit
39220e8e72
|
@ -8,6 +8,7 @@
|
||||||
|
|
||||||
import SyncConflictModal from '../components/SyncConflictModal.svelte';
|
import SyncConflictModal from '../components/SyncConflictModal.svelte';
|
||||||
import { pushToast } from '../stores/toast';
|
import { pushToast } from '../stores/toast';
|
||||||
|
import { t } from 'svelte-i18n';
|
||||||
|
|
||||||
const { open: openModal, close: closeModal } = getContext('simple-modal');
|
const { open: openModal, close: closeModal } = getContext('simple-modal');
|
||||||
|
|
||||||
|
@ -66,11 +67,20 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateSigninStatus(status) {
|
function updateSigninStatus(status) {
|
||||||
console.log('update drive signed in status:', status);
|
const hasScope = gapi.auth2.getAuthInstance().currentUser.get().hasGrantedScopes(SCOPES);
|
||||||
driveSignedIn.set(status);
|
|
||||||
|
if (status && !hasScope) {
|
||||||
|
pushToast($t('settings.driveSignInErrorScope'), 'error');
|
||||||
|
gapi.auth2.getAuthInstance().signOut();
|
||||||
|
}
|
||||||
|
|
||||||
|
const finalStatus = status && hasScope;
|
||||||
|
|
||||||
|
console.log('update drive signed in status:', finalStatus);
|
||||||
|
driveSignedIn.set(finalStatus);
|
||||||
driveLoading.set(false);
|
driveLoading.set(false);
|
||||||
|
|
||||||
if (status) {
|
if (finalStatus) {
|
||||||
getFiles();
|
getFiles();
|
||||||
} else {
|
} else {
|
||||||
synced.set(true);
|
synced.set(true);
|
||||||
|
@ -343,7 +353,6 @@
|
||||||
document.body.appendChild(fileLink);
|
document.body.appendChild(fileLink);
|
||||||
fileLink.click();
|
fileLink.click();
|
||||||
}
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<slot />
|
<slot />
|
||||||
|
|
|
@ -552,6 +552,7 @@
|
||||||
"driveError": "Google Drive API cannot be loaded",
|
"driveError": "Google Drive API cannot be loaded",
|
||||||
"driveSignIn": "Sign in to Google Drive",
|
"driveSignIn": "Sign in to Google Drive",
|
||||||
"driveSignOut": "Sign out Google Drive",
|
"driveSignOut": "Sign out Google Drive",
|
||||||
|
"driveSignInErrorScope": "Drive Sign In failed! Please sign in again and check the required permission!",
|
||||||
"synced": "Synced",
|
"synced": "Synced",
|
||||||
"waiting": "Waiting...",
|
"waiting": "Waiting...",
|
||||||
"syncing": "Syncing...",
|
"syncing": "Syncing...",
|
||||||
|
|
|
@ -552,6 +552,7 @@
|
||||||
"driveError": "Google Drive API tidak bisa dimuat",
|
"driveError": "Google Drive API tidak bisa dimuat",
|
||||||
"driveSignIn": "Sign in ke Google Drive",
|
"driveSignIn": "Sign in ke Google Drive",
|
||||||
"driveSignOut": "Sign out dari Google Drive",
|
"driveSignOut": "Sign out dari Google Drive",
|
||||||
|
"driveSignInErrorScope": "Drive Sign In gagal! Silahkan login kembali dan cek permission yang diperlukan!",
|
||||||
"synced": "Synced",
|
"synced": "Synced",
|
||||||
"waiting": "Menunggu...",
|
"waiting": "Menunggu...",
|
||||||
"syncing": "Syncing...",
|
"syncing": "Syncing...",
|
||||||
|
|
|
@ -252,7 +252,7 @@
|
||||||
|
|
||||||
<div class="lg:ml-64 pt-20 px-4 md:px-8 lg:pt-8">
|
<div class="lg:ml-64 pt-20 px-4 md:px-8 lg:pt-8">
|
||||||
<div class="bg-item rounded-xl mb-4 p-4">
|
<div class="bg-item rounded-xl mb-4 p-4">
|
||||||
<p class="text-white">{$t('settings.version')} <b>1.5</b></p>
|
<p class="text-white">{$t('settings.version')} <b>2.0</b></p>
|
||||||
</div>
|
</div>
|
||||||
<div class="bg-item rounded-xl mb-4 p-4 flex flex-col">
|
<div class="bg-item rounded-xl mb-4 p-4 flex flex-col">
|
||||||
<p class="text-white">{$t('settings.multiple')}</p>
|
<p class="text-white">{$t('settings.multiple')}</p>
|
||||||
|
|
Loading…
Reference in New Issue