import org.eclipse.jgit.lib.Repository;\r
import org.eclipse.jgit.revwalk.RevCommit;\r
\r
+import com.gitblit.models.RepositoryModel;\r
+import com.gitblit.models.UserModel;\r
import com.gitblit.utils.DiffUtils;\r
import com.gitblit.utils.JGitUtils;\r
import com.gitblit.utils.StringUtils;\r
@CacheControl(LastModified.BOOT)\r
public class PatchPage extends SessionPage {\r
\r
- public PatchPage(PageParameters params) {\r
+ public PatchPage(final PageParameters params) {\r
super(params);\r
\r
if (!params.containsKey("r")) {\r
- GitBlitWebSession.get().cacheErrorMessage(getString("gb.repositoryNotSpecified"));\r
+ error(getString("gb.repositoryNotSpecified"));\r
redirectToInterceptPage(new RepositoriesPage());\r
- return;\r
}\r
\r
final String repositoryName = WicketUtils.getRepositoryName(params);\r
final String objectId = WicketUtils.getObject(params);\r
final String blobPath = WicketUtils.getPath(params);\r
\r
+ GitBlitWebSession session = GitBlitWebSession.get();\r
+ UserModel user = session.getUser();\r
+\r
+ RepositoryModel model = app().repositories().getRepositoryModel(user, repositoryName);\r
+ if (model == null) {\r
+ // user does not have permission\r
+ error(getString("gb.canNotLoadRepository") + " " + repositoryName);\r
+ redirectToInterceptPage(new RepositoriesPage());\r
+ return;\r
+ }\r
+\r
Repository r = app().repositories().getRepository(repositoryName);\r
if (r == null) {\r
- GitBlitWebSession.get().cacheErrorMessage(getString("gb.canNotLoadRepository") + " " + repositoryName);\r
+ error(getString("gb.canNotLoadRepository") + " " + repositoryName);\r
redirectToInterceptPage(new RepositoriesPage());\r
return;\r
}\r
add(new Label("patchText", patch));\r
r.close();\r
}\r
+\r
}\r