• Resolved gtsopour

    (@gtsopour)


    Hello there,
    thank you for your work.

    I am using the default AngularJS $http service in order to generate an auth cookie for user authentication. Here is my $http service:

    $http({
    method: 'POST',
    url: api_url + 'auth/generate_auth_cookie/?nonce=' + data.nonce + '&username=' + username + '&password=' + password
    }).
    success(function(data, status, headers, config) {}).
    error(function(data, status, headers, config) {});

    This is working perfectly. My very important issue is the following one. When the password contains the # character, I am always receiving an invalid username/password combination message. Is it something in my end? Please note that this is happening only with this specific character in any position of the password.

    I really appreciate your help.

    Thanks again
    George

    https://ww.wp.xz.cn/plugins/json-api-auth/

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Ali Qureshi

    (@parorrey)

    Hi George,

    This is so because everything is discarded after the hash sign in url.

    You should encode the # sign and replace it with %23. Your password var will become from password=c00l#pa55w0rd to password=c00l%23pa55w0rd

    Hope that helps,

    Thread Starter gtsopour

    (@gtsopour)

    Hello,
    that status changed to resolved without any feedback. Could you please verify this?

    Best
    George

    Plugin Author Ali Qureshi

    (@parorrey)

    Hi,

    I checked the password with hash myself and it worked fine with %23. I thought there was no issue at plugin level and nothing was required.

    Anyway, you can close when confirmed.

    Thread Starter gtsopour

    (@gtsopour)

    Hello Ali,
    thank you for your answer. I really appreciate that and you are absolutely right.

    I just changed my service to the following one and it is working properly:

    $http({
    method: 'POST',
    url: api_url + 'auth/generate_auth_cookie/?nonce=' + data.nonce + '&username=' + encodeURIComponent(username) + '&password=' + encodeURIComponent(password)
    }).
    success(function(data, status, headers, config) {}).
    error(function(data, status, headers, config) {});

    Thanks again
    George

    I’m doing the same, I need auntenticarme in the same way that you do it from angularjs, you help me as I do ?, telling the truth only been a week in angularjs.

    Thanks

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Generate Auth Cookie for user authentication with AngularJS’ is closed to new replies.