aboutsummaryrefslogtreecommitdiff
path: root/RedirectAuth.php
diff options
context:
space:
mode:
authorMartin Fischer <martin@push-f.com>2022-10-13 10:17:51 +0200
committerMartin Fischer <martin@push-f.com>2022-10-13 10:21:37 +0200
commit46a49fbb9d856452580e8ff07185a500ab4861f6 (patch)
tree08fa621542b8be50f5c367af4cc94a7acbf50b30 /RedirectAuth.php
parent640f5d2faa3ce1319d9faed0993597b1deaf8b3c (diff)
gracefully handle invalid usernames from ProviderDetailsHEADmaster
Previously we treated the case that a configured ProviderDetails returned an invalid username as an irrecoverable error but it makes more sense to just instead ask the user to pick a different username.
Diffstat (limited to 'RedirectAuth.php')
-rw-r--r--RedirectAuth.php12
1 files changed, 4 insertions, 8 deletions
diff --git a/RedirectAuth.php b/RedirectAuth.php
index cd73e19..0d09f3d 100644
--- a/RedirectAuth.php
+++ b/RedirectAuth.php
@@ -214,19 +214,15 @@ class RedirectAuthProvider extends AbstractPrimaryAuthenticationProvider {
// The external user id has not yet been linked to a wiki account.
$user = $userFactory->newFromName($userInfo->userName, UserFactory::RIGOR_CREATABLE);
- if ($req instanceof OtherUsernameAuthRequest) {
- if ($user == null) {
- return AuthenticationResponse::newUI([new OtherUsernameAuthRequest($userInfo)], WfMessage('redirectauth-pick-other-username-invalid'));
- } else if ($user->isRegistered()) {
- return AuthenticationResponse::newUI([new OtherUsernameAuthRequest($userInfo)], WfMessage('redirectauth-pick-other-username-taken', $userInfo->userName));
- }
- }
if ($user == null) {
- return AuthenticationResponse::newFail(wfMessage('redirectauth-error-invalid-username', 'ProviderDetails'));
+ return AuthenticationResponse::newUI([new OtherUsernameAuthRequest($userInfo)], WfMessage('redirectauth-pick-other-username-invalid'));
}
if ($user->isRegistered()) {
// namespace collision
+ if ($req instanceof OtherUsernameAuthRequest) {
+ return AuthenticationResponse::newUI([new OtherUsernameAuthRequest($userInfo)], WfMessage('redirectauth-pick-other-username-taken', $userInfo->userName));
+ }
// We create the link manually because if the system message contained [[User:$1|]] MediaWiki would create an
// action=edit link in case the user page doesn't exist ... and linking an edit page would be confusing.