Merge branch 'standalone_develop' of https://gitlink.org.cn/Trustie/forgeplus into standalone_develop
This commit is contained in:
commit
7bebed6f91
|
@ -190,22 +190,24 @@ module ProjectOperable
|
|||
end
|
||||
|
||||
# 项目管理员(包含项目拥有者),权限:仓库设置、仓库可读可写
|
||||
# 增加bot用户权限,已安装bot,当前bot用户即拥有权限,权限粒度待完善
|
||||
def manager?(user)
|
||||
if owner.is_a?(User)
|
||||
managers.exists?(user_id: user.id)
|
||||
managers.exists?(user_id: user.id) || (user.platform == "bot" && BotInstall.joins(:bot).where(bot: { uid: user.id }).where(store_id: self.id).exists?)
|
||||
elsif owner.is_a?(Organization)
|
||||
managers.exists?(user_id: user.id) || owner.is_owner?(user.id) || (owner.is_only_admin?(user.id) && (teams.pluck(:id) & user.teams.pluck(:id)).size > 0)
|
||||
managers.exists?(user_id: user.id) || owner.is_owner?(user.id) || (owner.is_only_admin?(user.id) && (teams.pluck(:id) & user.teams.pluck(:id)).size > 0) || (user.platform == "bot" && BotInstall.joins(:bot).where(bot: { uid: user.id }).where(store_id: self.id).exists?)
|
||||
else
|
||||
false
|
||||
end
|
||||
end
|
||||
|
||||
# 项目开发者,可读可写权限
|
||||
# 增加bot用户权限,已安装当前bot用户对应的bot即拥有权限,权限粒度待完善
|
||||
def develper?(user)
|
||||
if owner.is_a?(User)
|
||||
developers.exists?(user_id: user.id)
|
||||
developers.exists?(user_id: user.id) || (user.platform == "bot" && BotInstall.joins(:bot).where(bot: { uid: user.id }).where(store_id: self.id).exists?)
|
||||
elsif owner.is_a?(Organization)
|
||||
developers.exists?(user_id: user.id) || (owner.is_only_write?(user.id) && (teams.pluck(:id) & user.teams.pluck(:id)).size > 0)
|
||||
developers.exists?(user_id: user.id) || (owner.is_only_write?(user.id) && (teams.pluck(:id) & user.teams.pluck(:id)).size > 0) || (user.platform == "bot" && BotInstall.joins(:bot).where(bot: { uid: user.id }).where(store_id: self.id).exists?)
|
||||
else
|
||||
false
|
||||
end
|
||||
|
|
|
@ -845,6 +845,15 @@ class User < Owner
|
|||
end
|
||||
end
|
||||
|
||||
# 重写gitea_token,当用户为bot类型时,替换成管理员token
|
||||
def gitea_token
|
||||
if self.platform == "bot"
|
||||
GiteaService.gitea_config[:admin_token]
|
||||
else
|
||||
self['gitea_token']
|
||||
end
|
||||
end
|
||||
|
||||
protected
|
||||
def validate_password_length
|
||||
# 管理员的初始密码是5位
|
||||
|
|
|
@ -55,6 +55,7 @@ default: &default
|
|||
access_key_secret: ''
|
||||
domain: 'https://testgit.trustie.net'
|
||||
base_url: '/api/v1'
|
||||
admin_token: '123123'
|
||||
accelerator:
|
||||
access_key_id: ''
|
||||
access_key_secret: ''
|
||||
|
|
Loading…
Reference in New Issue