Expand my Community achievements bar.

SOLVED

please give me one example for how to create login form using post method using slingservlets in aem.

Avatar

Level 4
 
1 Accepted Solution

Avatar

Correct answer by
Community Advisor

If your requirement is to enable a custom login form to let the user login to the AEM website, the simple option is

Create a Login form with the below input fields

name="j_username"

name="j_password"

Submit the form data to /system/sling/login/j_security_check endpoint,

Sample form from WKND website - refer to https://wknd.site/us/en.html

 

<form method="POST" action="/system/sling/login/j_security_check" id="wknd-sign-in-form" class="wknd-sign-in-form__form">
    <input type="hidden" name="charset" value="UTF-8" />
    <input type="hidden" name="j_validate" value="false" />

    <div id="container-ec9cf30016" class="cmp-container">
        <div class="text">
            <div class="cmp-form-text">
                <input class="cmp-form-text__text" data-cmp-hook-form-text="input" aria-label="USERNAME" type="text" id="form-text-123969625" placeholder="USERNAME" name="j_username" />
            </div>
        </div>
        <div class="text">
            <div class="cmp-form-text">
                <input class="cmp-form-text__text" data-cmp-hook-form-text="input" aria-label="PASSWORD" type="password" id="form-text-123969624" placeholder="PASSWORD" name="j_password" />
            </div>
        </div>
    </div>
    <div class="button">
        <button type="SUBMIT" id="form-button-272960011" class="cmp-form-button">SIGN IN</button>
    </div>
    <div class="hidden">
        <input type="hidden" id="sling-auth-redirect-signin" name="sling.auth.redirect" value="/us/en.html" />
    </div>
    <form></form>
</form>

 

Regards

Albin I

www.albinsblog.com

View solution in original post

2 Replies

Avatar

Correct answer by
Community Advisor

If your requirement is to enable a custom login form to let the user login to the AEM website, the simple option is

Create a Login form with the below input fields

name="j_username"

name="j_password"

Submit the form data to /system/sling/login/j_security_check endpoint,

Sample form from WKND website - refer to https://wknd.site/us/en.html

 

<form method="POST" action="/system/sling/login/j_security_check" id="wknd-sign-in-form" class="wknd-sign-in-form__form">
    <input type="hidden" name="charset" value="UTF-8" />
    <input type="hidden" name="j_validate" value="false" />

    <div id="container-ec9cf30016" class="cmp-container">
        <div class="text">
            <div class="cmp-form-text">
                <input class="cmp-form-text__text" data-cmp-hook-form-text="input" aria-label="USERNAME" type="text" id="form-text-123969625" placeholder="USERNAME" name="j_username" />
            </div>
        </div>
        <div class="text">
            <div class="cmp-form-text">
                <input class="cmp-form-text__text" data-cmp-hook-form-text="input" aria-label="PASSWORD" type="password" id="form-text-123969624" placeholder="PASSWORD" name="j_password" />
            </div>
        </div>
    </div>
    <div class="button">
        <button type="SUBMIT" id="form-button-272960011" class="cmp-form-button">SIGN IN</button>
    </div>
    <div class="hidden">
        <input type="hidden" id="sling-auth-redirect-signin" name="sling.auth.redirect" value="/us/en.html" />
    </div>
    <form></form>
</form>

 

Regards

Albin I

www.albinsblog.com

Avatar

Level 2

Can this be used for Production ?
Any security concerns with https ? The credentials are being sent over plain text.