Skip to content

Commit e796453

Browse files
committed
reintroduce auth modal for initial auth
1 parent 66e2d29 commit e796453

File tree

2 files changed

+20
-5
lines changed

2 files changed

+20
-5
lines changed

client/app.tt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
{{> modal id="file_load_modal" title="Your file is being loaded" message="Depending on the file size, this can be long." with_bar=true }}
99
{{> modal id="error_modal" title="An unexpected error occurred with the provider server" message="The app flow will still continue but unexpected behavior may occur. When in doubt restart the app." dismiss=true }}
1010
{{> modal id="user_auth_modal" title="Switch user" message="In order to open this file, you need to switch user." button_id="switch_user" button_text="Switch user" }}
11+
{{> modal id="auth_modal" title="You need to authorize this app to access your Google Drive" message="Make sure you grant access (check the boxes) for all the permissions the app needs in the next screen." button_id="start_g_oauth" button_text="Authorize!" }}
1112

1213
{{> file_info }}
1314
{{> major_notice_modal }}

client/assets/js/Controller/OAuth.js

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,25 @@ GoogleOAuthController.prototype.init = function(){
4545

4646
GoogleOAuthController.prototype.do_auth = function(user_id){
4747
var self = this
48-
sessionStorage.google_auth_return_to = window.location;
49-
var url = "/api/oauth2/google/authorize";
50-
if(user_id) {
51-
url += "?login_hint="+user_id;
48+
var auth = function() {
49+
sessionStorage.google_auth_return_to = window.location;
50+
var url = "/api/oauth2/google/authorize";
51+
if(user_id) {
52+
url += "?login_hint="+user_id;
53+
}
54+
window.location = url;
55+
};
56+
57+
if(!sessionStorage.hasAuthedOnce) {
58+
$('#auth_modal').modal('show')
59+
$('#start_g_oauth').click(function() {
60+
auth();
61+
});
62+
}
63+
else {
64+
auth();
5265
}
53-
window.location = url;
66+
5467
}
5568

5669
GoogleOAuthController.prototype.auth_with_user = function(user_id, callback){
@@ -67,6 +80,7 @@ GoogleOAuthController.prototype.setToken = function(token) {
6780
setCookie('access_token', token, 1);
6881
sessionStorage.access_token = token;
6982
gapi.client.setToken({"access_token":token});
83+
sessionStorage.hasAuthedOnce = true;
7084
}
7185

7286
GoogleOAuthController.prototype.ready = function(){

0 commit comments

Comments
 (0)