You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

18 lines
505 B

  1. class SetupLocalAccountService < BaseService
  2. # Setup an account for a new user instance by generating
  3. # an RSA key pair and a profile
  4. # @param [User] user Unsaved user instance
  5. # @param [String] username
  6. def call(user, username)
  7. user.build_account
  8. user.account.username = username
  9. user.account.domain = nil
  10. keypair = OpenSSL::PKey::RSA.new(2048)
  11. user.account.private_key = keypair.to_pem
  12. user.account.public_key = keypair.public_key.to_pem
  13. user.save!
  14. end
  15. end