Hack in registration prevention (#37)
All checks were successful
Deploy / deploy (push) Successful in 4m1s

Reviewed-on: #37
This commit is contained in:
Andrew Tomaka 2024-09-08 22:18:56 -04:00
parent eaa1846d42
commit 543a9599e0
4 changed files with 32 additions and 14 deletions

View file

@ -26,7 +26,10 @@ class UsersController < ApplicationController
@user = User.new(user_params)
respond_to do |format|
if @user.save
if ENV["REGISTRATION_ALLOWED"].blank?
format.html { redirect_to new_session_url, alert: "Registration disabled." }
format.json { render json: @user.errors, status: :unprocessable_entity }
elsif @user.save
@session = Session.new(session_params).save
session[:current_user_id] = @session.user_id