Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Paste
P7694
(An Untitled Masterwork)
Active
Public
Actions
Authored by
TheDJ
on Oct 18 2018, 7:01 PM.
Edit Paste
Archive Paste
View Raw File
Subscribe
Mute Notifications
Award Token
Flag For Later
Tags
None
Referenced Files
F26623969:
Oct 18 2018, 7:01 PM
2018-10-18 19:01:19 (UTC+0)
Subscribers
None
<?php
namespace
MediaWiki\Auth
;
class
ConfirmNoEmailSecondaryAuthenticationProvider
extends
AbstractSecondaryAuthenticationProvider
{
public
function
getAuthenticationRequests
(
$action
,
array
$options
)
{
return
[];
}
public
function
beginSecondaryAuthentication
(
$user
,
array
$reqs
)
{
return
AuthenticationResponse
::
newAbstain
();
}
public
function
beginSecondaryAccountCreation
(
$user
,
$creator
,
array
$reqs
)
{
if
(
$user
->
getEmail
()
)
{
wfDebug
(
'User already has an emailaddress'
);
return
AuthenticationResponse
::
newAbstain
();
}
wfDebug
(
'Lets go ask for an emailaddress'
);
$request
=
new
ConfirmNoEmailRequest
();
return
AuthenticationResponse
::
newUI
(
[
$request
],
wfMessage
(
'authprovider-confirmnoemail-message'
),
'warning'
);
}
public
function
continueSecondaryAccountCreation
(
$user
,
$creator
,
array
$reqs
)
{
wfDebug
(
'Check for all the secondary account stuff from confirmnoemail: '
.
count
(
$reqs
)
);
/** @var ConfirmNoEmailRequest $req */
$req
=
AuthenticationRequest
::
getRequestByClass
(
$reqs
,
ConfirmNoEmailRequest
::
class
);
if
(!
$req
)
{
wfDebug
(
'No request, start one ?'
);
$request
=
new
ConfirmNoEmailRequest
();
return
AuthenticationResponse
::
newUI
([
$request
],
wfMessage
(
'authprovider-confirmnoemail-message'
),
'warning'
);
}
wfDebug
(
'We found our result ?'
);
/** @var \StatusValue $result */
$result
=
$req
->
addEmailToUser
(
$user
);
if
(
$result
->
isGood
())
{
wfDebug
(
'email step is good'
);
return
AuthenticationResponse
::
newPass
();
}
wfDebug
(
'email step is bad'
);
// TODO NOT ok, improve
$request
=
new
ConfirmNoEmailRequest
();
return
AuthenticationResponse
::
newUI
(
[
$request
],
wfMessage
(
'authprovider-confirmnoemail-message'
),
'warning'
);
}
}
Event Timeline
TheDJ
created this paste.
Oct 18 2018, 7:01 PM
2018-10-18 19:01:19 (UTC+0)
Log In to Comment