Foren

custom login portlet with send action

Ilya Kharnikov, geändert vor 8 Jahren.

custom login portlet with send action

New Member Beiträge: 4 Beitrittsdatum: 27.04.16 Neueste Beiträge
Hi everybody,
I have a problem with custom login portlet. I'm trying to send action POST request from ajax to controller, where after
PortletActionInvoker.processAction ( "com.liferay.portlet.login.action.LoginAction", portletConfig, actionRequest,
                     noRedirectActionResponse) 

try to redirect to homepage, but if I not write redirect to standart
                  
  "/ Portal / login? Login =" + login + "& password =" + password + "& rememberMe =" + rememberMe

in action response my user is not login in a system
Maybe I make something wrong, if somebody can help me in my question will be very grateful.
Redirect to the login settings and passwords are not secure and can be intercepted.
Sorry for poor english.
thumbnail
Andrew Jardine, geändert vor 8 Jahren.

RE: custom login portlet with send action

Liferay Legend Beiträge: 2416 Beitrittsdatum: 22.12.10 Neueste Beiträge
Can you share with us the javascript you are using to try to do this?
Ilya Kharnikov, geändert vor 8 Jahren.

RE: custom login portlet with send action

New Member Beiträge: 4 Beitrittsdatum: 27.04.16 Neueste Beiträge

var formAction = $(this).attr("action");
var formData = {
   "login": portlet.content.find('input[name=_login]').val(),
   "password": portlet.content.find('input[name=_password]').val(),
   "rememberMe": portlet.content.find('input[name=_rememberMeCheckbox]').is(":checked")
    };
var url = formAction + "&action=customlogin";
$.ajax({
	type:'POST',
	headers: this.headers,
	dataType: "json",
	url: url,
	data:formData,
	error: function (data) {
		 console.log(data);
	},
	onFailure: function () {
		alert('Ajax Failure');
	},
	statusCode: {
		404: function() {
			alert("missing info");
		}
	},
	success : function (response) {
		alert("The server says: " + JSON.stringify(response));
	}
}).done(function( data ) {
	 console.log(data);
});
thumbnail
Andrew Jardine, geändert vor 8 Jahren.

RE: custom login portlet with send action

Liferay Legend Beiträge: 2416 Beitrittsdatum: 22.12.10 Neueste Beiträge
Hi Ilya,

I should have asked this the first time, sorry, but can you also include the HTML that you are referencing? You mentioned it is a custom login portlet -- so I assume that means that you are not using the one that Liferay provides (58)?

So your flow is ... (correct me if I am wrong)

1. User goes to a page that contains your custom portlet.
2. The portlet is displayed -- login form with same fields as the one that Liferay provides.
3. User fills in the form.
4. User hits Login button which calls a JS function (you provided)

-- can you tell me what the form action (url) is? Can you also show us what the full


var url = ...


is equal to before the AJAX call is made?
Ilya Kharnikov, geändert vor 8 Jahren.

RE: custom login portlet with send action

New Member Beiträge: 4 Beitrittsdatum: 27.04.16 Neueste Beiträge
I create action url in render phase like this:
Controller side:

  @RenderMapping
  @RequestMapping
    public String renderEdit(RenderRequest request,
                             RenderResponse response,
                             Model model)
            throws DocumentException, IOException {

        PortletURL url = response.createActionURL();
         model.addAttribute("action_url", url.toString());
   retrun "com.company.portal.portlets.login.view";
}


    <div class="jsLoginPortlet">
            <fieldset class="fieldset">
                  <div class="">
                    <form id="_loginForm" action="{$action_url}">
                      <div class="messenger"> </div>
                      <div class="control-group input-text-wrapper">
                          <label class="control-label" for="_58_login">{$email_adress}</label>
                          <input class="field clearable" id="_login" name="_58_login" type="text" value="{$def_addr}">
                       </div>
                       <div class="control-group input-text-wrapper">
                          <label class="control-label" for="_58_password">{$password}</label>
                          <input class="field" id="_password" name="_58_password" type="password" value="">
                       </div>
                       <span id="_58_passwordCapsLockSpan" style="display: none;">{$caps_lock_on}</span>
                       <div class="control-group form-inline input-checkbox-wrapper">
                          <label class="checkbox" for="_58_rememberMeCheckbox">
                          <input id="_58_rememberMe" name="_58_rememberMe" type="hidden" value="false">
                          <input class="field" id="_58_rememberMeCheckbox" name="_58_rememberMeCheckbox" type="checkbox">{$rem_me}</label>
                        </div>
                  </form></div>
                  <div class="button-holder">
                      <input type="submit" class="btn btn-primary" value="{$sign_in}/">
                
               </div>
               </fieldset>
        </div>