Skip to content
Snippets Groups Projects
Verified Commit 63621996 authored by Björn Geuken's avatar Björn Geuken Committed by Andrej Shadura
Browse files

[api] Use SecureRandom to generate a random fake password

Cherry-pick from 7967fe46
parent d6929fd4
Branches
Tags
1 merge request!21OBS SSO implementation
......@@ -218,14 +218,11 @@ class User < ActiveRecord::Base
end
def self.create_user_with_fake_pw!(attributes = {})
chars = ["A".."Z", "a".."z", "0".."9"].collect(&:to_a).join
fakepw = (1..24).collect { chars[rand(chars.size)] }.pack("a" * 24)
attributes[:password] = fakepw
create!(attributes)
# Generate and store a 24 char fake pw in the OBS DB that no-one knows
password = SecureRandom.base64
create!(attributes.merge(password: password, password_confirmation: password))
end
# This static method tries to find a user with the given login and password
# in the database. Returns the user or nil if he could not be found
def self.find_with_credentials(login, password)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment