2018-02-16 15:02:03 +00:00
|
|
|
class UsersController < ApplicationController
|
|
|
|
|
skip_before_action :authorize_request, only: :create
|
2018-02-19 16:03:07 +00:00
|
|
|
before_action :set_user, only: [:show]
|
|
|
|
|
|
2018-02-16 15:02:03 +00:00
|
|
|
# POST /signup
|
|
|
|
|
# return authenticated token upon signup
|
|
|
|
|
def create
|
|
|
|
|
user = User.create!(user_params)
|
|
|
|
|
auth_token = AuthenticateUser.new(user.email, user.password).call
|
|
|
|
|
response = { message: Message.account_created, auth_token: auth_token }
|
|
|
|
|
json_response(response, :created)
|
|
|
|
|
end
|
|
|
|
|
|
2018-02-19 16:03:07 +00:00
|
|
|
def show
|
|
|
|
|
json_response(@user)
|
|
|
|
|
end
|
|
|
|
|
|
2018-02-16 15:02:03 +00:00
|
|
|
private
|
|
|
|
|
|
|
|
|
|
def user_params
|
|
|
|
|
params.permit(
|
|
|
|
|
:name,
|
|
|
|
|
:email,
|
|
|
|
|
:password,
|
|
|
|
|
:password_confirmation
|
|
|
|
|
)
|
|
|
|
|
end
|
2018-02-19 16:03:07 +00:00
|
|
|
def set_user
|
|
|
|
|
@user = User.find(params[:id])
|
|
|
|
|
end
|
2018-02-16 15:02:03 +00:00
|
|
|
end
|