Sha256: fa9f69283e32bb63db956253a9d43a3e37a1047e81fa525068136a6399cb119c
Contents?: true
Size: 1.05 KB
Versions: 5
Compression:
Stored size: 1.05 KB
Contents
class SessionManager def set_session session @session = session end def set_cookies cookies @cookies = cookies end def authorize! id @session[:uid] = id @cookies[:uid] = id @cookies[:chk] = (Digest::MD5.new.update "#{CONFIG[:pepper]}#{id}#{CONFIG[:salt]}").to_s end def whoami if @session && @session[:uid] user = UserCard.find(@session[:uid]).userable username = user.name == '' ? "#{user.class.name}##{user.id}" : user.name username << " из компании #{user.company.name}" if user.class.name == 'Manager' && user.company.name username else 'Anonymous' end end def login_data check_login_data @session[:login_data] end def login_data_update account @session[:login_data] = {type: account.class.name, id: account.id} @session[:uid] = account.user_card.id end def check_login_data begin @session[:login_data][:type].constantize.find_by({id: @session[:login_data][:id]}).present? rescue @session[:login_data] = nil end end end
Version data entries
5 entries across 5 versions & 1 rubygems