Pattern
Sign in
Sign people in with their phone number and a password, check it is them with a code by SMS, and keep their answers when the session ends.
When to use
- When people need to come back to something that is theirs: an application in progress, a business account, their licences.
When not to use
- To do a one-off task such as reporting a problem or paying a fee: let people do it without an account, and send a reference by SMS.
- Only to collect contact details. An account is one more password to remember.
How it works
- Sign in: a phone number (or email address) and a password with a Show button, on one page.
- Check it is them: a 6-digit code by SMS, which their phone can fill in. Offer email as another way.
- While signed in: a timeout warning on every page, 2 minutes before the end of the session.
- Signed out: a page that says why, and that their answers are saved.
The sign-in page
- Ask for what people already use with you: most people in Ghana have a phone number before an email address.
- Use
autocomplete="tel"(oremail) andautocomplete="current-password", so password managers and phones can fill them in. - Link to "Forgotten your password?" and to "Create an account" under the button, never above it.
- Never ask for a Ghana Card number and date of birth as a way to sign in: they are not secret.
Error messages
- Empty: "Enter your phone number", "Enter your password".
- Wrong: "The phone number or password is not right". Do not say which, or people can find out who has an account.
- Too many tries: "You have tried too many times. Try again in 15 minutes, or reset your password". Say how long.
- Code: "The code is not right" and "The code has expired. Send a new code".
Accessibility
- Never block pasting into the password or the code, and never ask people to solve a puzzle to sign in (WCAG 3.3.8, accessible authentication).
- Give people at least 20 minutes of inactivity before signing them out, warn them, and let them extend it (WCAG 2.2.1).
Example: The sign-in page
<h1>Sign in to your business account</h1>
<form action="/sign-in/" method="post" novalidate>
<div class="ggds-field">
<label class="ggds-label" for="signin-phone">Phone number</label>
<p class="ggds-hint" id="signin-phone-hint">The number you used to create your account</p>
<input class="ggds-input ggds-input--width-medium" id="signin-phone" name="phone" type="tel" autocomplete="tel" inputmode="tel" aria-describedby="signin-phone-hint">
</div>
<div class="ggds-field ggds-password-input" data-ggds-module="password-input">
<label class="ggds-label" for="signin-password">Password</label>
<div class="ggds-password-input__wrapper">
<input class="ggds-input ggds-password-input__input" id="signin-password" name="password" type="password" autocomplete="current-password" spellcheck="false" autocapitalize="none">
<button class="ggds-button ggds-button--secondary ggds-password-input__toggle" type="button" aria-controls="signin-password" aria-label="Show password" hidden>Show</button>
</div>
</div>
<button class="ggds-button" type="submit">Sign in</button>
</form>
<p><a href="/sign-in/forgotten-password/">Forgotten your password?</a></p>
<p>No account yet? <a href="/create-account/">Create an account</a>.</p><>
<h1>Sign in to your business account</h1>
<form action="/sign-in/" method="post" noValidate>
<div className="ggds-field">
<label className="ggds-label" htmlFor="signin-phone">Phone number</label>
<p className="ggds-hint" id="signin-phone-hint">The number you used to create your account</p>
<input className="ggds-input ggds-input--width-medium" id="signin-phone" name="phone" type="tel" autoComplete="tel" inputMode="tel" aria-describedby="signin-phone-hint" />
</div>
<div className="ggds-field ggds-password-input" data-ggds-module="password-input">
<label className="ggds-label" htmlFor="signin-password">Password</label>
<div className="ggds-password-input__wrapper">
<input className="ggds-input ggds-password-input__input" id="signin-password" name="password" type="password" autoComplete="current-password" spellCheck="false" autocapitalize="none" />
<button className="ggds-button ggds-button--secondary ggds-password-input__toggle" type="button" aria-controls="signin-password" aria-label="Show password" hidden>Show</button>
</div>
</div>
<button className="ggds-button" type="submit">Sign in</button>
</form>
<p><a href="/sign-in/forgotten-password/">Forgotten your password?</a></p>
<p>No account yet? <a href="/create-account/">Create an account</a>.</p>
</>Example: Wrong phone number or password
<div class="ggds-error-summary" data-ggds-module="error-summary" role="alert" aria-labelledby="signin-error-title" tabindex="-1">
<h2 class="ggds-error-summary__title" id="signin-error-title">There is a problem</h2>
<ul class="ggds-error-summary__list"><li><a href="#signin-wrong-phone">The phone number or password is not right</a></li></ul>
</div>
<h1>Sign in to your business account</h1>
<form action="/sign-in/" method="post" novalidate>
<div class="ggds-field ggds-field--error">
<label class="ggds-label" for="signin-wrong-phone">Phone number</label>
<p class="ggds-error-message" id="signin-wrong-phone-error"><span class="ggds-visually-hidden">Error:</span> The phone number or password is not right</p>
<input class="ggds-input ggds-input--width-medium" id="signin-wrong-phone" name="phone" type="tel" autocomplete="tel" inputmode="tel" aria-describedby="signin-wrong-phone-error" aria-invalid="true" value="024 123 4567">
</div>
<div class="ggds-field ggds-password-input" data-ggds-module="password-input">
<label class="ggds-label" for="signin-wrong-password">Password</label>
<div class="ggds-password-input__wrapper">
<input class="ggds-input ggds-password-input__input" id="signin-wrong-password" name="password" type="password" autocomplete="current-password" spellcheck="false" autocapitalize="none">
<button class="ggds-button ggds-button--secondary ggds-password-input__toggle" type="button" aria-controls="signin-wrong-password" aria-label="Show password" hidden>Show</button>
</div>
</div>
<button class="ggds-button" type="submit">Sign in</button>
</form>
<p><a href="/sign-in/forgotten-password/">Forgotten your password?</a></p><>
<div className="ggds-error-summary" data-ggds-module="error-summary" role="alert" aria-labelledby="signin-error-title" tabIndex={-1}>
<h2 className="ggds-error-summary__title" id="signin-error-title">There is a problem</h2>
<ul className="ggds-error-summary__list"><li><a href="#signin-wrong-phone">The phone number or password is not right</a></li></ul>
</div>
<h1>Sign in to your business account</h1>
<form action="/sign-in/" method="post" noValidate>
<div className="ggds-field ggds-field--error">
<label className="ggds-label" htmlFor="signin-wrong-phone">Phone number</label>
<p className="ggds-error-message" id="signin-wrong-phone-error"><span className="ggds-visually-hidden">Error:</span> The phone number or password is not right</p>
<input className="ggds-input ggds-input--width-medium" id="signin-wrong-phone" name="phone" type="tel" autoComplete="tel" inputMode="tel" aria-describedby="signin-wrong-phone-error" aria-invalid="true" defaultValue="024 123 4567" />
</div>
<div className="ggds-field ggds-password-input" data-ggds-module="password-input">
<label className="ggds-label" htmlFor="signin-wrong-password">Password</label>
<div className="ggds-password-input__wrapper">
<input className="ggds-input ggds-password-input__input" id="signin-wrong-password" name="password" type="password" autoComplete="current-password" spellCheck="false" autocapitalize="none" />
<button className="ggds-button ggds-button--secondary ggds-password-input__toggle" type="button" aria-controls="signin-wrong-password" aria-label="Show password" hidden>Show</button>
</div>
</div>
<button className="ggds-button" type="submit">Sign in</button>
</form>
<p><a href="/sign-in/forgotten-password/">Forgotten your password?</a></p>
</>Example: Check it is them with a code
<a class="ggds-back-link" href="/sign-in/">Back</a>
<h1>Check your phone</h1>
<form action="/sign-in/code/" method="post" novalidate>
<div class="ggds-field">
<label class="ggds-label" for="signin-code">Enter the code we sent you</label>
<p class="ggds-hint" id="signin-code-hint">We sent a 6-digit code to 024 *** 4567. It expires in 10 minutes.</p>
<input class="ggds-input ggds-input--code" id="signin-code" name="code" type="text" inputmode="numeric" autocomplete="one-time-code" spellcheck="false" aria-describedby="signin-code-hint">
</div>
<button class="ggds-button" type="submit">Continue</button>
</form>
<p><a href="/sign-in/code/new/">Send a new code</a></p>
<p><a href="/sign-in/code/email/">Get a code by email instead</a></p><>
<a className="ggds-back-link" href="/sign-in/">Back</a>
<h1>Check your phone</h1>
<form action="/sign-in/code/" method="post" noValidate>
<div className="ggds-field">
<label className="ggds-label" htmlFor="signin-code">Enter the code we sent you</label>
<p className="ggds-hint" id="signin-code-hint">We sent a 6-digit code to 024 *** 4567. It expires in 10 minutes.</p>
<input className="ggds-input ggds-input--code" id="signin-code" name="code" type="text" inputMode="numeric" autoComplete="one-time-code" spellCheck="false" aria-describedby="signin-code-hint" />
</div>
<button className="ggds-button" type="submit">Continue</button>
</form>
<p><a href="/sign-in/code/new/">Send a new code</a></p>
<p><a href="/sign-in/code/email/">Get a code by email instead</a></p>
</>Example: Signed out after the session ended
<h1>You have been signed out</h1>
<p>We signed you out because you had not done anything for 20 minutes. This protects your information.</p>
<p>Your answers are saved. Sign in again to carry on where you left off.</p>
<a class="ggds-button" href="/sign-in/">Sign in</a><>
<h1>You have been signed out</h1>
<p>We signed you out because you had not done anything for 20 minutes. This protects your information.</p>
<p>Your answers are saved. Sign in again to carry on where you left off.</p>
<a className="ggds-button" href="/sign-in/">Sign in</a>
</>Components used
Something wrong, unclear or missing? or suggest a change to it on GitHub. You need a GitHub account.