user_authentication 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 17f2717aefc439f9917b101b30ba05ad47a4beae
4
- data.tar.gz: 8f5836d3a23da681d90d6967929275f036e2e82c
3
+ metadata.gz: 7cab4b717fa05399b7c8bccd19fd3e9b20803ff0
4
+ data.tar.gz: 225aa6d85665d2e2c70233b0f1c2bb486961e289
5
5
  SHA512:
6
- metadata.gz: 8aab8a8a433b7b7dd6e1919de7233f7e59755049b269b98d1aea019aa3fdf3a2fea9a0554787f799aa6ddc39205d2d4fe0b76dc4fefc5edd06e57d42d697fe4b
7
- data.tar.gz: 45d750a8beddee8285497e2c3ee3af5e8c4d23d63c23bd95b55caeeaf019c401eaea040926a2d206a3d8f5c4eb4d1f6e79e5e13c2ed01ce4a60f18f245e05af4
6
+ metadata.gz: 0d012c397a7afde1c31d821c53502ca50054272576ef8a59341a94a08d878c428d0684a2b0220e8bbc6f1fb8470e1b24ddc09a6a2f96677d48b828ae010f7672
7
+ data.tar.gz: 0d9dc1a12b89d5fda9932bc482632e3436f585344c1680348a4fdc24bf5a8c2aeceb0fffb2842570f87712f824af9d5ffb43d9353b70f70b340d6de7b7f02e3a
@@ -1,9 +1,10 @@
1
1
  class ApplicationController < ActionController::Base
2
2
  before_filter :set_current_user
3
3
 
4
- # private
4
+ # private
5
5
 
6
- def authorize
6
+ # redirect: Path to login page.
7
+ def authorize(redirect=nil)
7
8
  # Not using skip_before_filter, since main app could inadvertently override that
8
9
  # by using a before_filter :authorize in its application_controller.
9
10
  if params[:controller] == "users" && ["login", "logout", "signup"].include?(params[:action])
@@ -11,8 +12,10 @@ class ApplicationController < ActionController::Base
11
12
  end
12
13
 
13
14
  if current_user.nil?
14
- session[:return_to] = url_for params
15
- redirect_to root_path, alert: "Please log in to access this page."
15
+ session[:redirect] = url_for params
16
+ redirect_to redirect || login_path, alert: "Please log in to access this page."
17
+ else
18
+ return true
16
19
  end
17
20
  end
18
21
 
@@ -29,6 +32,11 @@ class ApplicationController < ActionController::Base
29
32
 
30
33
  true
31
34
  end
35
+
36
+ def redirect
37
+ session_redirect = session.delete(:redirect)
38
+ redirect_to params[:redirect] || session_redirect || :back
39
+ end
32
40
  end
33
41
 
34
42
  require File.join Rails.root, "app/controllers/application_controller"
@@ -16,10 +16,10 @@ class UsersController < ApplicationController
16
16
  if respond_to? :on_login
17
17
  on_login
18
18
  else
19
- redirect_to params[:redirect] || :back
19
+ redirect
20
20
  end
21
21
  else
22
- redirect_to :back, alert: 'Please check email and password.'
22
+ redirect_to :back, alert: "Please check email and password."
23
23
  end
24
24
  end
25
25
 
@@ -30,7 +30,7 @@ class UsersController < ApplicationController
30
30
  if respond_to? :on_logout
31
31
  on_logout
32
32
  else
33
- redirect_to root_path
33
+ redirect_to :back
34
34
  end
35
35
  end
36
36
 
@@ -46,10 +46,10 @@ class UsersController < ApplicationController
46
46
  if respond_to? :on_signup
47
47
  on_signup
48
48
  else
49
- redirect_to params[:redirect] || :back
49
+ redirect
50
50
  end
51
51
  else
52
- redirect_to :back, alert: 'Please check email and password.'
52
+ redirect_to :back, alert: "Please check email and password."
53
53
  end
54
54
  end
55
55
 
@@ -60,7 +60,7 @@ class UsersController < ApplicationController
60
60
  if respond_to? :on_set_password
61
61
  on_set_password
62
62
  else
63
- redirect_to params[:redirect] || :back
63
+ redirect
64
64
  end
65
65
  end
66
66
  end
@@ -1,3 +1,3 @@
1
1
  module UserAuthentication
2
- VERSION = '0.1.3'
2
+ VERSION = '0.1.4'
3
3
  end
@@ -0,0 +1,3 @@
1
+ module UserAuthentication
2
+ VERSION = '0.1.3'
3
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: user_authentication
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sujoy Gupta
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-08 00:00:00.000000000 Z
11
+ date: 2014-06-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -171,6 +171,7 @@ files:
171
171
  - lib/random.rb
172
172
  - lib/tasks/user_authentication_tasks.rake
173
173
  - lib/user_authentication/version.rb
174
+ - lib/user_authentication/version.rb~
174
175
  - lib/user_authentication.rb
175
176
  - MIT-LICENSE
176
177
  - Rakefile