Commit af08948e5c3218cbb7610983994b752d5bd099aa
Committed by
Leandro Santos
1 parent
8e2f02dc
Exists in
master
and in
29 other branches
Infra to display login popup when not logged users click in a link
Showing
2 changed files
with
30 additions
and
1 deletions
Show diff stats
lib/authenticated_system.rb
@@ -60,7 +60,11 @@ module AuthenticatedSystem | @@ -60,7 +60,11 @@ module AuthenticatedSystem | ||
60 | if logged_in? && authorized? | 60 | if logged_in? && authorized? |
61 | true | 61 | true |
62 | else | 62 | else |
63 | - access_denied | 63 | + if params[:require_login_popup] |
64 | + render :json => { :require_login_popup => true } | ||
65 | + else | ||
66 | + access_denied | ||
67 | + end | ||
64 | end | 68 | end |
65 | end | 69 | end |
66 | 70 |
@@ -0,0 +1,25 @@ | @@ -0,0 +1,25 @@ | ||
1 | +(function($) { | ||
2 | + $(window).bind('userDataLoaded', function(event, data) { | ||
3 | + $(".require-login-popup").live('click', function(){ | ||
4 | + clicked = $(this); | ||
5 | + url = clicked.attr("href"); | ||
6 | + if(url!=undefined && url!='' && url!='#') { | ||
7 | + if(!data.login) { | ||
8 | + url = $.param.querystring(url, "require_login_popup=true"); | ||
9 | + } | ||
10 | + loading_for_button(this); | ||
11 | + $.post(url, function(data){ | ||
12 | + if(data.require_login_popup) { | ||
13 | + $('#link_login').click(); //TODO see a better way to show login popup | ||
14 | + } | ||
15 | + }).complete(function() { | ||
16 | + clicked.css("cursor",""); | ||
17 | + $(".small-loading").remove(); | ||
18 | + }); | ||
19 | + } else { | ||
20 | + $('#link_login').click(); | ||
21 | + } | ||
22 | + return false; | ||
23 | + }); | ||
24 | + }); | ||
25 | +})(jQuery); |