Created
March 14, 2020 18:17
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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