grails - Cannot invoke method isLoggedIn() on null object -
i have 2 spring security related question.
1, have below code in controller changing password
def changepassword() { if (!securityservice.isloggedin()) { redirect(action: 'auth', controller: 'login') return } }
when hit save button after confirming new password generates te following error
nullpointerexception occurred when processing request: [post] cannot invoke method isloggedin() on null object.
now question wrong?
2, second question similar trying current user this
user currentuser = securityservice.getcurrentuser() currentuser.gender = gender currentuser.save()
but still generating same error
cannot invoke method getcurrentuser() on null object
note:- using grails 2.4.4 , spring security 2.0-rc4.
update:- did include def securityservice
in controller/service
just add 'def springservice' in controller
class usercontroller{ def springsecurityservice def changepassword(){ //you can access springsecurityservice if (!springsecurityservice.isloggedin()) { redirect(action: 'auth', controller: 'login') return } } }
Comments
Post a Comment