Merge branch 'standalone_develop' of https://gitlink.org.cn/Trustie/forgeplus into standalone_develop
This commit is contained in:
commit
6223cf41e2
|
@ -8,6 +8,7 @@ class UsersController < ApplicationController
|
|||
before_action :connect_to_ci_db, only: [:get_user_info]
|
||||
before_action :convert_image!, only: [:update, :update_image]
|
||||
skip_before_action :check_sign, only: [:attachment_show]
|
||||
# before_action :sso_login, only: [:get_user_info]
|
||||
|
||||
def connect_to_ci_db(options={})
|
||||
if !(current_user && !current_user.is_a?(AnonymousUser) && current_user.devops_certification?)
|
||||
|
@ -329,4 +330,36 @@ class UsersController < ApplicationController
|
|||
render_not_found
|
||||
end
|
||||
|
||||
def sso_login
|
||||
if params[:ticket].present? && !current_user.logged? && params[:websiteName].nil?
|
||||
info = Base64.decode64(params[:ticket]) || Base64.decode64(params[:info].gsub(" ", "+")).force_encoding("utf-8")
|
||||
# login 邮箱 手机号 姓名 学校/单位
|
||||
user_info = info.split("&&")
|
||||
# Rails.logger.info("user_info====== #{info}")
|
||||
login = user_info[0]
|
||||
email = user_info[1]
|
||||
phone = user_info[2]
|
||||
real_name = user_info[3]
|
||||
department_name = user_info[4]
|
||||
|
||||
# 没有登录时,新建用户并登录
|
||||
if current_user.logged?
|
||||
user = current_user
|
||||
else
|
||||
user = User.where("login = ? or phone = ? or mail = ? ", "edu_#{login}", phone, email).first
|
||||
unless user
|
||||
ActiveRecord::Base.transaction do
|
||||
phone_rand = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9].sample(4).join
|
||||
user_params = { status: 1, type: 'User', login: "e_#{login}", lastname: "#{real_name}", mail: "#{email}",
|
||||
nickname: "#{real_name}", professional_certification: 0, certification: 0, grade: 0,
|
||||
password: "12345678", phone: "#{phone_rand}", profile_completed: 1 }
|
||||
user = User.create!(user_params)
|
||||
UserExtension.create!(user_id: user.id, gender: 1, custom_department: "#{department_name}")
|
||||
end
|
||||
end
|
||||
successful_authentication(user)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
|
@ -103,13 +103,13 @@ module ApplicationHelper
|
|||
timeIntoFormat = timePassed / ONE_MINUTE
|
||||
updateAtValue = timeIntoFormat.to_s + "分钟前"
|
||||
elsif (timePassed < ONE_DAY)
|
||||
timeIntoFormat = timePassed / ONE_HOUR
|
||||
timeIntoFormat = (timePassed.to_f / ONE_HOUR).ceil
|
||||
updateAtValue = timeIntoFormat.to_s + "小时前"
|
||||
elsif (timePassed < ONE_MONTH)
|
||||
timeIntoFormat = timePassed / ONE_DAY
|
||||
timeIntoFormat = (timePassed.to_f / ONE_DAY).ceil
|
||||
updateAtValue = timeIntoFormat.to_s + "天前"
|
||||
elsif (timePassed < ONE_YEAR)
|
||||
timeIntoFormat = timePassed / ONE_MONTH
|
||||
timeIntoFormat = (timePassed.to_f / ONE_MONTH).ceil
|
||||
updateAtValue = timeIntoFormat.to_s + "个月前"
|
||||
else
|
||||
timeIntoFormat = timePassed / ONE_YEAR
|
||||
|
|
Loading…
Reference in New Issue