Sha256: c9f67f429b5058eec8395dce4717e997b4e41816ead971c8d53ef34b2e9cb958
Contents?: true
Size: 1.19 KB
Versions: 1
Compression:
Stored size: 1.19 KB
Contents
# frozen_string_literal: true # FIXME: configurate load_path load "#{Tramway.root}/app/controllers/tramway/concerns/auth_management.rb" class Tramway::SessionsController < Tramway::ApplicationController before_action :redirect_if_signed_in, except: :destroy # FIXME: should be included in Tramway::ApplicationController include Tramway::Concerns::AuthManagement def new @session_form = Tramway::SessionForm.new Tramway::User.new end def create @session_form = Tramway::SessionForm.new record if @session_form.validate params[:user] sign_in @session_form.model redirect_to root_path else render :new end end def destroy root_path = Tramway::Engine.routes.url_helpers.root_path sign_out redirect_to params[:redirect] || root_path end private def redirect_if_signed_in if params[:model].present? && signed_in? && request.env['PATH_INFO'] != Tramway.root_path_for(current_user.class) redirect_to Tramway.root_path_for(current_user.class) end end def record @record ||= params[:model].constantize.find_by email: params[:user][:email] end def root_path Tramway::Engine.routes.url_helpers.root_path[0..-2] end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
tramway-0.1.2 | app/controllers/tramway/sessions_controller.rb |