The code powering m.abunchtell.com https://m.abunchtell.com
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.
 
 
 
 

24 lines
917 B

  1. # frozen_string_literal: true
  2. class AppSignUpService < BaseService
  3. def call(app, params)
  4. return unless allowed_registrations?
  5. user_params = params.slice(:email, :password, :agreement)
  6. account_params = params.slice(:username)
  7. user = User.create!(user_params.merge(created_by_application: app, password_confirmation: user_params[:password], account_attributes: account_params))
  8. Doorkeeper::AccessToken.create!(application: app,
  9. resource_owner_id: user.id,
  10. scopes: app.scopes,
  11. expires_in: Doorkeeper.configuration.access_token_expires_in,
  12. use_refresh_token: Doorkeeper.configuration.refresh_token_enabled?)
  13. end
  14. private
  15. def allowed_registrations?
  16. Setting.open_registrations && !Rails.configuration.x.single_user_mode
  17. end
  18. end