Skip to content
This repository has been archived by the owner on Aug 8, 2021. It is now read-only.

Commit

Permalink
Prevent fake banned messages
Browse files Browse the repository at this point in the history
  • Loading branch information
rahulsom committed Sep 3, 2017
1 parent f0ed786 commit 17baf46
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
3 changes: 2 additions & 1 deletion src/main/webapp/WEB-INF/groovy/store.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ if (githubAuthUtil.isAuthenticated()) {
uploader: username,
uploaderEmail: session.getAttribute(GithubAuthUtil.GITHUB_EMAIL_PRIMARY)
)
UserList myList = LgtmService.instance.getUserList(username)
try {
UserList myList = LgtmService.instance.getUserList(username)

if (myList.bannedFromUpload) {
request.setAttribute 'message', "You're not allowed to upload images"
Expand All @@ -46,6 +46,7 @@ if (githubAuthUtil.isAuthenticated()) {
request.setAttribute 'message', 'That image was already uploaded.'
redirect "/i/${e.hash}"
} catch (ValidationException e) {
request.setAttribute('banned', myList.bannedFromUpload)
request.setAttribute 'message', e.message
request.setAttribute 'imageUrl', imageUrl
response.setHeader "Content-Type", "text/html"
Expand Down
10 changes: 5 additions & 5 deletions src/main/webapp/WEB-INF/pages/upload.gtpl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@
<body>
<h1>Upload</h1>

<% if (request.getAttribute('banned') == false) { %>
<% if (request.getAttribute('banned') == true) { %>
<div class="alert alert-warning" role="alert">
You have been banned from uploading images for violating our content policy. You may still use
</div>
<% } else { %>
<form action="/save" method="post">
<div class="form-group>
<label for="imageUrl">Image Url</label>
Expand All @@ -17,10 +21,6 @@
</div>
<button type="submit" class="btn btn-default">Submit</button>
</form>
<% } else { %>
<div class="alert alert-warning" role="alert">
You have been banned from uploading images for violating our content policy. You may still use
</div>
<% } %>
</body>
</html>

0 comments on commit 17baf46

Please sign in to comment.