Skip to content

Commit

Permalink
implement user controller
Browse files Browse the repository at this point in the history
  • Loading branch information
Austin Kabiru committed Mar 7, 2017
1 parent 340c207 commit e8c09fc
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
class UsersController < ApplicationController

# POST /signup
def create
user = User.new(user_params)
if user.save
# return authenticated token upon signup
auth_token = AuthenticateUser.new(user.email, user.password).call
response = { message: Message.account_created, auth_token: auth_token }
json_response(response, :created)
else
json_response(
{ message: Message.account_not_created },
:unprocessable_entity
)
end
end

private

def user_params
params.permit(
:name,
:email,
:password,
:password_confirmation
)
end
end

0 comments on commit e8c09fc

Please sign in to comment.