mirror of
https://github.com/transloadit/uppy.git
synced 2026-07-22 09:48:06 +00:00
Check for auth session on new object. Add auth link to auth template.
This commit is contained in:
parent
6af4293dbe
commit
ea81ec9e8c
1 changed files with 17 additions and 1 deletions
|
|
@ -1,5 +1,7 @@
|
|||
// import Utils from '../core/Utils'
|
||||
import Plugin from './Plugin'
|
||||
// temporarily using superagent
|
||||
import request from 'superagent'
|
||||
|
||||
export default class Drive extends Plugin {
|
||||
constructor (core, opts) {
|
||||
|
|
@ -8,9 +10,13 @@ export default class Drive extends Plugin {
|
|||
this.authenticate = this.authenticate.bind(this)
|
||||
this.connect = this.connect.bind(this)
|
||||
this.render = this.render.bind(this)
|
||||
this.renderAuthentication = this.renderAuthentication.bind(this)
|
||||
this.checkAuthentication = this.checkAuthentication.bind(this)
|
||||
this.files = []
|
||||
this.currentDir = '/'
|
||||
|
||||
this.checkAuthentication()
|
||||
|
||||
this.isAuthenticated = false
|
||||
}
|
||||
|
||||
|
|
@ -23,6 +29,16 @@ export default class Drive extends Plugin {
|
|||
}
|
||||
}
|
||||
|
||||
checkAuthentication () {
|
||||
request.get('http://localhost:3002/drive/auth/authorize')
|
||||
.set('Content-Type', 'application/json')
|
||||
.end((err, res) => {
|
||||
if (err) { return new Error(err) }
|
||||
this.isAuthenticated = res.body.isAuthenticated
|
||||
this.authUrl = res.body.authUrl
|
||||
})
|
||||
}
|
||||
|
||||
authenticate () {
|
||||
}
|
||||
|
||||
|
|
@ -39,7 +55,7 @@ export default class Drive extends Plugin {
|
|||
}
|
||||
|
||||
renderAuthentication () {
|
||||
return `<div><h1>Authenticate With Google Drive</h1><button>Authenticate</button></div>`
|
||||
return `<div><h1>Authenticate With Google Drive</h1><a href=${ this.authUrl || '#' }>Authenticate</a></div>`
|
||||
}
|
||||
|
||||
render (files) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue