Note that there are some explanatory texts on larger screens.

plurals
  1. POspring security problem using grails
    primarykey
    data
    text
    <p>I am new to grails and spring security plugin core , but i am facing a problem of </p> <p>ERROR GrailsExceptionResolver - a different object with the same identifier value was already associated with the session: [nayax.SecUserSecRole#nayax.SecUserSecRole : null]</p> <p>my code is :</p> <pre><code>NayaxUser populateDataFromJson(def user) { //todo: HANDLE CASES OF CREATING ROLES FOR USER AND REAUTHENTICATE THEM println "#### In FUNCTION ####" Facebook existingProfile = Facebook.findByFid(user.id) if (existingProfile) { println "### User already present in the database ####" existingProfile.setUser(existingProfile.user) //todo: CREATE ROLE AND REAUTHENTICATE USER SecRole secRole1 = SecRole.findByAuthority(SecRoleConstants.ROLE_USER) SecUserSecRole.create(existingProfile.user, secRole1) //todo: REAUTHENTICATE USER springSecurityService.reauthenticate(existingProfile.user.username) existingProfile.user.merge() return existingProfile.user } else { Facebook facebookObj = new Facebook(fid: user.id, lastLogin: new Date(), creationDate: new Date()).save(flush: true) NayaxUser nayaxUser = new NayaxUser(facebookUrl: user.link, fullName: user.name, facebook: facebookObj, username: user.email, password: springSecurityService.encodePassword("pleaseChangeMe"), enabled: true) if (nayaxUser.save(flush: true)) { println "### WORK DONE , saved user and save the user in session ###" facebookObj.setUser(nayaxUser) //todo: CREATE ROLE AND REAUTHENTICATE USER SecRole secRole = SecRole.findByAuthority(SecRoleConstants.ROLE_USER) SecUserSecRole.create(nayaxUser, secRole) //todo: REAUTHENTICATE USER springSecurityService.reauthenticate(nayaxUser.username) nayaxUser.merge() return nayaxUser } else { println "### ERROR IN VALIDATING DATA So NOT SETTING THE USER IN SESSION ####" nayaxUser.errors.allErrors.each { error -&gt; println("### ERROR IS ${error} ####") } return nayaxUser } } } </code></pre> <p>Actually , when i am loggin in from the facebook button and then logging out from my implementation and then logging back again quicky then there is an exception but after logging out i refresh the page a few times the problem disappears. I think something is wrong with my facebook logout implementation or is there something in the code ???</p> <p>Any suggestions are welcome.. </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload