Sha256: e7d67a4b48457d4966daf4b4d396bfab659ea875f7b52da88f7527f480b0d177
Contents?: true
Size: 1.04 KB
Versions: 11
Compression:
Stored size: 1.04 KB
Contents
module Applicaster module AuthHelpers def current_user @current_user ||= user_from_session end def user_signed_in? !current_user.nil? end def authenticate_user! unless current_user store_location! redirect_to '/auth/applicaster' end end def current_access_token if credentials = session[:omniauth_credentials] credentials[:token] || credentials["token"] end end protected def store_location! session[:path_before_login] = if request.get? request.fullpath else request.referrer end end def clear_omniauth_credentials session.delete(:omniauth_credentials) end def user_from_session return nil unless current_access_token Applicaster::Accounts.user_from_token(current_access_token).tap do |user| clear_omniauth_credentials unless user end end end end
Version data entries
11 entries across 11 versions & 1 rubygems