0

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])
    }
}
tim_yates
  • 167,322
  • 27
  • 342
  • 338
  • Hope this will help you. You can use filter .http://stackoverflow.com/questions/6415452/grails-add-header-to-every-response – praveen_programmer Jun 24 '15 at 15:43
  • http://stackoverflow.com/questions/19791406/spring-security-authentication-based-on-request-parameter – V H Jun 24 '15 at 15:56
  • I have to set url value as location value I won't be able to set if it's set through filter and url value will change depending on from where the page is redirected to login page.Is there a solution that I can set the url value as location header whenever a button is clicked and is redirected t a gsp.It's working but only fr once when I start a server I want it everytime. – Kartiki Sahu Jun 25 '15 at 05:48

0 Answers0