tkh_authentication 0.0.6 → 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/CHANGELOG.md
CHANGED
@@ -2,13 +2,16 @@
|
|
2
2
|
|
3
3
|
|
4
4
|
|
5
|
+
## 0.0.7
|
6
|
+
|
7
|
+
* Safe redirect to root if host app did not set up the root route
|
8
|
+
|
5
9
|
|
6
10
|
## 0.0.6
|
7
11
|
|
8
12
|
* Redirect users to target page upon logging in if they had been interrupted by authenticate or authenticate_with_admin filters
|
9
13
|
|
10
14
|
|
11
|
-
|
12
15
|
## 0.0.5
|
13
16
|
|
14
17
|
* Users controller has both an authenticate and an authenticate_with_admin before_filters
|
@@ -11,7 +11,7 @@ class SessionsController < ApplicationController
|
|
11
11
|
else
|
12
12
|
cookies[:auth_token] = user.auth_token
|
13
13
|
end
|
14
|
-
redirect_to (session[:target_page] ||
|
14
|
+
redirect_to (session[:target_page] || safe_root_url), notice: t('authentication.login_confirmation')
|
15
15
|
session[:target_page] = nil
|
16
16
|
else
|
17
17
|
flash.now.alert = t('authentication.warning.email_or_password_invalid')
|
@@ -21,7 +21,7 @@ class SessionsController < ApplicationController
|
|
21
21
|
|
22
22
|
def destroy
|
23
23
|
cookies.delete(:auth_token)
|
24
|
-
redirect_to
|
24
|
+
redirect_to safe_root_url, notice: t('authentication.logout_confirmation')
|
25
25
|
end
|
26
26
|
|
27
27
|
end
|
@@ -16,7 +16,7 @@ class UsersController < ApplicationController
|
|
16
16
|
@user = User.new(params[:user])
|
17
17
|
if @user.save
|
18
18
|
cookies[:auth_token] = @user.auth_token
|
19
|
-
redirect_to session[:target_page] ||
|
19
|
+
redirect_to session[:target_page] || safe_root_url, notice: t('authentication.signup_confirmation')
|
20
20
|
session[:target_page] = nil
|
21
21
|
else
|
22
22
|
render "new"
|
data/app/models/user.rb
CHANGED
@@ -5,6 +5,7 @@ class User < ActiveRecord::Base
|
|
5
5
|
# not allowed are :admin:boolean, :auth_token:string, password_reset_token:string, password_reset_sent_at:datetime
|
6
6
|
attr_accessible :email, :password, :password_confirmation, :first_name, :last_name
|
7
7
|
|
8
|
+
validates_presence_of :email
|
8
9
|
validates_uniqueness_of :email, :case_sensitive => false
|
9
10
|
validates_presence_of :password, on: :create
|
10
11
|
validates_presence_of :first_name
|
@@ -18,8 +18,14 @@ module TkhAuthenticationActionControllerExtension
|
|
18
18
|
def authenticate_with_admin
|
19
19
|
unless current_user && current_user.admin?
|
20
20
|
session[:target_page] = request.url if session[:target_page].nil?
|
21
|
-
redirect_to
|
21
|
+
redirect_to safe_root_url, alert: t('authentication.warning.restricted_access')
|
22
22
|
end
|
23
23
|
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def safe_root_url
|
28
|
+
defined?(root_url) ? root_url : '/'
|
29
|
+
end
|
24
30
|
end
|
25
31
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tkh_authentication
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-08-
|
12
|
+
date: 2012-08-03 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -171,7 +171,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
171
171
|
version: '0'
|
172
172
|
segments:
|
173
173
|
- 0
|
174
|
-
hash:
|
174
|
+
hash: 4227862360547794696
|
175
175
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
176
176
|
none: false
|
177
177
|
requirements:
|
@@ -180,7 +180,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
180
180
|
version: '0'
|
181
181
|
segments:
|
182
182
|
- 0
|
183
|
-
hash:
|
183
|
+
hash: 4227862360547794696
|
184
184
|
requirements: []
|
185
185
|
rubyforge_project:
|
186
186
|
rubygems_version: 1.8.23
|