# class SessionsController

START:setup

### Public Instance Methods

create() click to toggle source

START:login

    # File app/controllers/sessions_controller.rb, line 11
      def create
        user = User.find_by(name: params[:name])
        if user and user.authenticate(params[:password])
          session[:user_id] = user.id
          redirect_to admin_url
        else
          redirect_to login_url, alert: "Invalid user/password combination"
        end
      end

destroy() click to toggle source

START:logout

    # File app/controllers/sessions_controller.rb, line 25
      def destroy
        session[:user_id] = nil
        redirect_to store_url, notice: "Logged out"
      end

new() click to toggle source

    # File app/controllers/sessions_controller.rb, line 7
    def new
    end