掲示板

custom login portlet with send action

8年前 に Ilya Kharnikov によって更新されました。

custom login portlet with send action

New Member 投稿: 4 参加年月日: 16/04/27 最新の投稿
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
8年前 に Andrew Jardine によって更新されました。

RE: custom login portlet with send action

Liferay Legend 投稿: 2416 参加年月日: 10/12/22 最新の投稿
Can you share with us the javascript you are using to try to do this?
8年前 に Ilya Kharnikov によって更新されました。

RE: custom login portlet with send action

New Member 投稿: 4 参加年月日: 16/04/27 最新の投稿

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
7年前 に Andrew Jardine によって更新されました。

RE: custom login portlet with send action

Liferay Legend 投稿: 2416 参加年月日: 10/12/22 最新の投稿
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?
7年前 に Ilya Kharnikov によって更新されました。

RE: custom login portlet with send action

New Member 投稿: 4 参加年月日: 16/04/27 最新の投稿
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>