Sha256: 1b9aefd4d7f3ecf278f2ddfa9d860388a5055bc9385bc35e309399db9853e868
Contents?: true
Size: 756 Bytes
Versions: 2
Compression:
Stored size: 756 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 else flash.now[:error] = "Email or password is invalid" render "new" end end # Destroys the current session (logout) def destroy session[:user_id] = nil redirect_to root_url end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
lines-engine-1.0.0 | app/controllers/lines/sessions_controller.rb |
lines-engine-0.9.0 | app/controllers/lines/sessions_controller.rb |