Implement advanced login
{{ resolvedDiscussionCount }}/{{ discussionCount }} {{ resolvedCountText }} resolved
-
-
-
-
9 11 10 12 has_secure_password 11 13 12 def User.digest(string) 13 cost = ActiveModel::SecurePassword.min_cost ? BCrypt::Engine::MIN_COST : BCrypt::Engine.cost 14 BCrypt::Password.create(string, cost: cost) 15 end 14 # Returns the hash digest of the given string. 15 def User.digest(string) 16 cost = ActiveModel::SecurePassword.min_cost ? BCrypt::Engine::MIN_COST : BCrypt::Engine.cost 17 BCrypt::Password.create(string, cost: cost) 18 end 19 -
-
63 62 end 64 63 65 64 test "password should be present (nonblank)" do 66 @user.password = @user.password_confirmation = " " * 6 65 @user.password = @user.password_confirmation = "" * 6 -
Master
sao lại thay đổi test case vậy em
-
-
-
-
-
-
14 class << self 15 # Returns the hash digest of the given string. 16 def digest(string) 17 cost = ActiveModel::SecurePassword.min_cost ? BCrypt::Engine::MIN_COST : BCrypt::Engine.cost 18 BCrypt::Password.create(string, cost: cost) 19 end 20 21 # Returns a random token. 22 def new_token 23 SecureRandom.urlsafe_base64 24 end 15 25 end 26 27 # Remembers a user in the database for use in persistent sessions 28 def remember 29 self.remember_token = User.new_token -
MasterEdited by Son Do Hong
Trong class nên gọi là
self.class.new_tokenthay vì gọi tên classUser.new_token -
-
-
15 # Returns the hash digest of the given string. 16 def digest(string) 17 cost = ActiveModel::SecurePassword.min_cost ? BCrypt::Engine::MIN_COST : BCrypt::Engine.cost 18 BCrypt::Password.create(string, cost: cost) 19 end 20 21 # Returns a random token. 22 def new_token 23 SecureRandom.urlsafe_base64 24 end 15 25 end 26 27 # Remembers a user in the database for use in persistent sessions 28 def remember 29 self.remember_token = User.new_token 30 update_attribute(:remember_digest, User.digest(remember_token)) -
Master
tương tự comment trên
-
-
-
Toggle commit list
-
16 def digest(string) 17 cost = ActiveModel::SecurePassword.min_cost ? BCrypt::Engine::MIN_COST : BCrypt::Engine.cost 18 BCrypt::Password.create(string, cost: cost) 19 end 20 21 # Returns a random token. 22 def new_token 23 SecureRandom.urlsafe_base64 24 end 15 25 end 26 27 # Remembers a user in the database for use in persistent sessions 28 def remember 29 self.remember_token = self.class.new_token 30 update_attribute(:remember_digest, self.class.digest(remember_token)) 31 #BCrypt::Password.new(remember_digest).is_password?(remember_token) -
Master
remove comment
-
-
-
-
merged
Toggle commit list