Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Downloads require authentication #217

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ class SearchController {
redirect(action:'list', params:[q:params.q, fq:params.fq])
}

@AlaSecured
def download(){
response.setHeader("Content-Disposition", "attachment; filename=\"images.zip\"")
response.setHeader("Content-Type", "application/zip")
Expand Down
33 changes: 29 additions & 4 deletions grails-app/views/search/list.gsp
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,19 @@
<a id="btnAddCriteria" class="btn btn-default">
<g:message code="list.advanced.search" />
</a>
<a class="btn btn-default" href="${createLink(controller:'search', action:'download')}?${request.getQueryString()}">
<span class="glyphicon glyphicon-download"></span>
<g:message code="list.download.results" />
</a>
<auth:ifLoggedIn>
<a class="btn btn-default" href="${createLink(controller:'search', action:'download')}?${request.getQueryString()}">
<span class="glyphicon glyphicon-download"></span>
<g:message code="list.download.results" />
</a>
</auth:ifLoggedIn>
<auth:ifNotLoggedIn>
<!-- Button trigger modal -->
<button type="button" class="btn btn-default" data-toggle="modal" data-target="#modal-download-login-required">
<span class="glyphicon glyphicon-download"></span>
<g:message code="list.download.results" />
</button>
</auth:ifNotLoggedIn>
</div>
</div>
</g:form>
Expand Down Expand Up @@ -85,6 +94,22 @@
</div>
</div>
</div>
<div class="modal fade" id="modal-download-login-required" tabindex="-1" role="dialog" aria-labelledby="label-download-login-required">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title" id="label-download-login-required"><g:message code="list.download.loginRequiredModal.title" default="Login Required"/></h4>
</div>
<div class="modal-body">
<p><g:message code="list.download.loginRequiredModal.body" default="Please login to download image search results."/></p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal"><g:message code="list.download.loginRequiredModal.close" default="Close"/></button>
</div>
</div>
</div>
</div>

<script>

Expand Down