class SessionsController < ApplicationController skip_before_action :authenticate, only: [ :new, :create ] def new end def create Current.user = User.authenticate_by( username: params[:username], password: params[:password], ) if Current.user session[:user_id] = Current.user.id flash[:notice] = t(".success", name: Current.user.first_name) redirect_to :root else flash[:alert] = t(".error") render :new, status: :unprocessable_entity end end def destroy reset_session Current.user = nil flash[:notice] = t(".success") redirect_to login_path end end