simple_user 0.1.3.3 → 0.1.3.8

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.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZTUxMTJkZThjYWIyNjZlZmQwYjFkOGQ0ZmE0Y2NhM2ZiODM4YjI4Yw==
4
+ NDU3ODc3MmFjMDY1MWYxYmNmMDc3ZjVhMjUyMGI0ZTE2MTUyNTEwNg==
5
5
  data.tar.gz: !binary |-
6
- NWIzMWNiMGUyNDk0ZDE1MWYwZjgzMzFmNmJmMDRmZWRmMTEwOWUyYg==
6
+ OTk2ZTIyOWNhMjFkNjU4NTJjMTdmYjcyMzQ0NDExZDJiNzZkNmY2NA==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- NTIxNGJkN2I5MjcxOTkwMjNmYzRlM2VmN2U0ZDFjYjA3N2M0OGNjYjhhNGI2
10
- N2ViMTc4MmUyMmY2NjZlYmIxOWVkYWJhMzNhZTk3Y2I5ZmMxMDk3MjkzNDU1
11
- MzY2NWIzYmY4M2YxM2UwMzlhMGUwNDQ3Nzg5MzU5ZWRjMWRkNTY=
9
+ ZTBkYzJkOTNlZjFkN2ExYWM0NTFhYzQxYmEwMGZlMzNiZTA0M2QxZTJkZGI5
10
+ Njg2NDA5ZWI0ZTUyMDlmYTNlNWJiOGZkM2FjMmIzODIzNzQ0ZTRjMzRkOGM5
11
+ NDgxNDBmMDQzMDY4NWEyODg2YmU5ZmQzOGZiMjM1Y2E4OTEzNzM=
12
12
  data.tar.gz: !binary |-
13
- ZGRmZmE4YzI4ZTNmM2RkZTcxYTM4NGY3NjdlOWE2MWIwNzQ3NTAwNjQwNDg1
14
- YzRjZWFjMzg0OGZjNDczYzk0NDI5MmQ4Y2QzYTU4M2U3ODA5MGQyZjkzZjAx
15
- ZmVjMTg2ZWYxMjA3NGRmZTQ4OWY4ODBkM2UzOGY2MTUyYjE3ZDU=
13
+ YmVkOTU2NWEzZmM4YTU5MmE0M2ZhOWI0MmNmMjc1NzdhMDNjNDdkNjFhNWYx
14
+ YmFlYjQ0ZjZjZWNlYTZiZGMzNDFmNTg1MTdhMmE0ZWE1NTljMjljYmVhYzI4
15
+ MjE4MjM4YThlYjVhNDU5YzkxNTc3YWM0ZDc2MWFkMzA4NzZlNGE=
@@ -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', :git => 'git://github.com/pablomarti/simple_user.git'</tt>
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. Watch the test/dummy for an example of the links
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
@@ -9,8 +9,7 @@ module SimpleUser
9
9
  if resource.banned?
10
10
  sign_out resource
11
11
  flash.delete(:notice)
12
- flash[:error] = "This account has been suspended."
13
- root_path
12
+ flash[:error] = "This account has been suspended."
14
13
  else
15
14
  ENV['ADMIN_PATH']
16
15
  end
@@ -3,5 +3,11 @@ module SimpleUser
3
3
 
4
4
  layout ENV['APPLICATION_LAYOUT']
5
5
 
6
+ before_filter :set_user_return_to
7
+
8
+ def set_user_return_to
9
+ session[:return_to] = request.referer
10
+ end
11
+
6
12
  end
7
13
  end
@@ -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
- redirect_to root_url
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
- redirect_to root_url
17
+ redirect_after_create
18
18
  else
19
19
  flash[:error] = "Error while creating the user account. Please try again."
20
- redirect_to root_url
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
- super
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 in</h2>
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 %>
@@ -1,3 +1,4 @@
1
1
  APPLICATION_LAYOUT: 'application'
2
2
  ADMIN_LAYOUT: 'application'
3
- ADMIN_PATH: '/'
3
+ ADMIN_PATH: '/'
4
+ REDIRECT_USER_AFTER_SIGNIN: 'false'
@@ -1,3 +1,3 @@
1
1
  module SimpleUser
2
- VERSION = "0.1.3.3"
2
+ VERSION = "0.1.3.8"
3
3
  end
@@ -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,4 +1,9 @@
1
1
  class WelcomeController < ApplicationController
2
+
2
3
  def index
3
4
  end
5
+
6
+ def test_redirect
7
+ end
8
+
4
9
  end
@@ -1,6 +1,10 @@
1
- <h2>Sign in</h2>
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>
@@ -2,6 +2,8 @@ Rails.application.routes.draw do
2
2
 
3
3
  mount SimpleUser::Engine => "/simple_user", :as => "simple_user"
4
4
 
5
+ get 'welcome/test_redirect'
6
+
5
7
  root :to => 'welcome#index'
6
8
 
7
9
  end
@@ -0,0 +1,4 @@
1
+ APPLICATION_LAYOUT: 'application'
2
+ ADMIN_LAYOUT: 'application'
3
+ ADMIN_PATH: '/'
4
+ REDIRECT_USER_AFTER_SIGNIN: 'true'
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.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-04-10 00:00:00.000000000 Z
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