Sha256: f82dd6063a6c7590182c8a496911380f31d7d92fa78df606cb29e0e992c21425
Contents?: true
Size: 799 Bytes
Versions: 32
Compression:
Stored size: 799 Bytes
Contents
# Creates (login) and destroys (logout) sessions require_dependency "lines/application_controller" module Lines class SessionsController < ApplicationController layout "lines/admin" # Renders form for creating a new article def new end # Authenticate user and create a new session. def create user = Lines::User.find_by(email: params[:email]) if user && user.authenticate(params[:password]) session[:user_id] = user.id redirect_to admin_root_url, notice: "Logged in!" else flash.now.alert = "Email or password is invalid" render "new" end end # Destroys the current session (logout) def destroy session[:user_id] = nil redirect_to root_url, notice: "Logged out!" end end end
Version data entries
32 entries across 32 versions & 1 rubygems