Newer
Older
Website-backend / db / seeds.rb
@lukas lukas on 9 Apr 2022 808 bytes add quotes for admins
def getHash(password, publicSalt, privateSalt)
    return Digest::SHA256.hexdigest(Digest::SHA256.hexdigest(password + publicSalt) + privateSalt)
end

def createUser(username, password, isAdmin)
    @publicSalt = SecureRandom.hex(64)
    @secretSalt = SecureRandom.hex(64)
    User.create(uuid: SecureRandom.uuid,
                username: username,
                publicSalt: @publicSalt,
                secretSalt: @secretSalt,
                passwordHash: getHash(password, @publicSalt, @secretSalt),
                isAdmin: isAdmin,
                )
end

createUser('admin', 'changeme', true)
createUser('lukas', 'test', false)
Authority.create(name:`hostname`.tr("\n", ''), signature: Rails.application.credentials.secret_key_base)
Authority.create(name: 'thirdParty', signature: 'thirdPartyKKey')