if session[:user]
self.current_user = User.where(:id => session[:user]).where("status IN ('active', 'confirmed', 'suspended')").first
- if current_user.status == "suspended"
+ if session[:fingerprint] &&
+ session[:fingerprint] != current_user.fingerprint
+ reset_session
+ self.current_user = nil
+ elsif current_user.status == "suspended"
session.delete(:user)
session_expires_automatically
elsif session[:token]
session[:user] = current_user.id if self.current_user = User.authenticate(:token => session[:token])
end
+
+ session[:fingerprint] = current_user.fingerprint if current_user && session[:fingerprint].nil?
rescue StandardError => e
logger.info("Exception authorizing user: #{e}")
reset_session
if current_user.save
token.destroy
+ session[:fingerprint] = current_user.fingerprint
flash[:notice] = t "users.reset_password.flash changed"
successful_login(current_user)
end
token.destroy
session[:user] = user.id
+ session[:fingerprint] = user.fingerprint
redirect_to referer || welcome_path
end
end
current_user.tokens.delete_all
session[:user] = current_user.id
+ session[:fingerprint] = current_user.fingerprint
redirect_to :action => "account", :display_name => current_user.display_name
elsif token
flash[:error] = t "users.confirm_email.failure"
# process a successful login
def successful_login(user, referer = nil)
session[:user] = user.id
+ session[:fingerprint] = user.fingerprint
session_expires_after 28.days if session[:remember_me]
target = referer || session[:referer] || url_for(:controller => :site, :action => :index)
end
if user.save
+ session[:fingerprint] = user.fingerprint
+
set_locale(true)
if user.new_email.blank? || user.new_email == user.email
#
class User < ApplicationRecord
+ require "digest"
require "xml/libxml"
has_many :traces, -> { where(:visible => true) }
ClientApplication.find_by(:key => application_key).access_token_for_user(self)
end
+ def fingerprint
+ digest = Digest::SHA256.new
+ digest.update(email)
+ digest.update(pass_crypt)
+ digest.hexdigest
+ end
+
private
def set_defaults