Skip to content

Commit

Permalink
Improve account-disabled error messages.
Browse files Browse the repository at this point in the history
  • Loading branch information
kohler committed Sep 20, 2023
1 parent a3342c7 commit 3dfaec7
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 4 deletions.
1 change: 1 addition & 0 deletions etc/msgs.json
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@
["badpost", "<0>Your browser session has changed since you last used this tab. Please try again."],
["session_failed_error", "<0>You appear to have disabled cookies in your browser. This site requires cookies to function."],

["account_disabled", "<0>Your account on this site has been disabled by a site administrator"],
["signin_error", "{message:ftext}"],
["signin_error", "<5>User {email} does not currently have an account. Double-check the email address, or <a href=\"{newaccount}\">create the account</a> if you’d like.", ["{context}=no_account", "{newaccount}"]],
["signin_error", "<5>{message:ftext}. Use <a href=\"{forgotpassword}\">“Forgot your password?”</a> to reset it.", ["{context}=password_expired", "{forgotpassword}"]],
Expand Down
2 changes: 1 addition & 1 deletion index.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ function handle_request($nav) {
if (!$pagej || str_starts_with($pagej->name, "__")) {
Multiconference::fail($qreq, 404, ["link" => true], "<0>Page not found");
} else if ($user->is_disabled() && !($pagej->allow_disabled ?? false)) {
Multiconference::fail($qreq, 403, ["link" => true], "<0>Your account is disabled");
Multiconference::fail($qreq, 403, ["link" => true], $user->conf->_i("account_disabled"));
} else {
$pc->set_root($pagej->group);
handle_request_components($user, $qreq, $pagej->group, $pc);
Expand Down
7 changes: 7 additions & 0 deletions lib/fmt.php
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,13 @@ function addj($m) {
}
}

/** @param string $id
* @param string $otext
* @param null|float|int $priority */
function define_template($id, $otext, $priority = null) {
$this->_addj_object((object) ["id" => $id, "otext" => $otext, "priority" => $priority, "template" => true]);
}

/** @param string $id
* @return bool */
function has_override($id) {
Expand Down
2 changes: 1 addition & 1 deletion lib/login.php
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ static function login_error(Conf $conf, $email, $info, $ms) {
$args[] = new FmtArg("newaccount", $conf->hoturl_raw("newaccount", ["email" => $email]));
}
} else if (isset($info["disabled"])) {
$e = "<0>Your account on this site is disabled. Contact the site administrator for more information.";
$e = $conf->_i("account_disabled");
} else if (isset($info["reset"])) {
$e = "<0>Your password has expired";
$args[] = new FmtArg("context", "password_expired");
Expand Down
3 changes: 2 additions & 1 deletion src/conference.php
Original file line number Diff line number Diff line change
Expand Up @@ -4923,6 +4923,7 @@ function fmt() {
if (($mlist = $this->opt("messageOverrides"))) {
expand_json_includes_callback($mlist, [$this->_fmt, "addj"]);
}
$this->_fmt->define_template("site", "<0>" . $this->opt["paperSite"]);
}
if ($this->_fmt_override_names !== null) {
foreach ($this->_fmt_override_names as $id) {
Expand Down Expand Up @@ -5131,7 +5132,7 @@ function call_api_on($uf, $fn, Contact $user, Qrequest $qreq, $prow) {
return JsonResult::make_error(403, "<0>Missing credentials");
} else if ($user->is_disabled()
&& (!$uf || !($uf->allow_disabled ?? false))) {
return JsonResult::make_error(403, "<0>Your account is disabled");
return JsonResult::make_error(403, "<0>Disabled account");
} else if (!$uf) {
if ($this->has_api($fn, $user, null)) {
return JsonResult::make_error(405, "<0>Method not supported");
Expand Down
2 changes: 1 addition & 1 deletion src/pages/p_home.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ function __construct(Contact $user) {

static function disabled_request(Contact $user, Qrequest $qreq) {
if (!$user->is_empty() && $user->is_disabled()) {
$user->conf->warning_msg($user->conf->_i("account_disabled"));
$qreq->print_header("Account disabled", "home", ["action_bar" => ""]);
$user->conf->warning_msg("<0>Your account on this site has been disabled by a site administrator. Please contact them with questions.");
$qreq->print_footer();
exit;
}
Expand Down

0 comments on commit 3dfaec7

Please sign in to comment.