Sha256: 4a3eb326409924db73c6be659a188ffa175195f6b1a9e2efa3231f7cae3b57eb

Contents?: true

Size: 909 Bytes

Versions: 6

Compression:

Stored size: 909 Bytes

Contents

module Tramway::Auth
  module Web
    class SessionsController < ::Tramway::Auth::Web::ApplicationController
      before_action :redirect_if_signed_in, except: :destroy

      def new
        @session_form = ::Tramway::Auth::SessionForm.new ::Tramway::User::User.new
      end

      def create
        @session_form = ::Tramway::Auth::SessionForm.new ::Tramway::User::User.active.find_or_initialize_by email: params[:user][:email]
        if @session_form.validate params[:user]
          sign_in @session_form.model
          redirect_to ::Tramway::Auth.root_path
        else
          render :new
        end
      end

      def destroy
        sign_out
        redirect_to ::Tramway::Auth.root_path
      end

      private

      def redirect_if_signed_in
        redirect_to ::Tramway::Auth.root_path if signed_in? && request.env['PATH_INFO'] != ::Tramway::Auth.root_path
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
tramway-auth-1.1.0.1 app/controllers/tramway/auth/web/sessions_controller.rb
tramway-auth-1.1 app/controllers/tramway/auth/web/sessions_controller.rb
tramway-auth-1.0.2.1 app/controllers/tramway/auth/web/sessions_controller.rb
tramway-auth-1.0.2 app/controllers/tramway/auth/web/sessions_controller.rb
tramway-auth-1.0.1.2 app/controllers/tramway/auth/web/sessions_controller.rb
tramway-auth-1.0.1.1 app/controllers/tramway/auth/web/sessions_controller.rb