Posts

Showing posts with the label login

Auditing the sucessful logged-in users in liferay

In Liferay we have some events to like application startup, global events, login events and many more. If we want to audit the login user on which IP address he logged-in in liferay we have events like 1.login.events.pre 2.login.events.post login.events.pre : Which Executes Before Login Action. login.events.post: Which Excutes After Login. we want to track the user login on which IP Address used so we will write the login.events.post which will be execute after login completes. In Portal.Properties login.events.post = com.sample.hook.LoginSuccessAudit. Create a class called LoginSuccessAudit public class LoginSuccessAudit extends Action { @Override public void run(HttpServletRequest request, HttpServletResponse response) throws ActionException {                    User user = PortalUtil.getUser(request);                    System.out.println("IP Address ...

Audting the Login Failure in liferay

In Liferay we can audit login failure for the user just by writing the hook. We have property which we need to add in portal.properties file as.        auth.failure = com.sample.events.hook.LoginFailureAudit. Then create a class and extend with the AuthFailure public class LoginFailureAudit implements AuthFailure {      public void onFailureByEmailAddress(long companyId, String emailAddress, Map<String, String[]> headerMap, Map<String, String[]> parameterMap) throws AuthException { long userId = UserLocalServiceUtil.getUserByScreenName(companyId, emailAddress).getUserId(); User user = UserLocalServiceUtil.getUser(userId); System.out.println("login failure attempts are"+user.getFailedLoginAttempts()); } public void onFailureByScreenName(long companyId, String screenName, Map<String, String[]> headerMap, Map<String, String[]> parameterMap) throws AuthException { long userId = UserLocalServiceUtil.g...

Points to remember when we write the custom login portlet

Suppose you need to create the custom login portlet, which does not satisfy the default liferay's login portlet. then you need to update the following properties in the portal-ext.properties. 1. If your portlet name is "Custom login" then you need to update this property      auth.login.portlet.name= Custom login. 2. Also we need to mention the Page name(friendly URL) where this login portlet resides.      auth.login.url=/web/guest/ login

Reteriving guest premissions for the login portlet

  Some times unknowingly admin  may remove the guest permissions for the login portlet and when we try to access the portlet it says "you do not have permission to view the portlet" . Then we have to retrive back the permisions but portlet is not accessiable  what to do! Here we go , Add the following properties in portal-ext.properties  auto.login.hooks=com.liferay.portal.security.auth.ParameterAutoLogin , Whenever we add parameter in portal-ext.properties we need to resart the server. Access the url as follows  http://localhost:8080/c/portal/login?parameterAutoLoginLogin=yourscreennameOrEmailAddress&parameterAutoLoginPassword=password Retrieve back the permission changes and remove the auto.login.hooks from the portal-ext.properties. Thats it you have done and you will able to see the login portlet