Expand my Community achievements bar.

Auto Login After Registration

Avatar

Former Community Member

Hi Experts,

We have Custom Registration and login processes. I have a requirement wherein if the user registers they should be logged in immediately. The registration is LDAP based registration where the user is first created in LDAP and then synced to CQ. 

The syncing code is where emailId and password are the credentials provided by the user. As soon as this happens the user nodes under /home are created for user as specified in LDAP.

 userSession = this.repository.login(new SimpleCredentials(emailId, password.toCharArray()), defaultWorkspace);

Since the userSession is active through the whole request, i thought that user would log in with this process but that is not happening. Any Pointers would be helpful.

PS: I have got an admin session as well in the same class which i am getting as below. The session is needed in order to save extra nodes in the repository which we need after user is registered. 

adminSession = this.repository.loginAdministrative(null);

Is it because we have got two different session something might be in play??

2 Replies

Avatar

Level 10

Hi Kumar,

1. is the user will be created before you call repository.login ?

2. Can you login with the user created through LDAP sync manually ?

3. Will your application be logged in admin after this process or will it be anonymous ?

Can you also share any log information so that we can see what could be the problem aswell.

Avatar

Former Community Member

bsloki wrote...

Hi Kumar,

1. is the user will be created before you call repository.login ?

2. Can you login with the user created through LDAP sync manually ?

3. Will your application be logged in admin after this process or will it be anonymous ?

Can you also share any log information so that we can see what could be the problem aswell.

 

 

1) The user is being created from repository.login(creds) method. Once this method executes successfully user is created in CQ.

2) I can't sync users manually, they need to be syncd automatically that is why we are logging them in using repository.login(creds). The creds are extracted from LDAP for this.

3) I expect that once i use repository.login ( user provided creds) at the time of registration, i should be logging in as that user. So, it will not be anonymous or admin but that user. I can do request to j_security_check and login the user but i thought that repository.login does the login.

* There are no error logs for this. It is all custom code to do auto login. 

The only problem is that when i do repository.login(user creds) would the user be logged into the repository or not. Would login-token cookie be set for that user or not. Do i have to make a call to j_security_check explicitly to log users in??