Skip to content

List token names that have expired in email

What does this MR do and why?

This MR aims to include the expired personal access token names in the email that's sent to the user to make it easier for the user to act upon.

Resolves Include name of expiring access token(s) in ema... (#375275 - closed)

Screenshots or screen recordings

Screenshots taken from LetterOpenerWeb at http://127.0.0.1:3001/rails/letter_opener/ (normally it runs on port 3000, but I have multiple GDK's running, so it's 3001 for me):

Where token_names is empty

HTML

image

Text

SCR-20230105-jfc

Where token_names isn't empty

HTML

SCR-20230105-jdv

Text

SCR-20230105-jdz

How to set up and validate locally

  1. In your local GitLab instance, create a new PAT via http://127.0.0.1:3000/-/profile/personal_access_tokens for the root user called expired. It doesn't matter what scopes or expiration date you set.
  2. Bring up a rails console, e.g. gdk rails c.
  3. Run the following to force the expiration of the PAT and send the email:
    user = User.find_by_username('root')
    user.personal_access_tokens.where(name: 'expired').first.update!(expires_at: Date.today)    
    PersonalAccessTokens::ExpiredNotificationWorker.new.perform
  4. Visit http://127.0.0.1:3000/rails/letter_opener/ to confirm you see the correct emails.

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #375275 (closed)

Edited by Ash McKenzie

Merge request reports