janus 0.8.0 → 0.8.1

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: db69af223011b34004ed7c3b3d3b0b94d1c143ae
4
- data.tar.gz: 4648e6814dc5578a272ca63d93d021e7d6753e8c
3
+ metadata.gz: cfd15bc79e41899bc65c3eddc3042f11524e4616
4
+ data.tar.gz: f836a95402bb7371fe25d1af49cd5841b74bb6b3
5
5
  SHA512:
6
- metadata.gz: 0ab6bbc22c50eff38c2162aecad2ce3db7a1ba8a21c17cc06a1cb0a96b554bb2322626747176b294a92efd10a0569f7d269244e09a0df6d6a2bbf8ce7dc38d62
7
- data.tar.gz: 23e1f598b215370df21ae5b3e20e10ababf958c275364a717e060f228fa2192f66abe2a0cab981fc63f60b5778403f954da1841a78a25003547458775bfe0927
6
+ metadata.gz: 15d3598d95a4e264a6087fea6244fe4937849c759dca34ffd0377a0764ef1b5a633bb98004e083e7a15136999d8535d71674e1944a9d913799af69ccb9601720
7
+ data.tar.gz: ee62d38fd4070283177a52176ac77525ad0994e991aaa0f579b2e9f559ad4ba38ae0a86c679c42f449825f2979c14cac43cb10b1410387d254a4309699e7983a
checksums.yaml.gz.sig CHANGED
Binary file
data.tar.gz.sig CHANGED
Binary file
data/README.rdoc CHANGED
@@ -25,7 +25,7 @@ As for the strategies and hooks:
25
25
  to keep users signed in across top level domains;
