Class: Usman::Api::V1::ProfileController
- Inherits:
-
BaseController
- Object
- ActionController::API
- BaseController
- Usman::Api::V1::ProfileController
- Defined in:
- app/controllers/usman/api/v1/profile_controller.rb
Instance Method Summary collapse
Methods included from Usman::ApiHelper
#current_device, #current_user, #require_admin_auth_token, #require_api_token, #require_auth_token, #require_super_admin_auth_token
Instance Method Details
#create_profile ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'app/controllers/usman/api/v1/profile_controller.rb', line 6 def create_profile proc_code = Proc.new do if @current_registration if @current_user @success = false @errors = { heading: I18n.translate("api.profile.user_already_exists.heading"), message: I18n.translate("api.profile.user_already_exists.message") } else @user = User.new @user.name = permitted_params[:name] @user.generate_username_and_password @user.gender = permitted_params[:gender] @user.date_of_birth = permitted_params[:date_of_birth] @user.email = permitted_params[:email] if @user.valid? @current_registration.user = @user @success = true @alert = { heading: I18n.translate("api.profile.profile_created.heading"), message: I18n.translate("api.profile.profile_created.message") } @data = { registration: @reg_data.registration, device: @reg_data.device } else @errors = @user.errors @success = false end end else @success = false @errors = { heading: I18n.translate("api.profile.registration_details_missing.heading"), message: I18n.translate("api.profile.registration_details_missing.message") } end end render_json_response(proc_code) end |