Sha256: 305032214d1ff0c82366d541dc96360ab7943558cf480031b703af1dc38ba162

Contents?: true

Size: 812 Bytes

Versions: 17

Compression:

Stored size: 812 Bytes

Contents

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

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

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

      def destroy
        sign_out
        redirect_to root_path
      end

      private

      def redirect_if_signed_in
        redirect_to ::Tramway::User.root_path if signed_in?
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
tramway-user-1.0.2 app/controllers/tramway/user/web/sessions_controller.rb
tramway-user-1.0.1.14 app/controllers/tramway/user/web/sessions_controller.rb
tramway-user-1.0.1.13 app/controllers/tramway/user/web/sessions_controller.rb
tramway-user-1.0.1.12 app/controllers/tramway/user/web/sessions_controller.rb
tramway-user-1.0.1.11 app/controllers/tramway/user/web/sessions_controller.rb
tramway-user-1.0.1.10 app/controllers/tramway/user/web/sessions_controller.rb
tramway-user-1.0.1.9 app/controllers/tramway/user/web/sessions_controller.rb
tramway-user-1.0.1.8 app/controllers/tramway/user/web/sessions_controller.rb
tramway-user-1.0.1.7 app/controllers/tramway/user/web/sessions_controller.rb
tramway-user-1.0.1.6 app/controllers/tramway/user/web/sessions_controller.rb
tramway-user-1.0.1.5 app/controllers/tramway/user/web/sessions_controller.rb
tramway-user-1.0.1.4 app/controllers/tramway/user/web/sessions_controller.rb
tramway-user-1.0.1.3 app/controllers/tramway/user/web/sessions_controller.rb
tramway-user-1.0.1.2 app/controllers/tramway/user/web/sessions_controller.rb
tramway-user-1.0.1.1 app/controllers/tramway/user/web/sessions_controller.rb
tramway-user-1.0.1 app/controllers/tramway/user/web/sessions_controller.rb
tramway-user-1.0 app/controllers/tramway/user/web/sessions_controller.rb