RE: Required double login on first time app usage

Mateusz Wolak, modified 7 Years ago. Junior Member Posts: 27 Join Date: 1/17/18 Recent Posts

Hello,

when I install my app on any device I do need log in twice - first in login screenlet and then it redirects me to standard web liferay portal login portlet where I do need provide the same credentials again.
It only occurs during first login using new app, whenever I try to log in the second, third time I need to log in using only login screenlet and then it redirects me correctly to portal home page.
I think is might be something with certificate, that I am trusting?
All hints would be helpful, thanks.

Best regards

thumbnail
Victor Galan, modified 7 Years ago. Regular Member Posts: 144 Join Date: 6/14/16 Recent Posts

Hey,

 

You are using a WebScreenlet, right? You mean that when you try to load your WebScreenlet it always load the login first?

 

Can you share the code where you are creating/loading the WebScreenlet?

Mateusz Wolak, modified 7 Years ago. Junior Member Posts: 27 Join Date: 1/17/18 Recent Posts

I mean that whenever I run my app for the first time I need to login via login screenlet (and it's ok for me), but after that action it redirects me to my portal login page to login again to portal, as shown on the screenshot_5.

 

My first portlet is autlogin which redirects to privatecontentactivity or mainactivity depending on if user is already logged in.  In Mainactivity on login success i start activity with privatecontenctactivity which contains WebScreenlet.

The onCreate method from PrivateContentActivity looks like:
 

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_private_content);

    observer = new CordovaLifeCycleObserver();

    WebScreenlet screenlet = (WebScreenlet) findViewById(R.id.web_screenlet);

    downloadManager = (DownloadManager) getSystemService(Context.DOWNLOAD_SERVICE);



    if (getResources().getString(R.string.liferay_portlet_url) != null) {
        WebScreenletConfiguration webScreenletConfiguration =
                new WebScreenletConfiguration.Builder(getResources().getString(R.string.liferay_portlet_url))
                        .addRawJs(R.raw.ebok_mobile_js, "ebok_mobile_js.js")
                        //.addRawCss(R.raw.portletcss, "portlet.css")
                        //.addLocalCss("gallery.css")
                        //.addLocalJs("ebok_mobile_js.js")
                        .enableCordova(observer)
                        .load();
        screenlet.setWebScreenletConfiguration(webScreenletConfiguration);

        screenlet.setListener(this);
        screenlet.setScrollEnabled(true);
        screenlet.load();


    }
}

 

 

thumbnail
Victor Galan, modified 7 Years ago. Regular Member Posts: 144 Join Date: 6/14/16 Recent Posts

Hey

The Login Screenlet doesn't do any redirect at all or are you using OAuth2?

Login screenlet has a save credential property that allows you to avoid login to the application each time https://dev.liferay.com/develop/tutorials/-/knowledge_base/7-0/accessing-the-liferay-session-in-android

 

Regarding the WebScreenlet code, this string: R.string.liferay_portlet_url is an absolute url? For this to work it should be a relative url

I hope it helps

 

Victor

 

 

Mateusz Wolak, modified 7 Years ago. Junior Member Posts: 27 Join Date: 1/17/18 Recent Posts

Hey,

liferay_portlet_url contains relative url: "/group/guest/desktop" .
My autologin screenlet work perfectly and it's not the problem.
So I will try to explain it again:
User installs my app for the first time.

He sees login portlet as shown on screenshot_6.png.
He enters proper credentials. 
Now he sees login portlet from liferay portal as shown on screenshot_5.png.
If he enters proper credentials, he is redirected to /group/guest/desktop.

Now when he logs out from app, he is redirected to login screenlet as shown on screenshot_6.png.
He enters proper credentials.
He is immediatly redirected to /group/guest/dekstop (he does not need to re login again using liferay login portlet).

Hope it helps,

Best regards

thumbnail
Victor Galan, modified 7 Years ago. Regular Member Posts: 144 Join Date: 6/14/16 Recent Posts

Hey,

 

What I don't get yet is how are you showing this "Auto login portlet" is inside a WebScreenlet? Because I think it seems like the root of the problem, right?

Mateusz Wolak, modified 7 Years ago. Junior Member Posts: 27 Join Date: 1/17/18 Recent Posts

Hey,

no, it isn't. It's on totally different activity, so if user log in correctly I redirect him to activity which holds WebScreenlet.

@Override
public void onLoginSuccess(User user) {
   startActivity(new Intent(this, PrivateContentActivity.class));
}

 

If You would like, I can send You my current project on Your email.

 

 

thumbnail
Victor Galan, modified 7 Years ago. Regular Member Posts: 144 Join Date: 6/14/16 Recent Posts

Yeah, this way I can take a look into it :) my email is victor.galan@liferay.com

 

Thanks a lot!

thumbnail
Jenny trump, modified 6 Years ago. New Member Posts: 6 Join Date: 10/1/18 Recent Posts

 Track user login status. like

 

  1. while user login adds an entry that user is active or login

  2. now while the user is trying to log in with another device at that time check that user is login/active or not. if a user is active then don't allow them for login and display a message that log out from your old device. You can also put auto logout from last device functionality also.

  3. While the user is logged out at that time change user status active/login to not-active/logout so by this way you can manage this.

You have to pass this user status with your login web Service or API in android and in the website you can directly check from DB.