Sha256: a24e8f22560b19044cb0a7ca8249a07c48268f153962f9120f46ef37227b56f5

Contents?: true

Size: 784 Bytes

Versions: 1

Compression:

Stored size: 784 Bytes

Contents

module TinyCore
  module Controllers
    module UserSessions
      def self.included(receiver)
        receiver.before_filter :guest_required, :only => [ :new, :create ]
        receiver.skip_before_filter :verify_authenticity_token, :only => :create
      end

      def new
        @user_session = UserSession.new
      end

      def create
        @user_session = UserSession.new(params[:user_session])
        if @user_session.save
          flash[:notice] = I18n.t("flash.notice.logged_in")
          redirect_back_or_default root_path
        else
          render :action => :new
        end
      end

      def destroy
        current_user_session.destroy
        flash[:notice] = I18n.t("flash.notice.logged_out")
        redirect_to login_path
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
tiny_core_users-0.0.1 lib/tiny_core/controllers/user_sessions.rb