Modify to solve the error of non-logged in user called the function of user model