Refactor status messages display on user registration/authorization

Created on 24 April 2018, over 7 years ago
Updated 19 August 2025, 2 months ago

Problem/Motivation

The OpenIDConnect::completeAuthorization() method checks, whether a new user can be registered by the OpenID Connect module or administrators only can register new users or have to unblock newly created accounts first and creates an according status message.
The OpenIDConnectRedirectController::authenticate() method adds status messages, if a user can not be authorized for any reason.

In order to avoid two status messages like "Thank you for applying for an account. Your account is currently pending approval by the site administrator." and "Logging in with @provider could not be completed due to an error." at the same time, the redirect controller has to check the registration mode as well.

Proposed resolution

Two approaches would suffice:

  • Create authorization related status messages in only one of OpenIDConnect::completeAuthorization() or OpenIDConnectRedirectController::authenticate(), or
  • provide a service method returning the registration mode, so we can avoid duplicated code for registration mode checks in the redirect controller and the OpenID Connect service.

Remaining tasks

Decide for a way to go and create an according patch.

User interface changes

None.

API changes

None.

Data model changes

None.

📌 Task
Status

Active

Version

1.0

Component

Code

Created by

🇭🇰Hong Kong Mario Steinitz Hong Kong Central

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇨🇦Canada teknocat

    This is still an issue in the 3.x branch and would be ideal to have a solution for.

  • 🇨🇦Canada teknocat

    Having a look at the code, it looks like the completeAuthorization function should be able to take care of this.

    It is supposed to only display the message 'The username %name has not been activated or is blocked.' if $context['is_new'] is empty. But this is always empty because a few lines above that when creating a new account, it does not add 'is_new' with a value of TRUE to the $context array, it just passes $context with that added on the fly into the saveUserinfo method. That's an easy fix by adding a line prior to the call to $this->saveUserinfo() that sets $context['is_new'] = TRUE;.

    Then if the account is blocked but is new and pending administrator approval it should just return TRUE. That will make the controller think everything was hunky-dory and thus prevent the second error message from being displayed saying that logging in with the specified method could not be completed due to an error.

    I'll update this issue to apply to the 3.x branch and submit a patch once I can try this out, test and make sure it works.

  • @teknocat opened merge request.
Production build 0.71.5 2024