generated from espoo-dev/rails_boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathusers_controller.rb
More file actions
41 lines (31 loc) · 853 Bytes
/
users_controller.rb
File metadata and controls
41 lines (31 loc) · 853 Bytes
1
2
3
4
5
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
# frozen_string_literal: true
module Api
module V1
class UsersController < ApiController
def index
users = User.page(page).per(per_page)
authorize(users)
render json: users, status: :ok
end
def destroy_self
authorize(current_user)
result = Users::DestroySelf.result(user: current_user, password: confirmation_password)
if result.success?
render json: { message: "Account deleted successfully" }, status: :ok
else
render json: { error: "Unable to delete account. Error: #{result.error}" }, status: :unprocessable_entity
end
end
private
def page
params[:page]
end
def per_page
params[:per_page]
end
def confirmation_password
params[:password]
end
end
end
end