I have Grails application there is button onclicking which it is forwarded to a action which is authenticated by spring security and first goes to login page if a user is not logged in and then come to the expected page.
I want to set header after the button is clicked and want it in login page only if it had been redirected here after clicking on the button normally it shouldn't be there on login page.
I have redirected to another function from GSP and there I am setting header and from there I have redirected to the actuall function.
For the first time when server runs the value comes but after that it dissappears.
Please guide me.
My code:-
gsp code :
<g:form controller="project" action="addFundraiserUrl" id="${project.id}" params="['fr':currentFundraiser.username]">
<input type="submit" value="Join Us" class="col-md-12 col-sm-12 col-xs-12 inviteteammember text-center btn btn-default btn-md manage-team"/>
</g:form>
controller code :-
def addFundraiserUrl () {
response.setHeader 'X-JoinUs', 'true'
redirect (action:'addFundRaiser', params:params)
}
@Secured(['IS_AUTHENTICATED_FULLY'])
def addFundRaiser(){
def project = projectService.getProjectById(params.id)
User user = userService.getCurrentUser()
def fundraiser = project.user.username
def iscampaignAdmin = userService.isCampaignBeneficiaryOrAdmin(project, user)
def message = projectService.getFundRaisersForTeam(project, user)
def title = projectService.getVanityTitleFromId(params.id)
def name = userService.getVanityNameFromUsername(fundraiser, params.id)
if (iscampaignAdmin) {
flash.prj_mngprj_message = message
redirect (action: 'manageproject', params:['projectTitle':title])
} else {
flash.prj_mngprj_message = message
redirect (action: 'show', params:['projectTitle':title,'fr':name])
}
}