Skip to content

Commit 388ac7f

Browse files
Simplify access validation logic
1 parent fa94543 commit 388ac7f

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

src/Synchronizer.cs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,15 @@ public async Task<ValidationResult> ValidateAccess()
2626
{
2727
var access = await _gitHub.GetAccess();
2828

29-
return access.All(a => a != "repo") ? ValidationResult.Error("API key does not have `repo` access")
30-
: access.All(a => a != "delete_repo") ? ValidationResult.Error("API key does not have `delete_repo` access")
31-
: ValidationResult.Success();
29+
if (access.Contains("repo") && access.Contains("delete_repo"))
30+
{
31+
return ValidationResult.Success();
32+
}
33+
34+
var error = !access.Contains("repo")
35+
? "API key does not have `repo` access"
36+
: "API key does not have `delete_repo` access";
37+
return ValidationResult.Error(error);
3238
}
3339

3440
public async Task<ValidationResult> ValidateUser(Account account)

0 commit comments

Comments
 (0)