From 8b2b36df0eac6d258c4d0271d122309b6b5c5bd5 Mon Sep 17 00:00:00 2001 From: Naoki Takezoe Date: Wed, 25 Apr 2018 01:55:02 +0900 Subject: [PATCH] Remove code in authenticators which keeps backward compatibility --- .../gitbucket/core/util/Authenticator.scala | 20 ++++++++----------- 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/src/main/scala/gitbucket/core/util/Authenticator.scala b/src/main/scala/gitbucket/core/util/Authenticator.scala index 5cc52a90b..7dd8fd534 100644 --- a/src/main/scala/gitbucket/core/util/Authenticator.scala +++ b/src/main/scala/gitbucket/core/util/Authenticator.scala @@ -31,9 +31,8 @@ trait OwnerAuthenticator { self: ControllerBase with RepositoryService with Acco protected def ownerOnly[T](action: (T, RepositoryInfo) => Any) = (form: T) => { authenticate(action(form, _)) } private def authenticate(action: (RepositoryInfo) => Any) = { - val paths = request.paths - val userName = params.getOrElse("owner", paths(0)) - val repoName = params.getOrElse("repository", paths(1)) + val userName = params("owner") + val repoName = params("repository") getRepository(userName, repoName).map { repository => context.loginAccount match { case Some(x) if (x.isAdmin) => action(repository) @@ -89,9 +88,8 @@ trait ReferrerAuthenticator { self: ControllerBase with RepositoryService with A protected def referrersOnly[T](action: (T, RepositoryInfo) => Any) = (form: T) => { authenticate(action(form, _)) } private def authenticate(action: (RepositoryInfo) => Any) = { - val paths = request.paths - val userName = params.getOrElse("owner", paths(0)) - val repoName = params.getOrElse("repository", paths(1)) + val userName = params("owner") + val repoName = params("repository") getRepository(userName, repoName).map { repository => if (isReadable(repository.repository, context.loginAccount)) { action(repository) @@ -112,9 +110,8 @@ trait ReadableUsersAuthenticator { self: ControllerBase with RepositoryService w } private def authenticate(action: (RepositoryInfo) => Any) = { - val paths = request.paths - val userName = params.getOrElse("owner", paths(0)) - val repoName = params.getOrElse("repository", paths(1)) + val userName = params("owner") + val repoName = params("repository") getRepository(userName, repoName).map { repository => context.loginAccount match { case Some(x) if (x.isAdmin) => action(repository) @@ -138,9 +135,8 @@ trait WritableUsersAuthenticator { self: ControllerBase with RepositoryService w } private def authenticate(action: (RepositoryInfo) => Any) = { - val paths = request.paths - val userName = params.getOrElse("owner", paths(0)) - val repoName = params.getOrElse("repository", paths(1)) + val userName = params("owner") + val repoName = params("repository") getRepository(userName, repoName).map { repository => context.loginAccount match { case Some(x) if (x.isAdmin) => action(repository)