20 lines
450 B
Ruby
20 lines
450 B
Ruby
require 'bcrypt'
|
|
require 'securerandom'
|
|
|
|
def create_password_for_user(password)
|
|
return BCrypt::Password.create(password)
|
|
end
|
|
|
|
def check_password_for_user(user_id, entered_password)
|
|
hashed_password = get_user_hashed_password(user_id)
|
|
|
|
if BCrypt::Password.new(hashed_password) == entered_password
|
|
return true
|
|
else
|
|
return false
|
|
end
|
|
end
|
|
|
|
def generate_random_string(length)
|
|
SecureRandom.urlsafe_base64(length)
|
|
end |