mirror of
https://gitlink.org.cn/Gitlink/forgeplus.git
synced 2026-05-03 03:40:49 +08:00
auth2接入
This commit is contained in:
@@ -265,9 +265,11 @@ class ApplicationController < ActionController::Base
|
||||
end
|
||||
end
|
||||
|
||||
# if !User.current.logged? && Rails.env.development?
|
||||
# User.current = User.find 1
|
||||
# end
|
||||
if !User.current.logged? && Rails.env.development?
|
||||
user = User.find 1
|
||||
User.current = user
|
||||
start_user_session(user)
|
||||
end
|
||||
|
||||
|
||||
# 测试版前端需求
|
||||
|
||||
@@ -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?
|
||||
|
||||
Reference in New Issue
Block a user