1
0
Fork 0
mirror of https://github.com/mastodon/mastodon.git synced 2024-08-20 21:08:15 -07:00
mastodon/app/services/setup_local_account_service.rb

19 lines
505 B
Ruby
Raw Normal View History

2016-02-24 03:57:29 -08:00
class SetupLocalAccountService < BaseService
# Setup an account for a new user instance by generating
# an RSA key pair and a profile
# @param [User] user Unsaved user instance
# @param [String] username
2016-02-22 07:00:20 -08:00
def call(user, username)
user.build_account
user.account.username = username
user.account.domain = nil
keypair = OpenSSL::PKey::RSA.new(2048)
user.account.private_key = keypair.to_pem
user.account.public_key = keypair.public_key.to_pem
user.save!
end
end