Skip to content

Commit

Permalink
reintroduce auth modal for initial auth
Browse files Browse the repository at this point in the history
  • Loading branch information
julsemaan committed May 11, 2024
1 parent 66e2d29 commit e796453
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
1 change: 1 addition & 0 deletions client/app.tt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
{{> modal id="file_load_modal" title="Your file is being loaded" message="Depending on the file size, this can be long." with_bar=true }}
{{> 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 }}
{{> 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" }}
{{> 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!" }}

{{> file_info }}
{{> major_notice_modal }}
Expand Down
24 changes: 19 additions & 5 deletions client/assets/js/Controller/OAuth.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,25 @@ GoogleOAuthController.prototype.init = function(){

GoogleOAuthController.prototype.do_auth = function(user_id){
var self = this
sessionStorage.google_auth_return_to = window.location;
var url = "/api/oauth2/google/authorize";
if(user_id) {
url += "?login_hint="+user_id;
var auth = function() {
sessionStorage.google_auth_return_to = window.location;
var url = "/api/oauth2/google/authorize";
if(user_id) {
url += "?login_hint="+user_id;
}
window.location = url;
};

if(!sessionStorage.hasAuthedOnce) {
$('#auth_modal').modal('show')
$('#start_g_oauth').click(function() {
auth();
});
}
else {
auth();
}
window.location = url;

}

GoogleOAuthController.prototype.auth_with_user = function(user_id, callback){
Expand All @@ -67,6 +80,7 @@ GoogleOAuthController.prototype.setToken = function(token) {
setCookie('access_token', token, 1);
sessionStorage.access_token = token;
gapi.client.setToken({"access_token":token});
sessionStorage.hasAuthedOnce = true;
}

GoogleOAuthController.prototype.ready = function(){
Expand Down

0 comments on commit e796453

Please sign in to comment.