Skip to main content

This is a draft (version 0.5.0). The National Information Technology Agency (NITA) plans to make GGDS official guidance for government websites after independent accessibility testing. What this means

Ghana Government Design System Design system for Government of Ghana websites – home Search

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

  1. Sign in: a phone number (or email address) and a password with a Show button, on one page.
  2. Check it is them: a 6-digit code by SMS, which their phone can fill in. Offer email as another way.
  3. While signed in: a timeout warning on every page, 2 minutes before the end of the session.
  4. 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" (or email) and autocomplete="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

Open this example on its own page

HTML code for “The sign-in page”
HTML
<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>
JSX (React)
<>
  <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

Open this example on its own page

HTML code for “Wrong phone number or password”
HTML
<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>
JSX (React)
<>
  <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

Open this example on its own page

HTML code for “Check it is them with a code”
HTML
<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>
JSX (React)
<>
  <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

Open this example on its own page

HTML code for “Signed out after the session ended”
HTML
<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>
JSX (React)
<>
  <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

  • Text input, textarea, select and file upload

    A single form question with a label, an optional hint and an error message.

  • Password input

    A password field with a Show button, so people can check what they typed before they send it.

  • Code input

    One box for a code people receive by SMS or email, which their phone can fill in for them.

  • Error summary

    A box at the top of the page that lists every problem after a form is submitted.

  • Timeout warning

    Warns people before they are signed out for being inactive, and lets them stay signed in with one button.

  • Button

    Buttons do things: submit a form, save, continue.

Back to top

Something wrong, unclear or missing? Report a problem with this page or suggest a change to it on GitHub. You need a GitHub account.