ImportSongs: Implement Google Drive beta testing
Instances that wish to enable Google Drive support should first enable it to only a small subset of users (100 maximum) to allow the OAuth screen to be verified by Google without hitting the user limit. Minimum level in the config can be set to enable beta testing of this feature and then disabled by setting it to None. - Add user level assignment screen to the administration panel - Add privacy policy and links to it in various places - Add switch accounts link near the Google Drive picker
This commit is contained in:
@@ -131,37 +131,48 @@ class Gpicker{
|
||||
gapi.client.load("drive", "v3").then(resolve, reject)
|
||||
))
|
||||
}
|
||||
getToken(lockedCallback=()=>{}, errorCallback=()=>{}){
|
||||
if(this.oauthToken){
|
||||
return Promise.resolve()
|
||||
}
|
||||
getAuth(errorCallback=()=>{}){
|
||||
if(!this.auth){
|
||||
var authPromise = gapi.auth2.init({
|
||||
clientId: this.oauthClientId,
|
||||
fetch_basic_profile: false,
|
||||
scope: this.scope
|
||||
}).then(() => {
|
||||
this.auth = gapi.auth2.getAuthInstance()
|
||||
}, e => {
|
||||
if(e.details){
|
||||
errorCallback(strings.gpicker.authError.replace("%s", e.details))
|
||||
}
|
||||
return Promise.reject(e)
|
||||
return new Promise((resolve, reject) => {
|
||||
gapi.auth2.init({
|
||||
clientId: this.oauthClientId,
|
||||
fetch_basic_profile: false,
|
||||
scope: this.scope
|
||||
}).then(() => {
|
||||
this.auth = gapi.auth2.getAuthInstance()
|
||||
resolve(this.auth)
|
||||
}, e => {
|
||||
if(e.details){
|
||||
var errorStr = strings.gpicker.authError.replace("%s", e.details)
|
||||
if(/cookie/i.test(e.details)){
|
||||
errorStr += "\n\n" + strings.gpicker.cookieError
|
||||
}
|
||||
errorCallback(errorStr)
|
||||
}
|
||||
reject(e)
|
||||
})
|
||||
})
|
||||
}else{
|
||||
var authPromise = Promise.resolve()
|
||||
return Promise.resolve(this.auth)
|
||||
}
|
||||
return authPromise.then(() => {
|
||||
var user = this.auth.currentUser.get()
|
||||
if(!this.checkScope(user)){
|
||||
}
|
||||
getToken(lockedCallback=()=>{}, errorCallback=()=>{}, force){
|
||||
if(this.oauthToken && !force){
|
||||
return Promise.resolve()
|
||||
}
|
||||
return this.getAuth(errorCallback).then(auth => {
|
||||
var user = force || auth.currentUser.get()
|
||||
if(force || !this.checkScope(user)){
|
||||
lockedCallback(false)
|
||||
this.auth.signIn().then(user => {
|
||||
return auth.signIn(force ? {
|
||||
prompt: "select_account"
|
||||
} : undefined).then(user => {
|
||||
if(this.checkScope(user)){
|
||||
lockedCallback(true)
|
||||
}else{
|
||||
return Promise.reject("cancel")
|
||||
}
|
||||
})
|
||||
}, () => Promise.reject("cancel"))
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -173,6 +184,9 @@ class Gpicker{
|
||||
return false
|
||||
}
|
||||
}
|
||||
switchAccounts(lockedCallback, errorCallback){
|
||||
return this.loadApi().then(() => this.getToken(lockedCallback, errorCallback, true))
|
||||
}
|
||||
displayPicker(callback){
|
||||
var picker = gapi.picker.api
|
||||
new picker.PickerBuilder()
|
||||
|
||||
Reference in New Issue
Block a user