please give me one example for how to create login form using post method using slingservlets in aem. | Adobe Higher Education
Skip to main content
Level 3
December 8, 2021
Beantwortet

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

  • December 8, 2021
  • 1 Antwort
  • 2163 Ansichten
No text available
Dieses Thema wurde für Antworten geschlossen.
Beste Antwort von AlbinIs1

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

1 Antwort

AlbinIs1Community AdvisorAntwort
Community Advisor
December 8, 2021

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

Level 2
January 6, 2023

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