Class: JwtAuthEngine::RegistrationsController

Inherits:
ApplicationController show all
Includes:
Serializable, Tokenizable
Defined in:
app/controllers/jwt_auth_engine/registrations_controller.rb

Overview

Signup endpoint for creating new auth model records.

Instance Method Summary collapse

Methods included from ResponseRenderable

#render_internal_server_error, #render_success, #render_unauthorized, #render_validation_error

Instance Method Details

#signupObject

── POST /signup ─────────────────────────────────────────────────────────



12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'app/controllers/jwt_auth_engine/registrations_controller.rb', line 12

def 
  result = SignupService.new(signup_params: ).call

  return render_validation_error(errors: result[:errors]) unless result[:success]

  auth_model_instance = result[JwtAuthEngine.auth_model_name]

  render_success(
    message: 'Signup successful.',
    JwtAuthEngine.auth_model_name => serialize_auth_model_instance(auth_model_instance),
    **issue_tokens(auth_model_instance),
    status: :created
  )
end