simple_user 0.1.3.3 → 0.1.3.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/README.rdoc +4 -2
- data/app/controllers/simple_user/admin_users/sessions_controller.rb +1 -2
- data/app/controllers/simple_user/application_controller.rb +6 -0
- data/app/controllers/simple_user/auth_controller.rb +14 -3
- data/app/controllers/simple_user/users/sessions_controller.rb +13 -2
- data/app/models/simple_user/user.rb +13 -0
- data/app/views/simple_user/users/sessions/new.html.erb +5 -1
- data/lib/generators/simple_user/install/templates/simple_user.yml +2 -1
- data/lib/simple_user/version.rb +1 -1
- data/test/dummy/app/controllers/application_controller.rb +5 -0
- data/test/dummy/app/controllers/welcome_controller.rb +5 -0
- data/test/dummy/app/views/simple_user/users/sessions/new.html.erb +5 -1
- data/test/dummy/app/views/welcome/test_redirect.html.erb +1 -0
- data/test/dummy/config/routes.rb +2 -0
- data/test/dummy/config/simple_user.yml +4 -0
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NDU3ODc3MmFjMDY1MWYxYmNmMDc3ZjVhMjUyMGI0ZTE2MTUyNTEwNg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
OTk2ZTIyOWNhMjFkNjU4NTJjMTdmYjcyMzQ0NDExZDJiNzZkNmY2NA==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZTBkYzJkOTNlZjFkN2ExYWM0NTFhYzQxYmEwMGZlMzNiZTA0M2QxZTJkZGI5
|
10
|
+
Njg2NDA5ZWI0ZTUyMDlmYTNlNWJiOGZkM2FjMmIzODIzNzQ0ZTRjMzRkOGM5
|
11
|
+
NDgxNDBmMDQzMDY4NWEyODg2YmU5ZmQzOGZiMjM1Y2E4OTEzNzM=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
YmVkOTU2NWEzZmM4YTU5MmE0M2ZhOWI0MmNmMjc1NzdhMDNjNDdkNjFhNWYx
|
14
|
+
YmFlYjQ0ZjZjZWNlYTZiZGMzNDFmNTg1MTdhMmE0ZWE1NTljMjljYmVhYzI4
|
15
|
+
MjE4MjM4YThlYjVhNDU5YzkxNTc3YWM0ZDc2MWFkMzA4NzZlNGE=
|
data/README.rdoc
CHANGED
@@ -7,7 +7,7 @@ Make avaiable to your users for loggin with Devise or Facebook, and manage them
|
|
7
7
|
|
8
8
|
== Installation
|
9
9
|
|
10
|
-
1. Add to your gemfile: <tt>gem 'simple_user'
|
10
|
+
1. Add to your gemfile: <tt>gem 'simple_user'</tt>
|
11
11
|
|
12
12
|
2. Run <tt>bundle</tt>
|
13
13
|
|
@@ -19,7 +19,9 @@ Make avaiable to your users for loggin with Devise or Facebook, and manage them
|
|
19
19
|
|
20
20
|
6. Add to your routes.rb: <tt>mount SimpleUser::Engine => "/simple_user", :as => "simple_user"</tt>
|
21
21
|
|
22
|
-
7.
|
22
|
+
7. Add to your application.js: <tt>//= require simple_user/application</tt>
|
23
|
+
|
24
|
+
8. Watch the test/dummy for an example of the links
|
23
25
|
|
24
26
|
|
25
27
|
== TODO
|
@@ -8,19 +8,30 @@ module SimpleUser
|
|
8
8
|
if authentication
|
9
9
|
flash[:notice] = "Signed in successfully."
|
10
10
|
sign_in(:user, authentication.user)
|
11
|
-
|
11
|
+
redirect_after_create
|
12
12
|
else
|
13
13
|
user = User.build_new_auth(auth)
|
14
14
|
if user.save(:validate => false)
|
15
15
|
flash[:notice] = "Account created and signed in successfully."
|
16
16
|
sign_in(:user, user)
|
17
|
-
|
17
|
+
redirect_after_create
|
18
18
|
else
|
19
19
|
flash[:error] = "Error while creating the user account. Please try again."
|
20
|
-
|
20
|
+
redirect_after_create
|
21
21
|
end
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
|
+
def redirect_after_create
|
26
|
+
if ENV['REDIRECT_USER_AFTER_SIGNIN'] == 'false' || !defined? session[:return_to] || session[:return_to] == "/" || session[:return_to].nil?
|
27
|
+
session[:return_to] = "/"
|
28
|
+
redirect_to root_url
|
29
|
+
else
|
30
|
+
return_to = session[:return_to]
|
31
|
+
session[:return_to] = "/"
|
32
|
+
redirect_to return_to
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
25
36
|
end
|
26
37
|
end
|
@@ -1,6 +1,11 @@
|
|
1
1
|
module SimpleUser
|
2
2
|
class Users::SessionsController < Devise::SessionsController
|
3
3
|
|
4
|
+
def new
|
5
|
+
session[:return_to] = "/"
|
6
|
+
super
|
7
|
+
end
|
8
|
+
|
4
9
|
def create
|
5
10
|
self.resource = warden.authenticate!(auth_options)
|
6
11
|
#self.resource = warden.authenticate!(:scope => resource_name, :recall => "#{controller_path}#failure")
|
@@ -14,7 +19,6 @@ module SimpleUser
|
|
14
19
|
#end
|
15
20
|
|
16
21
|
protected
|
17
|
-
|
18
22
|
def after_sign_in_path_for(resource)
|
19
23
|
if resource.banned?
|
20
24
|
sign_out resource
|
@@ -22,7 +26,14 @@ module SimpleUser
|
|
22
26
|
flash[:error] = "This account has been suspended."
|
23
27
|
root_path
|
24
28
|
else
|
25
|
-
|
29
|
+
if ENV['REDIRECT_USER_AFTER_SIGNIN'] == 'false' || !defined? session[:return_to] || session[:return_to] == "/" || session[:return_to].nil?
|
30
|
+
session[:return_to] = "/"
|
31
|
+
super
|
32
|
+
else
|
33
|
+
return_to = session[:return_to]
|
34
|
+
session[:return_to] = "/"
|
35
|
+
return_to
|
36
|
+
end
|
26
37
|
end
|
27
38
|
end
|
28
39
|
|
@@ -80,6 +80,19 @@ module SimpleUser
|
|
80
80
|
!active
|
81
81
|
end
|
82
82
|
|
83
|
+
def social_picture(provider = "facebook", width = 160, height = 129)
|
84
|
+
auth = authentications.where(:provider => provider).first rescue nil
|
85
|
+
|
86
|
+
tmp_image = case provider
|
87
|
+
when "facebook"
|
88
|
+
auth.nil? ? "" : "http://graph.facebook.com/#{auth.uid}/picture?width=#{width}&height=#{height}"
|
89
|
+
else
|
90
|
+
""
|
91
|
+
end
|
92
|
+
|
93
|
+
return tmp_image
|
94
|
+
end
|
95
|
+
|
83
96
|
private
|
84
97
|
def generate_random(str_length)
|
85
98
|
charlist = ("a".."z").to_a + ("A".."Z").to_a + ("0".."9").to_a
|
@@ -1,6 +1,10 @@
|
|
1
|
-
<h2>Sign
|
1
|
+
<h2>Sign In</h2>
|
2
2
|
|
3
3
|
<%= simple_form_for(resource, :as => resource_name, :url => session_path(resource_name)) do |f| %>
|
4
|
+
<% if !flash[:alert].nil? %>
|
5
|
+
<%= flash[:alert] %>
|
6
|
+
<% end %>
|
7
|
+
|
4
8
|
<div class="form-inputs">
|
5
9
|
<%= f.input :username, :required => true, :autofocus => true %>
|
6
10
|
<%= f.input :password, :required => true %>
|
data/lib/simple_user/version.rb
CHANGED
@@ -4,6 +4,11 @@ class ApplicationController < ActionController::Base
|
|
4
4
|
|
5
5
|
#before_filter :authenticate_user!
|
6
6
|
before_filter :banned?
|
7
|
+
before_filter :set_user_return_to
|
8
|
+
|
9
|
+
def set_user_return_to
|
10
|
+
session[:return_to] = request.referer
|
11
|
+
end
|
7
12
|
|
8
13
|
rescue_from CanCan::AccessDenied do |exception|
|
9
14
|
flash[:error] = "Access denied"
|
@@ -1,6 +1,10 @@
|
|
1
|
-
<h2>Sign
|
1
|
+
<h2>Sign In</h2>
|
2
2
|
|
3
3
|
<%= simple_form_for(resource, :as => resource_name, :url => session_path(resource_name)) do |f| %>
|
4
|
+
<% if !flash[:alert].nil? %>
|
5
|
+
<%= flash[:alert] %>
|
6
|
+
<% end %>
|
7
|
+
|
4
8
|
<div class="form-inputs">
|
5
9
|
<%= f.input :username, :required => true, :autofocus => true %>
|
6
10
|
<%= f.input :password, :required => true %>
|
@@ -0,0 +1 @@
|
|
1
|
+
<h1>TEST REDIRECTS</h1>
|
data/test/dummy/config/routes.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simple_user
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.3.
|
4
|
+
version: 0.1.3.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pablo Marti
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-05-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -244,6 +244,7 @@ files:
|
|
244
244
|
- test/dummy/public/422.html
|
245
245
|
- test/dummy/app/views/application/_menu_admin_users.html.erb
|
246
246
|
- test/dummy/app/views/application/_menu_users.html.erb
|
247
|
+
- test/dummy/app/views/welcome/test_redirect.html.erb
|
247
248
|
- test/dummy/app/views/welcome/index.html.erb
|
248
249
|
- test/dummy/app/views/simple_user/application/_menu_admin_users.html.erb
|
249
250
|
- test/dummy/app/views/simple_user/application/_menu_users.html.erb
|
@@ -345,6 +346,7 @@ files:
|
|
345
346
|
- test/dummy/config/initializers/secret_token.rb
|
346
347
|
- test/dummy/config/initializers/wrap_parameters.rb
|
347
348
|
- test/dummy/config/initializers/backtrace_silencers.rb
|
349
|
+
- test/dummy/config/simple_user.yml
|
348
350
|
- test/dummy/config/database.yml
|
349
351
|
- test/dummy/config/routes.rb
|
350
352
|
- test/dummy/config/environments/production.rb
|
@@ -396,6 +398,7 @@ test_files:
|
|
396
398
|
- test/dummy/public/422.html
|
397
399
|
- test/dummy/app/views/application/_menu_admin_users.html.erb
|
398
400
|
- test/dummy/app/views/application/_menu_users.html.erb
|
401
|
+
- test/dummy/app/views/welcome/test_redirect.html.erb
|
399
402
|
- test/dummy/app/views/welcome/index.html.erb
|
400
403
|
- test/dummy/app/views/simple_user/application/_menu_admin_users.html.erb
|
401
404
|
- test/dummy/app/views/simple_user/application/_menu_users.html.erb
|
@@ -497,6 +500,7 @@ test_files:
|
|
497
500
|
- test/dummy/config/initializers/secret_token.rb
|
498
501
|
- test/dummy/config/initializers/wrap_parameters.rb
|
499
502
|
- test/dummy/config/initializers/backtrace_silencers.rb
|
503
|
+
- test/dummy/config/simple_user.yml
|
500
504
|
- test/dummy/config/database.yml
|
501
505
|
- test/dummy/config/routes.rb
|
502
506
|
- test/dummy/config/environments/production.rb
|