Class: Auth::RegistrationsController
- Inherits:
-
Devise::RegistrationsController
- Object
- Devise::RegistrationsController
- Auth::RegistrationsController
- Includes:
- Concerns::TokenConcern
- Defined in:
- app/controllers/auth/registrations_controller.rb
Constant Summary collapse
- TCONDITIONS =
{:only => [:update,:destroy]}
Instance Method Summary collapse
-
#authenticate_scope! ⇒ Object
only required in case of registrations controller, for the update action, and destroy actions, wherein we need to make sure that the resource is authenticated before doing anything.
- #create {|resource| ... } ⇒ Object
-
#respond_with(*args) ⇒ Object
had to do this, cuz after update, the authentication token changes, and that needs to be communicated back to the client, or they will never be able to update or access the resource again.
- #respond_with_navigational(*args, &block) ⇒ Object
- #update {|resource| ... } ⇒ Object
Instance Method Details
#authenticate_scope! ⇒ Object
only required in case of registrations controller, for the update action, and destroy actions, wherein we need to make sure that the resource is authenticated before doing anything. have overridden the devise method here. it has nothing to do with the simple_token_authentication being done in other controllers. this was just done here because we cannot add simple_token_authentication to a devise controller.
93 94 95 96 97 98 |
# File 'app/controllers/auth/registrations_controller.rb', line 93 def authenticate_scope! do_before_request end |
#create {|resource| ... } ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'app/controllers/auth/registrations_controller.rb', line 10 def create check_recaptcha build_resource(sign_up_params) resource.m_client = self.m_client resource.set_client_authentication resource.save yield resource if block_given? if resource.persisted? if resource.active_for_authentication? :notice, :signed_up sign_up(resource_name, resource) respond_with resource, location: after_sign_up_path_for(resource) else :notice, :"signed_up_but_#{resource.}" expire_data_after_sign_in! respond_with resource, location: after_inactive_sign_up_path_for(resource) end else clean_up_passwords resource set_minimum_password_length respond_with resource end end |
#respond_with(*args) ⇒ Object
had to do this, cuz after update, the authentication token changes, and that needs to be communicated back to the client, or they will never be able to update or access the resource again.
66 67 68 69 70 71 72 73 74 75 76 |
# File 'app/controllers/auth/registrations_controller.rb', line 66 def respond_with(*args) if is_json_request? if args[0] && args[0].respond_to?(:authentication_token) render :json => args[0] else super(*args) end else super(*args) end end |
#respond_with_navigational(*args, &block) ⇒ Object
78 79 80 81 82 83 84 85 86 |
# File 'app/controllers/auth/registrations_controller.rb', line 78 def (*args, &block) if is_json_request? respond_with(*args) else respond_with(*args) do |format| format.any(*, &block) end end end |
#update {|resource| ... } ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'app/controllers/auth/registrations_controller.rb', line 39 def update check_recaptcha self.resource = resource_class.to_adapter.get!(send(:"current_#{resource_name}").to_key) prev_unconfirmed_email = resource.unconfirmed_email if resource.respond_to?(:unconfirmed_email) ## added these two lines resource.m_client = self.m_client resource.set_client_authentication ## end. resource_updated = update_resource(resource, account_update_params) yield resource if block_given? if resource_updated if is_flashing_format? flash_key = update_needs_confirmation?(resource, prev_unconfirmed_email) ? :update_needs_confirmation : :updated :notice, flash_key end sign_in resource_name, resource, bypass: true respond_with resource, location: after_update_path_for(resource) else clean_up_passwords resource respond_with resource end end |