FEATURE: Add safe-mode toggle to /u/admin-login (#17930)

Previously, this would require manually adding `?safe_mode=...` multiple times during the email-based login flow. `/u/admin-login` is often used when debugging a site, so it makes sense for this to be easier.

This commit introduces a new checkbox on the `/u/admin-login` screen. When checked, it'll set the safe_mode parameter on the `/email-login` link, and then pass it all the way through to the homepage redirect.
This commit is contained in:
David Taylor
2022-08-15 15:30:07 +01:00
committed by GitHub
parent 64a66cf82b
commit 3ffc213fa9
6 changed files with 71 additions and 2 deletions

View File

@ -961,7 +961,11 @@ class UsersController < ApplicationController
if user = User.with_email(params[:email]).admins.human_users.first
email_token = user.email_tokens.create!(email: user.email, scope: EmailToken.scopes[:email_login])
Jobs.enqueue(:critical_user_email, type: "admin_login", user_id: user.id, email_token: email_token.token)
token_string = email_token.token
if params["use_safe_mode"]
token_string += "?safe_mode=no_plugins,no_themes"
end
Jobs.enqueue(:critical_user_email, type: "admin_login", user_id: user.id, email_token: token_string)
@message = I18n.t("admin_login.success")
else
@message = I18n.t("admin_login.errors.unknown_email_address")