26
26
  - {TokenAuthenticatable}[http://rdoc.info/github/ysbaddaden/janus/Janus/Models/TokenAuthenticatable]
27
27
  to auth users with unique tokens;
28
- - {Confirmable}[http://rdoc.info/github/ysbaddaden/janus/Janus/Models/RemoteAuthenticatable]
28
+ - {Confirmable}[http://rdoc.info/github/ysbaddaden/janus/Janus/Models/Confirmable]
29
29
  to have users confirm their emails upon registration;
30
30
  - {Rememberable}[http://rdoc.info/github/ysbaddaden/janus/Janus/Models/Rememberable]
31
31
  to keep users authentified;
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.8.0
1
+ 0.8.1
@@ -4,6 +4,7 @@
4
4
  <%%= janus_error_messages %>
5
5
 
6
6
  <%%= f.hidden_field :reset_password_token %>
7
+ <%%= hidden_field_tag :return_to, params[:return_to] if params[:return_to] %>
7
8
 
8
9
  <div class="field">
9
10
  <%%= f.label :password %>
@@ -37,7 +37,7 @@ class Janus::ConfirmationsController < ApplicationController
37
37
  self.resource = resource_class.find_for_database_authentication(params[resource_name])
38
38
 
39
39
  if resource
40
- mailer_class.confirmation_instructions(resource).deliver
40
+ deliver_confirmation_instructions
41
41
 
42
42
  respond_to do |format|
43
43
  format.html { redirect_to root_url, :notice => t('flash.janus.confirmations.create.email_sent') }
@@ -55,4 +55,10 @@ class Janus::ConfirmationsController < ApplicationController
55
55
  end
56
56
  end
57
57
  end
58
+
59
+ # Simple wrapper for Mailer#confirmation_instructions.deliver to
60
+ # allow customization of the email (eg: to pass additional data).
61
+ def deliver_confirmation_instructions
62
+ mailer_class.confirmation_instructions(resource).deliver
63
+ end
58
64
  end
@@ -15,7 +15,7 @@ class Janus::PasswordsController < ApplicationController
15
15
 
16
16
  if resource
17
17
  resource.generate_reset_password_token!
18
- mailer_class.reset_password_instructions(resource).deliver
18
+ deliver_reset_password_instructions
19
19
 
20
20
  respond_to do |format|
21
21
  format.html { redirect_to root_url, :notice => t('flash.janus.passwords.create.email_sent') }
@@ -44,7 +44,7 @@ class Janus::PasswordsController < ApplicationController
44
44
  if resource
45
45
  if resource.reset_password!(params[resource_name])
46
46
  respond_to do |format|
47
- format.html { redirect_to root_url, :notice => t('flash.janus.passwords.update.password_updated') }
47
+ format.html { redirect_after_password_change(self.resource, :notice => t('flash.janus.passwords.update.password_updated')) }
48
48
  format.any { head :ok }
49
49
  end
50
50
  else
@@ -60,4 +60,24 @@ class Janus::PasswordsController < ApplicationController
60
60
  end
61
61
  end
62
62
  end
63
+
64
+ # Simple wrapper for Mailer#reset_password_instructions.deliver to
65
+ # allow customization of the email (eg: to pass additional data).
66
+ def deliver_reset_password_instructions
67
+ mailer_class.reset_password_instructions(resource).deliver
68
+ end
69
+
70
+ # Either redirects the user to after_password_change_url or to
71
+ # <tt>params[:return_to]</tt> if present.
72
+ def redirect_after_password_change(user, options = {})
73
+ if params[:return_to].present?
74
+ redirect_to params[:return_to], options
75
+ else
76
+ redirect_to after_password_change_url(user), options
77
+ end
78
+ end
79
+
80
+ def after_password_change_url(user)
81
+ root_url
82
+ end
63
83
  end
data/lib/janus/mailer.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  class Janus::Mailer < ActionMailer::Base
2
- default_from = Janus::Config.contact_email
2
+ default from: Janus::Config.contact_email
3
3
 
4
4
  def reset_password_instructions(user)
5
5
  @user = user
data/lib/janus/routes.rb CHANGED
@@ -67,6 +67,7 @@ module ActionDispatch # :nodoc:
67
67
 
68
68
  resource :confirmation, :only => [:show, :new, :create] if options[:confirmation]
69
69
  resource :password, :except => [:index, :show, :destroy] if options[:password]
70
+ yield if block_given?
70
71
  end
71
72
 
72
73
  ActionController::Base.janus(singular)
@@ -73,7 +73,9 @@ class Users::PasswordsControllerTest < ActionController::TestCase
73
73
  test "should update" do
74
74
  users(:julien).generate_reset_password_token!
75
75
 
76
- put :update, :user => @attributes.merge(:reset_password_token => users(:julien).reset_password_token)
76
+ put :update, :user => @attributes.merge(
77
+ :reset_password_token => users(:julien).reset_password_token
78
+ )
77
79
  assert_redirected_to root_url
78
80
  assert flash[:notice]
79
81
 
@@ -128,4 +130,12 @@ class Users::PasswordsControllerTest < ActionController::TestCase
128
130
  assert_redirected_to root_url
129
131
  assert flash[:alert]
130
132
  end
133
+
134
+ test "should redirect to specified URL" do
135
+ users(:julien).generate_reset_password_token!
136
+ user_params = @attributes.merge(:reset_password_token => users(:julien).reset_password_token)
137
+
138
+ put :update, :user => user_params, :return_to => 'http://example.com/some/path.html'
139
+ assert_redirected_to 'http://example.com/some/path.html'
140
+ end
131
141
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: janus
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.8.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Julien Portalier
@@ -30,7 +30,7 @@ cert_chain:
30
30
  KVqCN//9bevjMk5OiMi9X3Wu/GtVWDwC6OTWFWKd54KgbuWlakO8LC1SMmStnCIF
31
31
  W4qpyMWMZMcB4ZN/0mUVzY5xwrislBtsmQVUSw==
32
32
  -----END CERTIFICATE-----
33
- date: 2014-01-14 00:00:00.000000000 Z
33
+ date: 2014-02-07 00:00:00.000000000 Z
34
34
  dependencies:
35
35
  - !ruby/object:Gem::Dependency
36
36
  name: addressable
@@ -302,7 +302,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
302
302
  version: '0'
303
303
  requirements: []
304
304
  rubyforge_project:
305
- rubygems_version: 2.1.11
305
+ rubygems_version: 2.0.14
306
306
  signing_key:
307
307
  specification_version: 4
308
308
  summary: Authentication engine for Ruby on Rails
metadata.gz.sig CHANGED
Binary file