Class: Api::V1::UsersController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/people/api/v1/users_controller.rb

Instance Method Summary collapse

Instance Method Details

#destroyObject

DELETE /api/1/users/1



41
42
43
44
# File 'app/controllers/people/api/v1/users_controller.rb', line 41

def destroy
  @user.destroy
  render json: {}
end

#indexObject

GET /api/1/users



15
16
17
18
# File 'app/controllers/people/api/v1/users_controller.rb', line 15

def index
  @users = ::People::V1::User.all
  render json: @users
end

#showObject

GET /api/1/users/1



21
22
23
# File 'app/controllers/people/api/v1/users_controller.rb', line 21

def show
  render json: @user
end

#updateObject

PATCH/PUT /api/1/users/1



26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'app/controllers/people/api/v1/users_controller.rb', line 26

def update
  change_password
  before_email = @user.email
  if @user.update(user_params)
    if email_changed?(before_email.downcase,@user.email.downcase)
      #The email changed, reconfirm email address
      ::People::AccountMailer.email_confirmation(@user).deliver
    end
    render json: @user
  else
    render :json => {errors: @user.errors.full_messages}, status: :unprocessable_entity
  end
end