This topic contains 1 reply, has 2 voices, and was last updated by Sean Sean 1 year, 8 months ago.

Authentication using Javascript

  • mikonos

    Member Reply #10012


    I am deploying ur theme on a server with javascript as authentication.

    I am trying to add the authentication code in login.js file, but for some reason, I am not able to get the username values and password value to send it via my function.
    The authentication is through aws cognito, and I am trying to get this to work:


    var input = {

    email: email.value,

    password: password.value


    But the values are always null!! I checked the id’s in my html code and I tried using email instead of email.value! Not working!!

    The aws function that follows and send the input json:


    FunctionName: ‘sampleAuthLogin’,

    Payload: JSON.stringify(input)

    }, function(err, data) {

    if (err) console.log(err, err.stack);

    else {

    var output = JSON.parse(data.Payload);

    if (!output.login) {

    result.innerHTML = ‘<b>Not</b> logged in’;

    } else {

    result.innerHTML = ‘Logged in with IdentityId: ‘ + output.identityId + ‘<br>’;


    var creds = AWS.config.credentials;

    creds.params.IdentityId = output.identityId;

    creds.params.Logins = {

    ‘’: output.token


    creds.expired = true;


    // Do something with the authenticated role







    Can u let me know how to get the values for the inputs in the javascript file, and whther I can add the authentication code to the javascript login.js!





    Posts: 4527
    Support Staff Reply #10026


    Sorry, by reading your code we can not advise you much as this is not the theme related issue. This just requires a proper customization in order to implement it as per your requirements.  You can try to pass the secure token via hidden input. For this you will need to customize the script properly as per your requirements.



You must be logged in to reply to this topic.