Ask Questions and Find Answers
Important:
Ask is now read-only. You can review any existing questions and answers, but not add anything new.
But - don't panic! While ask is no more, we've replaced it with discuss - the new Liferay Discussion Forum! Read more here here or just visit the site here:
discuss.liferay.com
RE: Required double login on first time app usage
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
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?
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(); } }
Attachments:
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
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
Attachments:
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?
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.
Yeah, this way I can take a look into it :) my email is victor.galan@liferay.com
Thanks a lot!
Track user login status. like
-
while user login adds an entry that user is active or login
-
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.
-
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.
Powered by Liferay™