auth2接入

This commit is contained in:
xiaoxiaoqiong
2022-06-17 17:02:24 +08:00
parent 66c40d4791
commit 1f9caeece5
8 changed files with 1075 additions and 133 deletions

View File

@@ -671,6 +671,21 @@ class User < Owner
raise text
end
def self.authenticate!(login, password)
user = self.where("login = ? or mail = ? or phone = ? ", login.to_s.gsub(" ",''),login.to_s.gsub(" ",''),login.downcase.to_s.gsub(" ",'')).limit(1).first
return (user.check_password?(password) ? user : nil) unless user.nil?
nil
end
# Generate public/private keys
def generate_keys
key_size = (Rails.env == 'test' ? 512 : 2048)
serialized_private_key = OpenSSL::PKey::RSA::generate(key_size).to_s
serialized_public_key = OpenSSL::PKey::RSA.new(serialized_private_key)
[serialized_private_key, serialized_public_key]
end
def show_real_name
name = lastname + firstname
if name.blank?