From ea81ec9e8c8e4fa7ddc9366c8bebec88162bd9d4 Mon Sep 17 00:00:00 2001 From: Harry Hedger Date: Wed, 3 Feb 2016 04:04:18 -0500 Subject: [PATCH] Check for auth session on new object. Add auth link to auth template. --- src/plugins/GoogleDrive.js | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/plugins/GoogleDrive.js b/src/plugins/GoogleDrive.js index a0668b57e..9d1dbffb8 100644 --- a/src/plugins/GoogleDrive.js +++ b/src/plugins/GoogleDrive.js @@ -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 `

Authenticate With Google Drive

` + return `

Authenticate With Google Drive

Authenticate
` } render (files) {