Add Google Drive scope check

pull/1/head
Made Baruna 2021-08-12 02:19:19 +07:00
parent 9a82e00f15
commit 39220e8e72
No known key found for this signature in database
GPG Key ID: 5AA5DA16AA5DCEAD
4 changed files with 16 additions and 5 deletions

View File

@ -8,6 +8,7 @@
import SyncConflictModal from '../components/SyncConflictModal.svelte';
import { pushToast } from '../stores/toast';
import { t } from 'svelte-i18n';
const { open: openModal, close: closeModal } = getContext('simple-modal');
@ -66,11 +67,20 @@
}
function updateSigninStatus(status) {
console.log('update drive signed in status:', status);
driveSignedIn.set(status);
const hasScope = gapi.auth2.getAuthInstance().currentUser.get().hasGrantedScopes(SCOPES);
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);
if (status) {
if (finalStatus) {
getFiles();
} else {
synced.set(true);
@ -343,7 +353,6 @@
document.body.appendChild(fileLink);
fileLink.click();
}
</script>
<slot />

View File

@ -552,6 +552,7 @@
"driveError": "Google Drive API cannot be loaded",
"driveSignIn": "Sign in to Google Drive",
"driveSignOut": "Sign out Google Drive",
"driveSignInErrorScope": "Drive Sign In failed! Please sign in again and check the required permission!",
"synced": "Synced",
"waiting": "Waiting...",
"syncing": "Syncing...",

View File

@ -552,6 +552,7 @@
"driveError": "Google Drive API tidak bisa dimuat",
"driveSignIn": "Sign in ke Google Drive",
"driveSignOut": "Sign out dari Google Drive",
"driveSignInErrorScope": "Drive Sign In gagal! Silahkan login kembali dan cek permission yang diperlukan!",
"synced": "Synced",
"waiting": "Menunggu...",
"syncing": "Syncing...",

View File

@ -252,7 +252,7 @@
<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">
<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 class="bg-item rounded-xl mb-4 p-4 flex flex-col">
<p class="text-white">{$t('settings.multiple')}</p>