Skip to content
Email Recovery

Email Recovery

Setup

Email recovery lets players reset their password via a recovery code sent to their linked email.

email-recovery:
  enabled: true
  smtp:
    host: "smtp.gmail.com"
    port: 587
    username: "your-email@gmail.com"
    password: "app-password"
    from: "noreply@yourserver.com"
    tls: true        # STARTTLS, required when on (port 465 uses implicit TLS)
  code-expiry: 10    # minutes
  cooldown: 5        # minutes between requests

With tls: true the mail server has to offer STARTTLS: a server that does not is sent nothing, rather than the password and the code in clear. Its certificate also has to match the host name. The subjects and bodies of the mails are language keys (recover-mail-*, email-confirm-mail-*), so they follow the server language.

For Gmail, use an App Password (not your regular password). Enable 2-Step Verification in your Google account, then generate an app password at myaccount.google.com/apppasswords.

Player Flow

/email set user@example.com
/email confirm <code>

/email set mails a code to the address, and /email confirm links it once the code is typed back. Both, like /email remove, need a confirmed login on this connection. The email is stored in the xlogin_accounts table.

Recover password

  1. Player runs /recover <username>. XLogin sends a code of 8 letters and digits to the linked email.
  2. Player runs /recover <username> <code> <newpassword>. The code is validated and the password is reset.
  3. Player can now /login with the new password.

Codes are stored in memory (not database), expire after code-expiry minutes, and are single-use. At most 5 mails are sent per account per day.