sample_rails_tailwind/app/controllers/sessions_controller.rb
songtianlun 97c91fc8f3 refactor: simplify user signup view
- Remove unnecessary turbo frame tag from the signup form
- Directly render the form within the column div

This change simplifies the user signup view by removing the
unneeded turbo frame, which was not contributing to the
functionality. The form is now rendered directly, making the
code cleaner and easier to understand.
2025-01-05 01:41:45 +08:00

27 lines
675 B
Ruby

class SessionsController < ApplicationController
include SessionsHelper
def new
end
def create
user = User.find_by(email: params[:session][:email].downcase)
# if user && user.authenticate(params[:session][:password])
if user&.authenticate(params[:session][:password])
forwarding_url = session[:forwarding_url]
reset_session
params[:session][:remember_me] == "1" ? remember(user) : forget(user)
log_in user
redirect_to forwarding_url || user
else
flash.now[:danger] = "Invalid email/password combination"
render "new"
end
end
def destroy
log_out if logged_in?
redirect_to root_url
end
end