Installed authentication-zero
This commit is contained in:
30
app/controllers/registrations_controller.rb
Normal file
30
app/controllers/registrations_controller.rb
Normal file
@@ -0,0 +1,30 @@
|
||||
class RegistrationsController < ApplicationController
|
||||
skip_before_action :authenticate
|
||||
|
||||
def new
|
||||
@user = User.new
|
||||
end
|
||||
|
||||
def create
|
||||
@user = User.new(user_params)
|
||||
|
||||
if @user.save
|
||||
session_record = @user.sessions.create!
|
||||
cookies.signed.permanent[:session_token] = { value: session_record.id, httponly: true }
|
||||
|
||||
send_email_verification
|
||||
redirect_to root_path, notice: "Welcome! You have signed up successfully"
|
||||
else
|
||||
render :new, status: :unprocessable_entity
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
def user_params
|
||||
params.permit(:email, :password, :password_confirmation)
|
||||
end
|
||||
|
||||
def send_email_verification
|
||||
UserMailer.with(user: @user).email_verification.deliver_later
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user