fix sign in problem

This commit is contained in:
Xuan Sang LE 2018-02-28 21:10:44 +01:00
parent 90f7e1d166
commit 7baa808b55

View File

@ -14,8 +14,14 @@ class GoogleDriveHandler extends this.OS.API.VFS.BaseFileHandler
oninit: (f) -> oninit: (f) ->
me = @ me = @
return unless @setting return unless @setting
fn = (r) ->
return f() if r
# perform the login
G_CACHE = {"gdv:///":"root"}
gapi.auth2.getAuthInstance().signIn()
if _API.libready @setting.apilink if _API.libready @setting.apilink
f() fn(gapi.auth2.getAuthInstance().isSignedIn.get())
else else
_API.require @setting.apilink, () -> _API.require @setting.apilink, () ->
gapi.load "client:auth2", () -> gapi.load "client:auth2", () ->
@ -26,15 +32,11 @@ class GoogleDriveHandler extends this.OS.API.VFS.BaseFileHandler
scope: me.setting.SCOPES scope: me.setting.SCOPES
} }
.then () -> .then () ->
fn = (r) ->
return f() if r
# perform the login
G_CACHE = {"gdv:///":"root"}
gapi.auth2.getAuthInstance().signIn()
gapi.auth2.getAuthInstance().isSignedIn.listen (r) -> gapi.auth2.getAuthInstance().isSignedIn.listen (r) ->
fn(r) fn(r)
fn(gapi.auth2.getAuthInstance().isSignedIn.get()) fn(gapi.auth2.getAuthInstance().isSignedIn.get())
, (err) ->
_courrier.oserror "VFS cannot init GAPI", (_API.throwe "OS.VFS"), err
meta: (f) -> meta: (f) ->
me = @ me = @