mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-07 22:15:51 +01:00
(refs $#498)Don't show private repo user doesn't have permission
This fix in the dashboard pull request view But this fix still has a problem show wrong count number pull request.
This commit is contained in:
@@ -80,7 +80,7 @@ trait DashboardControllerBase extends ControllerBase {
|
||||
}.copy(repo = repository))
|
||||
|
||||
val userName = context.loginAccount.get.userName
|
||||
val allRepos = getAllRepositories()
|
||||
val allRepos = getAllRepositories(userName)
|
||||
val userRepos = getUserRepositories(userName, context.baseUrl, true).map(repo => repo.owner -> repo.name)
|
||||
val filterUser = Map(filter -> userName)
|
||||
val page = IssueSearchCondition.page(request)
|
||||
|
||||
@@ -166,8 +166,18 @@ trait RepositoryService { self: AccountService =>
|
||||
}
|
||||
}
|
||||
|
||||
def getAllRepositories()(implicit s: Session): List[(String, String)] = {
|
||||
Repositories.sortBy(_.lastActivityDate desc).map{ t =>
|
||||
/**
|
||||
* Returns the repositories without private repository that user does not have access right.
|
||||
* Include public repository, private own repository and private but collaborator repository.
|
||||
*
|
||||
* @param userName the user name of collaborator
|
||||
* @return the repository infomation list
|
||||
*/
|
||||
def getAllRepositories(userName: String)(implicit s: Session): List[(String, String)] = {
|
||||
Repositories.filter { t1 =>
|
||||
(t1.isPrivate === false.bind) ||
|
||||
(Collaborators.filter { t2 => t2.byRepository(t1.userName, t1.repositoryName) && (t2.collaboratorName === userName.bind)} exists)
|
||||
}.sortBy(_.lastActivityDate desc).map{ t =>
|
||||
(t.userName, t.repositoryName)
|
||||
}.list
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user