You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
677 B
36 lines
677 B
class ApplicationController < ActionController::Base
|
|
# Prevent CSRF attacks by raising an exception.
|
|
# For APIs, you may want to use :null_session instead.
|
|
protect_from_forgery with: :exception
|
|
|
|
helper_method :current_user
|
|
|
|
def welcome
|
|
render '/welcome'
|
|
end
|
|
|
|
def amiloggedin
|
|
amiloggedin = !!session[:current_user_id]
|
|
|
|
render json: current_user
|
|
end
|
|
|
|
private
|
|
|
|
def current_user
|
|
if session[:current_user_id]
|
|
@current_user ||= User.find(session[:current_user_id])
|
|
else
|
|
@current_user = false
|
|
end
|
|
end
|
|
|
|
def logged_in?
|
|
!!current_user
|
|
end
|
|
|
|
def require_current_user
|
|
redirect_to root_path unless logged_in?
|
|
end
|
|
end
|