mirror of
https://github.com/System-End/hackatime.git
synced 2026-04-19 22:15:14 +00:00
22 lines
544 B
Ruby
22 lines
544 B
Ruby
class ApplicationController < ActionController::Base
|
|
# Only allow modern browsers supporting webp images, web push, badges, import maps, CSS nesting, and CSS :has.
|
|
allow_browser versions: :modern
|
|
|
|
helper_method :current_user, :user_signed_in?
|
|
|
|
private
|
|
|
|
def current_user
|
|
@current_user ||= User.find_by(id: session[:user_id]) if session[:user_id]
|
|
end
|
|
|
|
def user_signed_in?
|
|
!!current_user
|
|
end
|
|
|
|
def authenticate_user!
|
|
unless user_signed_in?
|
|
redirect_to root_path, alert: "Please sign in first!"
|
|
end
|
|
end
|
|
end
|