Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F93092478
PhabricatorAuthFactorProviderDuoHostnameTransaction.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Tue, Nov 26, 04:01
Size
1 KB
Mime Type
text/x-php
Expires
Thu, Nov 28, 04:01 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
22574143
Attached To
rPH Phabricator
PhabricatorAuthFactorProviderDuoHostnameTransaction.php
View Options
<?php
final
class
PhabricatorAuthFactorProviderDuoHostnameTransaction
extends
PhabricatorAuthFactorProviderTransactionType
{
const
TRANSACTIONTYPE
=
'duo.hostname'
;
public
function
generateOldValue
(
$object
)
{
$key
=
PhabricatorDuoAuthFactor
::
PROP_HOSTNAME
;
return
$object
->
getAuthFactorProviderProperty
(
$key
);
}
public
function
applyInternalEffects
(
$object
,
$value
)
{
$key
=
PhabricatorDuoAuthFactor
::
PROP_HOSTNAME
;
$object
->
setAuthFactorProviderProperty
(
$key
,
$value
);
}
public
function
getTitle
()
{
return
pht
(
'%s changed the hostname for this provider from %s to %s.'
,
$this
->
renderAuthor
(),
$this
->
renderOldValue
(),
$this
->
renderNewValue
());
}
public
function
validateTransactions
(
$object
,
array
$xactions
)
{
$errors
=
array
();
if
(!
$this
->
isDuoProvider
(
$object
))
{
return
$errors
;
}
$old_value
=
$this
->
generateOldValue
(
$object
);
if
(
$this
->
isEmptyTextTransaction
(
$old_value
,
$xactions
))
{
$errors
[]
=
$this
->
newRequiredError
(
pht
(
'Duo providers must have an API hostname.'
));
}
foreach
(
$xactions
as
$xaction
)
{
$new_value
=
$xaction
->
getNewValue
();
if
(!
strlen
(
$new_value
))
{
continue
;
}
if
(
$new_value
===
$old_value
)
{
continue
;
}
try
{
PhabricatorDuoAuthFactor
::
requireDuoAPIHostname
(
$new_value
);
}
catch
(
Exception
$ex
)
{
$errors
[]
=
$this
->
newInvalidError
(
$ex
->
getMessage
(),
$xaction
);
continue
;
}
}
return
$errors
;
}
}
Event Timeline
Log In to Comment