浏览代码

Encode state to base64 to pass to oauth

Harry Hedger 9 年之前
父节点
当前提交
cf03fb784d
共有 1 个文件被更改,包括 6 次插入2 次删除
  1. 6 2
      src/plugins/GoogleDrive.js

+ 6 - 2
src/plugins/GoogleDrive.js

@@ -210,11 +210,15 @@ export default class Google extends Plugin {
    * Render user authentication view
    */
   renderAuth () {
-    const link = `${this.opts.host}/connect/google?state=${location.href}`
+    const state = btoa(JSON.stringify({
+      redirect: location.href
+    }))
+
+    const link = `${this.opts.host}/connect/google?state=${state}`
     return yo`
       <div class="UppyGoogleDrive-authenticate">
         <h1>You need to authenticate with Google before selecting files.</h1>
-        <a href=${link}>Authenticate</a>
+        <a href=${link} target="_blank">Authenticate</a>
       </div>
     `
   }