From 9b63bf1dfda36c61802165b2683761d2bb0d2110 Mon Sep 17 00:00:00 2001 From: Unathi Chonco Date: Wed, 12 Oct 2016 09:01:57 +0800 Subject: Remove method for regenerating a token, and update `#authenticate`. This change now creates a method `#authenticate_XXX` where XXX is the configured attribute name on `#has_secure_password`. `#authenticate` is now an alias to this method when the attribute name is the default 'password' --- activemodel/CHANGELOG.md | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) (limited to 'activemodel/CHANGELOG.md') diff --git a/activemodel/CHANGELOG.md b/activemodel/CHANGELOG.md index 0721655a9c..21ebe7e9ec 100644 --- a/activemodel/CHANGELOG.md +++ b/activemodel/CHANGELOG.md @@ -1,21 +1,18 @@ * Allows configurable attribute name for `#has_secure_password`. This still defaults to an attribute named 'password', causing no breaking - change. Also includes a convenience method `#regenerate_XXX` where - +XXX+ is the name of the custom attribute name, eg: + change. There is a new method `#authenticate_XXX` where XXX is the + configured attribute name, making the existing `#authenticate` now an + alias for this when the attribute is the default 'password'. + Example: class User < ActiveRecord::Base has_secure_password :activation_token, validations: false end user = User.new() - user.regenerate_activation_token - user.activation_token # => "ME7abXFGvzZWJRVrD6Et0YqAS6Pg2eDo" - user.activation_token_digest # => "$2a$10$0Budk0Fi/k2CDm2PEwa3Be..." - - The existing `#authenticate` method now allows specifying the attribute - to be authenticated, but defaults to 'password', eg: - - user.authenticate('ME7abXFGvzZWJRVrD6Et0YqAS6Pg2eDo', :activation_token) # => user + user.activation_token = "a_new_token" + user.activation_token_digest # => "$2a$10$0Budk0Fi/k2CDm2PEwa3Be..." + user.authenticate_activation_token('a_new_token') # => user *Unathi Chonco* -- cgit v1.2.3