I want add the page after to complete the registration in liferay portal, user can insert your image, and then Login portlet page is displayed.
To do this, what should I do?
In addition, for the first time only login the choice should be
I want add the page after to complete the registration in liferay portal, user can insert your image, and then Login portlet page is displayed. To do this, what should I do?
For this, Create a Hook for login portlet.
ref : webapps/ROOT/html/portlet/login/create_account.jsp
custom post login action
create hook plugin
in src/main/resources , create portal.properties and put:
login.events.post=com.liferay.CustomPostLoginAction
create CustomPostLoginAction class extend from com.liferay.portal.kernel.events.Action
put logic in run method this class and redirect to portlet for add user portrait (for exapmle userportrait portlet)
in view.jsp userportrait portlet use "liferay-ui:logo-selector" tag for add and crop image for user.
Related
I'd like to to hide the in-built "Sign-in" portlet for users that have logged in.
How do I set permissions to achieve this?
Liferay uses RBAC permission model, which probably won't allow you to achieve this through permissions. This is because it's utterly illogical to deprave a system role from a permission granted to a guest.
Consider some other options, from the top of my head:
Create a layout-template which show or hides some portlet column depending on whether current user is not guest (not entirely sure if this will be that easy as it depends on which variables exactly are available in layout-template velocity environment)
Wrap sign-in portlet in another portlet
Simply hook sign-in portlet's JSP
Javascript maybe? Probably the easiest solution, not the best though
Another way of achieving this is to create a public page which contains the Login portlet, let's say the page is called Login (this page and it's portlet should be viewable by guests).
Next, create another page and call this Welcome. Put some portlets on it for logged in users to see. The page should preferably private, however if it's public ensure you change permissions so guests can't see portlets etc..
Now go to Control Panel > Portal > Portal Settings and modify the Navigation links (hover over the question mark icon for informative tooltips explaining what each link does).
Here is an example, following on from what I've mentioned above with the Login and Welcome pages:
Simples! No code modifications or custom themes!
Liferay adds the signed-in class to your <body> element. If you can live with it being available in HTML, but just not shown, add
.signed-in .portlet_login {
display:none;
}
or similar to your theme or the login-portlet's look&feel advanced styling.
You can render/not render many things based on $is_signed_in check in Theme VM files.
is_signed_in will be true for logged in users and false otherwise.
Some examples are below from portal_vm.vm
#if(!$is_signed_in)
$sign_in_text
#end
#if($is_signed_in)
#if($permissionChecker.isOmniadmin()== true)
#dockbar()
#end
#if(!$is_signed_in)
$theme.include($themeServletContext, "/jsp/someJsp.jsp")
#end
This is basically two question? First i was wonder how to change the page liferay redirects when a user tries to access a page that has Power User view permissions. Liferay by default points to localhost:web/guest/home where they have their login page. On my application i have a different login in page and i want to redirect to the following page. I was browsing the web and found out that by setting auth.login.site.url=/whereiwontittopoint should actualy redirect me there. However it does not. I'm using Liferay 6.0.6 Community Editions. Has anyone done this? Is this the right way or this need to be done with a hook?
My other question is the following. I want to have a custom role on some pages. And i want when a user does not have that specfic role to be redirect to a totaly different page not the default login. I'm fairly sure this can be done by using the hook on some service but for some reason i can not identify this service.
EDIT
Ok for the first question i solved the issues. For the second question the answers i got here were not what i was looking for probably because i didn't post the question correctly. This is a full scenario of what i have done and what i need to do:
First of all i changed the /web/guest path that's on every liferay page to web/somthing/ this might not play a crucial role but the problems(some of the problems) started when that happend. THe over all idea is the following. I'm using spring mvc to create the application. I have created a backend to my application from where the admin can create pages for other users to see(This is not done by going to the control panel of liferay and adding a page but through the logic of the application). Once a page is created depending on some logic i create a role for that certain page(customer role also through code not the liferay admin). Some of the users are given this role if the satisfy some criteria and some are not. Here my problem arises, once a user that is loged in to my application tries to access a page (by inputting a direct URL in the browser to the page) that requres the view permision of the role i create for that page and the user does not have the appropriate role he gets redirect to lets say localhost/web/(username)/home a personal page and for some reason on that page by default from liferay he is able to view personal data(user name) of all other users of the application. My question is how through code to handle the redirection that happens of the above scenario.
I have tried on one attempt to actualy hook the servlet.service.events.pre action and before the user access that page to check if he has the appropriate permisions and actualy change his request. So far i have some issues but i can resolve them but this approach is not what i not rly what i am looking for because this action is executed before every single request on the application( and the page handling is just small part of that application) which means i will have a lot of code executing for no reason. I was wondering if there are any ways to add where the exception will redirect when i create the role? If not what action should i hook that will help me solve this scenario but with out the unneeded extrea trafic that i am creating with hooking servlet.service.events.pre action?
For the second stuff a bit hacky way could be as follows
1) Define set of roles against which you want to check in portal-ext.properties. You can add some property like my.super.secret.roles=rolename1,rolename2
2) Add a property for a redirect page url in portal-ext.properties so that you can redirect user there.
3)Add a custom attribute for Layout named checkForSecretRoles which has to be boolean and visible on Page. This will show you a checkbox in Manage page for each page, so that an admin can easily check or uncheck the value
4)Add a condition in your theme (portal_normal.vm) to check if the page has a check for secret role and then check the users role falls in any of the roles defined in portal-ext.properties. If yes then issue a redirect to the page specified by your custom redirect page url property
For your first question, it should work -
auth.forward.last.paths=/sign-in
sign-in would be your page name
The answer for your second question is, you have to create a Hook extending Action and made the below entry in your portal-ext.properties.
login.events.post=com.liferay.portal.events.LoginPostAction,com.liferay.portal.events.CustomLandingPageAction
There is a lot of information you can found on forum about how to use this property.
for 1. set default.landing.page.path=/whereiwontittopoint in portal.properties, see Liferay Login page redirect
for 2. create a hook, set servlet.service.events.post=com.my.action.MyAction and impliment this action, at this point you can redirect user to another page.
Once the Liferay Start Up page is displayed , there is a Sign-in Hyperlink , and once we click on that Sign-in Hyperlink it will take us to the Page where it will display the actual Login page.
What is the name of that JSP page (The Actual page with Email, Password and the Submit Button)?
I am using Liferay 6.1.
If you are thinking of modifying any JSP which is already there in liferay, consider modifying using hooks so that you dont have to restart liferay server since hooks are hot-deployable and easy to manage.
To learn more about hooks follow this link. http://www.liferay.com/documentation/liferay-portal/6.1/development/-/ai/hoo-4
The login link call login portlet. But you can change default login page, add to portal-ext.properties auth.login.url=mypageurl.
If what you want to do in your new login page is to add new fields then using Liferay custom fields will be the way go. You can define custom fields for User and make them editable and then add the into the login.jsp file using this tag
<div class="exp-ctrl-holder">
<liferay-ui:custom-attribute
className="<%=User.class.getName()%>"
classPK="<%=0%>"
editable="<%=true%>"
label="<%=true%>"
name="FieldName" />
</div>
This edit should be done using a hook
or
if you want to add additional logic to the login action then using the Liferay Extension environment is the best solution.
I am using Liferay 6 for development .
I have developed a Custom Login Portlet using Struts2 .
I am able to display my Custom Login page , On click of the Submit Button after validating the credentials aganist our MYSQL Databse , please tell me how can i display my 4 other Custom Portlets on entering valid credentials ??
please guide me what is the concept i should refer for this in liferay
( I am using Liferay 6 for development )
Okay, the way I would suggest you do this is by:
adding the 4 other portlets to your Custom Login page (or add a redirect on successful login, and them to the page you redirect to)
Set the permissions of your Custom Portlets to be viewable by only authenticated users. This can be done by removing Guest "View" permissions. This way a non-authenticated user or "Guest" won't see your portlets when the go to the page.
Does this answer your question?
~~ EDIT IN RESPONSE TO COMMENT ~~
Okay, so if you're using Struts, instead of redirecting to a JSP file, you want to redirect to a URL instead. So instead of /view/result.jsp it should be something like http://yoursite.com/page_with_4_portlets_on_it or just a relative URL /page_with_4_portlets_on_it (if the two pages are on the same Navigation level.
HOWEVER:
If you're new to Liferay then I would strongly suggest you use Liferay's inbuilt Portlet architecture using their MVCPortlet class. This will handle all the mappings, and workings that you have to manually write for using Struts. Then you can implement a doPost() method and do a ActionResponse.sendRedirect("/page_with_4_portlets_on_it");
Then this means that when your form action completes Liferay will redirect the user to the page you've specified.
The best place to get started with Liferay 6 portlets, the Liferay way is here.
I've got a theme which has a login portlet embedded in the header and I dont wish for validation messages to appear on this login portlet, instead I want Liferay to redirect to the maximized version of the login portlet with the validation errors.
Is there any easy way to do this through the Velocity template files?
The best workaround I can come up with is to hardcode a HTML form which posts to the login struts action which seems to show validation errors on a maximized loging portlet
Thank you
I don't believe Liferay 6.0 has the capability to overwrite portlet code using a VM. It is, however, a new feature in the upcoming 6.1 release.
But if you're tied into Liferay 6.0, you may create a hook plugin to tackle this problem.
Create a hook plugin.
In your hook.xml define:
<hook>
<custom-jsp-dir>/META-INF/custom_jsps</custom-jsp-dir>
</hook>
In copy the original login.jsp from Liferay Portal to /META-INF/custom_jsps/html/portlet/login.jsp.
You'll want to modify the form action's URL to have window state maximized. You can do so by adding the windowState attribute to the tag lib that generates the URL. For Example:
<portlet:actionURL windowState="<%= LiferayWindowState.MAXIMIZED.toString() %>" />
After deploying this hook plugin, the logins should go to a maximized state unless redirected by a successful login.