Method: Archangel::Backend::ProfilesController#update

Defined in:
app/controllers/archangel/backend/profiles_controller.rb

#updateObject

Update backend profile

Formats

HTML, JSON

Request

PATCH /backend/profile
PUT   /backend/profile.json

Response

{
  "profile": {
    "name": "First Last",
    "username": "my_username"
    "avatar": "local/path/to/new_file.gif"
    "email": "[email protected]"
  }
}


138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
# File 'app/controllers/archangel/backend/profiles_controller.rb', line 138

def update
  empty_password_params if resource_params.fetch(:password, nil).blank?

  profile = resource_content

  successfully_updated =
    if needs_password?(profile, resource_params)
      profile.update(resource_params)
    else
      profile.update_without_password(resource_params)
    end

  reauth_current_user if successfully_updated

  respond_with profile, location: -> { location_after_update }
end