mirror of
https://gitlink.org.cn/Gitlink/forgeplus.git
synced 2026-05-03 03:40:49 +08:00
Merge branch 'standalone_develop' into pm_project_develop
This commit is contained in:
@@ -23,10 +23,23 @@ class Admins::BaseController < ApplicationController
|
||||
def require_admin!
|
||||
return if current_user.blank? || !current_user.logged?
|
||||
return if current_user.admin_or_business?
|
||||
return if current_user.admin_or_glcc_admin?
|
||||
|
||||
render_forbidden
|
||||
end
|
||||
|
||||
def require_admin
|
||||
render_forbidden unless User.current.admin?
|
||||
end
|
||||
|
||||
def require_business
|
||||
render_forbidden unless admin_or_business?
|
||||
end
|
||||
|
||||
def require_glcc_admin
|
||||
render_forbidden unless admin_or_glcc_admin?
|
||||
end
|
||||
|
||||
# 触发after ajax render partial hooks,执行一些因为局部刷新后失效的绑定事件
|
||||
def rebind_event_if_ajax_render_partial
|
||||
return if request.format.symbol != :js
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
class Admins::EduSettingsController < Admins::BaseController
|
||||
before_action :require_admin
|
||||
before_action :find_setting, only: [:edit,:update, :destroy]
|
||||
|
||||
def index
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
class Admins::FaqsController < Admins::BaseController
|
||||
before_action :require_business
|
||||
before_action :find_faq, only: [:edit,:update, :destroy]
|
||||
|
||||
def index
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
class Admins::FeedbacksController < Admins::BaseController
|
||||
before_action :require_business
|
||||
before_action :get_feedback, only: [:new_history, :create_history, :destroy]
|
||||
|
||||
def index
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
class Admins::GlccPrCheckController < Admins::BaseController
|
||||
before_action :require_glcc_admin
|
||||
|
||||
def index
|
||||
params[:sort_by] = params[:sort_by].presence || 'created_on'
|
||||
params[:sort_direction] = params[:sort_direction].presence || 'desc'
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
class Admins::IdentityVerificationsController < Admins::BaseController
|
||||
before_action :require_business
|
||||
before_action :finder_identity_verification, except: [:index]
|
||||
def index
|
||||
params[:sort_by] = params[:sort_by].presence || 'created_at'
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
class Admins::IssuesRankController < Admins::BaseController
|
||||
before_action :require_admin
|
||||
|
||||
def index
|
||||
@statistics = DailyProjectStatistic.where('date >= ? AND date <= ?', begin_date, end_date)
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
class Admins::LaboratoriesController < Admins::BaseController
|
||||
before_action :require_admin
|
||||
def index
|
||||
default_sort('id', 'desc')
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
class Admins::MessageTemplatesController < Admins::BaseController
|
||||
before_action :require_admin
|
||||
before_action :get_template, only: [:edit, :update, :destroy]
|
||||
|
||||
def index
|
||||
@@ -7,12 +8,12 @@ class Admins::MessageTemplatesController < Admins::BaseController
|
||||
end
|
||||
|
||||
def new
|
||||
@message_template = MessageTemplate.new
|
||||
@message_template = MessageTemplate::CustomTip.new
|
||||
end
|
||||
|
||||
def create
|
||||
@message_template = MessageTemplate::CustomTip.new(message_template_params)
|
||||
@message_template.type = "MessageTemplate::CustomTip"
|
||||
def create
|
||||
@message_template = MessageTemplate::CustomTip.new
|
||||
@message_template.attributes = message_template_params
|
||||
if @message_template.save!
|
||||
redirect_to admins_message_templates_path
|
||||
flash[:success] = "创建消息模板成功"
|
||||
@@ -47,9 +48,7 @@ class Admins::MessageTemplatesController < Admins::BaseController
|
||||
|
||||
private
|
||||
def message_template_params
|
||||
# type = @message_template.present? ? @message_template.type : "MessageTemplate::CustomTip"
|
||||
# params.require(type.split("::").join("_").underscore.to_sym).permit!
|
||||
params.require(:message_template_custom_tip).permit!
|
||||
params.require(@message_template.type.split("::").join("_").underscore.to_sym).permit!
|
||||
end
|
||||
|
||||
def get_template
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
class Admins::NpsController < Admins::BaseController
|
||||
before_action :require_business
|
||||
def index
|
||||
@on_off_switch = EduSetting.get("nps-on-off-switch").to_s == 'true'
|
||||
@user_nps = UserNp.joins(:user).order(created_at: :desc)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
class Admins::OrganizationsController < Admins::BaseController
|
||||
before_action :finder_org, except: [:index]
|
||||
before_action :require_admin
|
||||
before_action :finder_org, except: [:index]
|
||||
|
||||
def index
|
||||
params[:sort_by] = params[:sort_by].presence || 'created_on'
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
class Admins::PageThemesController < Admins::BaseController
|
||||
before_action :require_admin
|
||||
before_action :finder_page_theme, only: [:edit, :update, :destroy]
|
||||
|
||||
def index
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
class Admins::ProjectCategoriesController < Admins::BaseController
|
||||
before_action :require_admin
|
||||
before_action :get_category, only: [:edit,:update, :destroy]
|
||||
before_action :validate_names, only: [:create, :update]
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
class Admins::ProjectIgnoresController < Admins::BaseController
|
||||
before_action :require_admin
|
||||
before_action :set_ignore, only: [:edit,:update, :destroy,:show]
|
||||
# before_action :validate_params, only: [:create, :update]
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
class Admins::ProjectLanguagesController < Admins::BaseController
|
||||
before_action :require_admin
|
||||
before_action :get_language, only: [:edit,:update, :destroy]
|
||||
before_action :validate_names, only: [:create, :update]
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
class Admins::ProjectLicensesController < Admins::BaseController
|
||||
before_action :require_admin
|
||||
before_action :set_license, only: [:edit,:update, :destroy,:show]
|
||||
# before_action :validate_params, only: [:create, :update]
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
class Admins::ProjectsController < Admins::BaseController
|
||||
before_action :require_admin
|
||||
before_action :find_project, only: [:edit, :update]
|
||||
|
||||
def index
|
||||
@@ -32,7 +33,7 @@ class Admins::ProjectsController < Admins::BaseController
|
||||
def destroy
|
||||
project = Project.find_by!(id: params[:id])
|
||||
ActiveRecord::Base.transaction do
|
||||
Gitea::Repository::DeleteService.new(project.owner, project.identifier).call
|
||||
Gitea::Repository::DeleteService.new(project.owner, project.identifier, current_user.gitea_token).call
|
||||
project.destroy!
|
||||
# render_delete_success
|
||||
UserAction.create(action_id: project.id, action_type: "DestroyProject", user_id: current_user.id, :ip => request.remote_ip, data_bank: project.attributes.to_json)
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
class Admins::ProjectsRankController < Admins::BaseController
|
||||
before_action :require_admin
|
||||
|
||||
def index
|
||||
@statistics = DailyProjectStatistic.where("date >= ? AND date <= ?", begin_date, end_date)
|
||||
@statistics = @statistics.group(:project_id).select("project_id,
|
||||
@@ -10,7 +12,7 @@ class Admins::ProjectsRankController < Admins::BaseController
|
||||
sum(issues) as issues,
|
||||
sum(pullrequests) as pullrequests,
|
||||
sum(commits) as commits").includes(:project)
|
||||
@statistics = @statistics.order("#{sort_by} #{sort_direction}")
|
||||
@statistics = paginate @statistics.order("#{sort_by} #{sort_direction}")
|
||||
export_excel(@statistics.limit(50))
|
||||
end
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
class Admins::ReversedKeywordsController < Admins::BaseController
|
||||
before_action :require_admin
|
||||
before_action :get_keyword, only: [:edit,:update, :destroy]
|
||||
# before_action :validate_identifer, only: [:create, :update]
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
class Admins::SitePagesController < Admins::BaseController
|
||||
before_action :require_admin
|
||||
before_action :finder_site_page, except: [:index]
|
||||
|
||||
def index
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
class Admins::SitesController < Admins::BaseController
|
||||
before_action :require_admin
|
||||
before_action :find_site, only: [:edit,:update, :destroy]
|
||||
|
||||
def index
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
class Admins::SystemNotificationsController < Admins::BaseController
|
||||
before_action :require_business
|
||||
before_action :get_notification, only: [:history, :edit,:update, :destroy]
|
||||
# before_action :validate_identifer, only: [:create, :update]
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
class Admins::Topic::ActivityForumsController < Admins::Topic::BaseController
|
||||
before_action :require_business
|
||||
before_action :find_activity_forum, only: [:edit, :update, :destroy]
|
||||
|
||||
def index
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
class Admins::Topic::BannersController < Admins::Topic::BaseController
|
||||
before_action :require_business
|
||||
before_action :find_banner, only: [:edit, :update, :destroy]
|
||||
|
||||
def index
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
class Admins::Topic::CardsController < Admins::Topic::BaseController
|
||||
before_action :require_business
|
||||
before_action :find_card, only: [:edit, :update, :destroy]
|
||||
|
||||
def index
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
class Admins::Topic::CooperatorsController < Admins::Topic::BaseController
|
||||
before_action :require_business
|
||||
before_action :find_cooperator, only: [:edit, :update, :destroy]
|
||||
|
||||
def index
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
class Admins::Topic::ExcellentProjectsController < Admins::Topic::BaseController
|
||||
before_action :require_business
|
||||
before_action :find_excellent_project, only: [:edit, :update, :destroy]
|
||||
|
||||
def index
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
class Admins::Topic::ExperienceForumsController < Admins::Topic::BaseController
|
||||
before_action :require_business
|
||||
before_action :find_experience_forum, only: [:edit, :update, :destroy]
|
||||
|
||||
def index
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
class Admins::Topic::GlccNewsController < Admins::Topic::BaseController
|
||||
before_action :require_glcc_admin
|
||||
before_action :find_glcc, only: [:edit, :update, :destroy]
|
||||
|
||||
def index
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
class Admins::Topic::PinnedForumsController < Admins::Topic::BaseController
|
||||
before_action :require_business
|
||||
before_action :find_pinned_forum, only: [:edit, :update, :destroy]
|
||||
|
||||
def index
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
class Admins::UsersController < Admins::BaseController
|
||||
before_action :require_admin
|
||||
before_action :finder_user, except: [:index]
|
||||
|
||||
def index
|
||||
@@ -73,6 +74,6 @@ class Admins::UsersController < Admins::BaseController
|
||||
def update_params
|
||||
params.require(:user).permit(%i[lastname nickname gender technical_title is_shixun_marker
|
||||
mail phone location location_city school_id department_id admin
|
||||
password login website_permission])
|
||||
password login website_permission business glcc_admin])
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
class Admins::UsersRankController < Admins::BaseController
|
||||
before_action :require_admin
|
||||
|
||||
def index
|
||||
@rank_date = rank_date
|
||||
|
||||
52
app/controllers/api/v1/projects/portrait_controller.rb
Normal file
52
app/controllers/api/v1/projects/portrait_controller.rb
Normal file
@@ -0,0 +1,52 @@
|
||||
class Api::V1::Projects::PortraitController < Api::V1::BaseController
|
||||
before_action :require_public_and_member_above
|
||||
|
||||
def index
|
||||
platform_statistic = $redis_cache.hgetall("v2-platform-statistic")
|
||||
|
||||
# 社区影响力
|
||||
praise_count = PraiseTread.where(praise_tread_object_type: "Project", praise_tread_object_id: @project.id).count
|
||||
watcher_count = Watcher.where(watchable_type:"Project", watchable_id: @project.id).count
|
||||
fork_count = ForkUser.where(project_id: @project.id).count
|
||||
community_impact_praise = platform_statistic['max-praise-count'].to_i == 0 ? 0 : 30*(praise_count.to_f/platform_statistic['max-praise-count'].to_i)
|
||||
community_impact_watcher = platform_statistic['max-watcher-count'].to_i == 0 ? 0 : 30*(watcher_count.to_f/platform_statistic['max-watcher-count'].to_i)
|
||||
community_impact_fork = platform_statistic['max-fork-count'].to_i == 0 ? 0 : 40*(fork_count.to_f/platform_statistic['max-fork-count'].to_i)
|
||||
community_impact = format("%.2f", community_impact_praise + community_impact_watcher + community_impact_fork)
|
||||
|
||||
# 项目成熟度
|
||||
pullrequest_count = PullRequest.where(project_id: @project.id).count
|
||||
issue_count = Issue.issue_issue.where(project_id: @project.id).count
|
||||
commit_count = CommitLog.joins(:project).merge(Project.common).where(project_id: @project.id).count
|
||||
project_maturity_pullrequest = platform_statistic['max-pullrequest-count'].to_i == 0 ? 0 : 30*(pullrequest_count.to_f/platform_statistic['max-pullrequest-count'].to_i)
|
||||
project_maturity_issue = platform_statistic['max-issue-count'].to_i == 0 ? 0 : 30*(issue_count.to_f/platform_statistic['max-issue-count'].to_i)
|
||||
project_maturity_commit = platform_statistic['max-commit-count'].to_i == 0 ? 0 : 40*(commit_count.to_f/platform_statistic['max-commit-count'].to_i)
|
||||
project_maturity = format("%.2f", project_maturity_pullrequest + project_maturity_issue + project_maturity_commit)
|
||||
|
||||
# 项目健康度
|
||||
closed_pullrequest_count = PullRequest.where(project_id: @project.id).merged_and_closed.count
|
||||
closed_issue_count = Issue.issue_issue.where(project_id: @project.id).closed.count
|
||||
has_license = @project.license.present? ? 1 : 0
|
||||
project_health_issue = (issue_count < 10 || closed_issue_count < 10) ? 0 : 40*(closed_issue_count-10).to_f/(issue_count-10)
|
||||
project_health_pullrequest = (pullrequest_count < 5 || closed_pullrequest_count < 5) ? 0 : 30*(closed_pullrequest_count-5).to_f/(pullrequest_count-5)
|
||||
project_health_license = 20*has_license
|
||||
project_health = format("%.2f", project_health_issue + project_health_pullrequest + project_health_license)
|
||||
|
||||
# 团队影响度
|
||||
member_count = Member.where(project_id: @project.id).count
|
||||
recent_one_month_member_count = Member.where(project_id:@project.id).where("created_on > ?", Time.now - 30.days).count
|
||||
team_impact_member = platform_statistic['max-member-count'].to_i == 0 ? 0 : 40*(member_count.to_f/platform_statistic['max-member-count'].to_i)
|
||||
team_impact_recent_member = platform_statistic['max-recent-one-month-member-count'].to_i == 0 ? 0 : 60*(recent_one_month_member_count.to_f/platform_statistic['max-recent-one-month-member-count'].to_i)
|
||||
team_impact = format("%.2f", team_impact_member + team_impact_recent_member)
|
||||
|
||||
# 开发活跃度
|
||||
recent_one_month_pullrequest_count = PullRequest.where(project_id: @project.id).where("created_at > ?", Time.now - 30.days).count
|
||||
recent_one_month_issue_count = Issue.issue_issue.where(project_id: @project.id).where("created_on > ?", Time.now - 30.days).count
|
||||
recent_one_month_commit_count = CommitLog.joins(:project).merge(Project.common).where(project_id: @project.id).where("created_at > ?", Time.now - 30.days).count
|
||||
develop_activity_pullrequest = platform_statistic['max-recent-one-month-pullrequest-count'].to_i == 0 ? 0 : 20*(recent_one_month_pullrequest_count.to_f/platform_statistic['max-recent-one-month-pullrequest-count'].to_i)
|
||||
develop_activity_issue = platform_statistic['max-recent-one-month-issue-count'].to_i == 0 ? 0 : 20*(recent_one_month_issue_count.to_f/platform_statistic['max-recent-one-month-issue-count'].to_i)
|
||||
develop_activity_commit = platform_statistic['max-recent-one-month-commit-count'].to_i == 0 ? 0 : 40*(recent_one_month_commit_count.to_f/platform_statistic['max-recent-one-month-commit-count'].to_i)
|
||||
develop_activity = format("%.2f", 20 + develop_activity_pullrequest + develop_activity_issue + develop_activity_commit)
|
||||
|
||||
render :json => {community_impact: community_impact, project_maturity: project_maturity, project_health: project_health, team_impact: team_impact, develop_activity: develop_activity}
|
||||
end
|
||||
end
|
||||
@@ -75,7 +75,11 @@ class ApplicationController < ActionController::Base
|
||||
|
||||
|
||||
def admin_or_business?
|
||||
User.current.admin? || User.current.business?
|
||||
User.current.admin? || User.current.business?
|
||||
end
|
||||
|
||||
def admin_or_glcc_admin?
|
||||
User.current.admin? || User.current.glcc_admin?
|
||||
end
|
||||
|
||||
# 判断用户的邮箱或者手机是否可用
|
||||
@@ -195,6 +199,10 @@ class ApplicationController < ActionController::Base
|
||||
normal_status(403, "") unless admin_or_business?
|
||||
end
|
||||
|
||||
def require_glcc_admin
|
||||
normal_status(403, "") unless admin_or_glcc_admin?
|
||||
end
|
||||
|
||||
# 前端会捕捉401,弹登录弹框
|
||||
# 未授权的捕捉407,弹试用申请弹框
|
||||
def require_login
|
||||
|
||||
@@ -36,6 +36,8 @@ class ProjectsController < ApplicationController
|
||||
def index
|
||||
scope = current_user.logged? ? Projects::ListQuery.call(params, current_user.id) : Projects::ListQuery.call(params)
|
||||
|
||||
# scope = scope.joins(repository: :mirror).where.not(mirrors: {status: 2}) # 导入失败项目不显示
|
||||
|
||||
@projects = kaminari_paginate(scope.includes(:project_category, :project_language, :repository, :project_educoder, :owner, :project_units, :project_topics))
|
||||
# @projects = paginate scope.includes(:project_category, :project_language, :repository, :project_educoder, :owner, :project_units)
|
||||
|
||||
@@ -62,7 +64,8 @@ class ProjectsController < ApplicationController
|
||||
end
|
||||
rescue Gitea::Api::ServerError => ex
|
||||
uid_logger_error(ex.message)
|
||||
tip_exception(ex.http_code, ex.message)
|
||||
# tip_exception(ex.http_code, ex.message)
|
||||
tip_exception(ex.message)
|
||||
rescue ApplicationService::Error => e
|
||||
uid_logger_error(e.message)
|
||||
tip_exception(e.message)
|
||||
@@ -214,7 +217,7 @@ class ProjectsController < ApplicationController
|
||||
|
||||
new_project_params = project_params.except(:private).merge(is_public: !private)
|
||||
@project.update_attributes!(new_project_params)
|
||||
@project.forked_projects.update_all(is_public: @project.is_public)
|
||||
@project.forked_projects.map{|p| p.update!(is_public: @project.is_public)}
|
||||
gitea_params = {
|
||||
private: private,
|
||||
default_branch: @project.default_branch,
|
||||
@@ -246,7 +249,7 @@ class ProjectsController < ApplicationController
|
||||
def destroy
|
||||
if current_user.admin? || @project.manager?(current_user)
|
||||
ActiveRecord::Base.transaction do
|
||||
Gitea::Repository::DeleteService.new(@project.owner, @project.identifier).call
|
||||
Gitea::Repository::DeleteService.new(@project.owner, @project.identifier,current_user.gitea_token).call
|
||||
@project.destroy!
|
||||
@project.forked_projects.update_all(forked_from_project_id: nil)
|
||||
# 如果该项目有所属的项目分类以及为私有项目,需要更新对应数量
|
||||
@@ -296,6 +299,30 @@ class ProjectsController < ApplicationController
|
||||
end
|
||||
|
||||
def simple
|
||||
if !@project.common? && @project&.repository&.mirror&.waiting?
|
||||
gitea_result = $gitea_client.get_repos_by_owner_repo(@project&.owner&.login, @project&.identifier)
|
||||
if !gitea_result["empty"]
|
||||
@project&.update_columns(gpid: gitea_result["id"])
|
||||
@project&.repository&.mirror&.succeeded!
|
||||
project_id = @project&.id
|
||||
user_id = @project&.owner&.id
|
||||
Rails.logger.info "############ mirror project_id,user_id: #{project_id},#{user_id} ############"
|
||||
OpenProjectDevOpsJob.set(wait: 5.seconds).perform_later(project_id, user_id) if project_id.present? && user_id.present?
|
||||
UpdateProjectTopicJob.set(wait: 1.seconds).perform_later(project_id) if project_id.present?
|
||||
Rails.logger.info "############ mirror status: #{@project&.repository&.mirror&.status} ############"
|
||||
end
|
||||
elsif !@project.common? && @project&.repository&.mirror&.failed?
|
||||
# 导入失败的项目标记 project.status=0, 在列表中不显示
|
||||
@project&.update_columns(status: 0) if @project&.status == 1
|
||||
|
||||
# Rails.logger.info "############ mirror status: #{@project&.repository&.mirror&.status}"
|
||||
# Gitea::Repository::DeleteService.new(@project.owner, @project.identifier,current_user.gitea_token).call
|
||||
# @project.destroy!
|
||||
# @project.forked_projects.update_all(forked_from_project_id: nil)
|
||||
# # 如果该项目有所属的项目分类以及为私有项目,需要更新对应数量
|
||||
# @project.project_category.decrement!(:private_projects_count, 1) if @project.project_category.present? && !@project.is_public
|
||||
# return render_error("导入失败,请重试!")
|
||||
end
|
||||
# 为了缓存活跃项目的基本信息,后续删除
|
||||
Cache::V2::ProjectCommonService.new(@project.id).read
|
||||
# 项目名称,标识,所有者变化时重置缓存
|
||||
|
||||
@@ -7,6 +7,7 @@ class RepositoriesController < ApplicationController
|
||||
before_action :require_login, only: %i[edit update create_file update_file delete_file sync_mirror]
|
||||
before_action :require_profile_completed, only: [:create_file]
|
||||
before_action :load_repository
|
||||
before_action :require_operate_above, only: %i[create_file update_file replace_file delete_file]
|
||||
before_action :authorizate!, except: [:sync_mirror, :tags, :commit, :archive]
|
||||
before_action :authorizate_user_can_edit_repo!, only: %i[sync_mirror]
|
||||
before_action :get_ref, only: %i[entries sub_entries top_counts files archive]
|
||||
@@ -437,4 +438,8 @@ class RepositoriesController < ApplicationController
|
||||
end
|
||||
end
|
||||
|
||||
def require_operate_above
|
||||
return render_forbidden if !current_user.admin? && !@project.operator?(current_user)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -702,6 +702,15 @@ class UsersController < ApplicationController
|
||||
@user = User.find_by(mail: params[:email])
|
||||
end
|
||||
|
||||
#根据login获取用户信息
|
||||
def get_user_info_by_login
|
||||
private_token = "hriEn3UwXfJs3PmyXnSH"
|
||||
sign = Digest::MD5.hexdigest("#{private_token}:#{params[:login]}")
|
||||
tip_exception(401, '401 Unauthorized') unless params[:sign].to_s == sign
|
||||
user = User.find_by_login params[:login]
|
||||
render_ok(data: {username: user.real_name, school: user.custom_department, login: user.login, phone: user.phone, mail: user.mail})
|
||||
end
|
||||
|
||||
private
|
||||
def load_user
|
||||
@user = User.find_by_login(params[:id]) || User.find_by(id: params[:id])
|
||||
@@ -731,7 +740,7 @@ class UsersController < ApplicationController
|
||||
end
|
||||
|
||||
def sso_login
|
||||
if params[:login].present? && !current_user.logged? && params[:websiteName].present?
|
||||
if params[:login].present? && !current_user.logged? && params[:websiteName].present? && request.referer.to_s.include?("gitlink.org.cn")
|
||||
user = User.where("login = ?", "#{params[:login].presence}").first
|
||||
# 已同步注册,直接登录
|
||||
if user.present?
|
||||
|
||||
@@ -2,8 +2,8 @@ class VersionReleasesController < ApplicationController
|
||||
include ApplicationHelper
|
||||
before_action :load_repository
|
||||
before_action :set_user
|
||||
before_action :require_login, except: [:index, :show]
|
||||
before_action :check_release_authorize, except: [:index, :show]
|
||||
before_action :require_login, except: [:index, :show, :download]
|
||||
before_action :check_release_authorize, except: [:index, :show, :download]
|
||||
before_action :find_version , only: [:show, :edit, :update, :destroy]
|
||||
|
||||
def index
|
||||
@@ -157,7 +157,7 @@ class VersionReleasesController < ApplicationController
|
||||
name: params[:name],
|
||||
prerelease: params[:prerelease] || false,
|
||||
tag_name: params[:tag_name],
|
||||
target_commitish: params[:target_commitish] || "master" #分支
|
||||
target_commitish: params[:target_commitish] || @project.default_branch #分支
|
||||
}
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user