# frozen_string_literal: true # Controller for managing sessions for <%= plural_class_name %>. # Automatically generated by the orthodox gem (https://github.com/bodacious/orthodox) class <%= plural_class_name %>::SessionsController < <%= plural_class_name %>::BaseController skip_before_action :authenticate_<%= singular_name %> def new @<%= singular_name %>_session = <%= class_name %>Session.new(<%= singular_name %>_session_params) end def create @<%= singular_name %>_session = <%= class_name %>Session.new(<%= singular_name %>_session_params) if @<%= singular_name %>_session.valid? sign_in(@<%= singular_name %>_session.<%= singular_name %>, as: :<%= singular_name %>) redirect_to(<%= plural_name %>_dashboard_url, notice: "Successfully signed in") else render :new end end def destroy sign_out(:<%= singular_name %>) redirect_to root_url, notice: "Successfully signed out" end private def <%= singular_name %>_session_params return {} unless params.key?(:<%= singular_name %>_session) params.require(:<%= singular_name %>_session).permit(:email, :password) end end