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

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -