Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Deprecated User#remember_me! for User#reset_remember_token!

  • Loading branch information...
commit 58e05e2e4fd960320bdf420e26e275d6d79a3c45 1 parent 9b091f5
@rmm5t rmm5t authored
View
2  lib/clearance/authentication.rb
@@ -62,7 +62,7 @@ def authenticate
# sign_in(@user)
def sign_in(user)
if user
- user.remember_me!
+ user.reset_remember_token!
cookies[:remember_token] = {
:value => user.remember_token,
:expires => 1.year.from_now.utc
View
22 lib/clearance/user.rb
@@ -87,14 +87,18 @@ def authenticated?(password)
# Set the remember token.
#
- # @example
- # user.remember_me!
- # cookies[:remember_token] = {
- # :value => user.remember_token,
- # :expires => 1.year.from_now.utc
- # }
+ # @deprecated Use {#reset_remember_token!} instead
def remember_me!
- self.remember_token = encrypt("--#{Time.now.utc}--#{password}--#{id}--")
+ warn "[DEPRECATION] remember_me!: use reset_remember_token! instead"
+ reset_remember_token!
+ end
+
+ # Reset the remember token.
+ #
+ # @example
+ # user.reset_remember_token!
+ def reset_remember_token!
+ generate_remember_token
save(false)
end
@@ -157,6 +161,10 @@ def generate_confirmation_token
self.confirmation_token = encrypt("--#{Time.now.utc}--#{password}--")
end
+ def generate_remember_token
+ self.remember_token = encrypt("--#{Time.now.utc}--#{encrypted_password}--#{id}--")
+ end
+
def initialize_confirmation_token
generate_confirmation_token if new_record?
end
View
6 test/models/user_test.rb
@@ -120,13 +120,13 @@ def @user.initialize_salt; end
end
end
- # remember me
+ # resetting remember token
- context "When authenticating with remember_me!" do
+ context "When resetting authentication with reset_remember_token!" do
setup do
@user = Factory(:email_confirmed_user)
assert_nil @user.remember_token
- @user.remember_me!
+ @user.reset_remember_token!
end
should "set the remember token" do
Please sign in to comment.
Something went wrong with that request. Please try again.