Skip to content

Instantly share code, notes, and snippets.

@donrestarone
Created March 14, 2020 18:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save donrestarone/34a465296602765d4a0cd7e550326086 to your computer and use it in GitHub Desktop.
Save donrestarone/34a465296602765d4a0cd7e550326086 to your computer and use it in GitHub Desktop.
a simple users_controller that creates a user and sends them an email confirmation link
class Api::Core::V1::UsersController < ApplicationController
before_action except: [:create] do
authenticate_token
end
def create
first_name = params["first_name"]
last_name = params["last_name"]
email = params["email"]
phone = params["phone"]
password = params["password"]
password_confirmation = params["password"]
if first_name && last_name && email && password && password_confirmation
user = User.handle_creation(first_name, last_name, email, phone, password, password_confirmation)
if user
EmailConfirmationJob.perform_later(user.id)
render json: {
status: 'OK'
code: 200
}
else
render json: {status: 'error user account not created', code: 400}
end
else
render json: {status: 'specify all required information', code: 422}
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment