Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleaning up a chunk of code #394

Merged
merged 2 commits into from
Oct 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "Registrator"
uuid = "4418983a-e44d-11e8-3aec-9789530b3b3e"
authors = ["Stefan Karpinski <stefan@karpinski.org>"]
version = "1.4.2"
version = "1.5"

[deps]
AutoHashEquals = "15f4f7f2-30c1-5605-9d31-71845cf9641f"
Expand Down
17 changes: 7 additions & 10 deletions src/webui/gitutils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -115,17 +115,14 @@ function isauthorized(u::User{GitLab.User}, repo::GitLab.Project, fetch = true)
end
# Same as above: group membership then collaborator check.
nspath = split(repo.namespace.full_path, "/")
ismember = @gf_bool @mock is_collaborator(u.forge, repo.namespace.full_path, repo.name, u.user.id)
if !ismember
accns = ""
for ns in nspath
accns = joinpath(accns, ns)
ismember = @gf_bool @mock is_member(forge, accns, u.user.id)
ismember &&
break
end
(@gf_bool @mock is_collaborator(u.forge, repo.namespace.full_path, repo.name, u.user.id)) &&
return AuthSuccess()
accns = ""
for ns in nspath
accns = joinpath(accns, ns)
(@gf_bool @mock is_member(forge, accns, u.user.id)) &&
return AuthSuccess()
end
ismember && return AuthSuccess()
AuthFailure("Project $(repo.name) belongs to the group $(repo.namespace.full_path), and user $(u.user.name) is not a member of that group or its parent group(s)")
end

Expand Down