Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F93094655
PhabricatorAuthFactorProviderEditController.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:26
Size
2 KB
Mime Type
text/x-php
Expires
Thu, Nov 28, 04:26 (2 d)
Engine
blob
Format
Raw Data
Handle
22574582
Attached To
rPH Phabricator
PhabricatorAuthFactorProviderEditController.php
View Options
<?php
final
class
PhabricatorAuthFactorProviderEditController
extends
PhabricatorAuthFactorProviderController
{
public
function
handleRequest
(
AphrontRequest
$request
)
{
$this
->
requireApplicationCapability
(
AuthManageProvidersCapability
::
CAPABILITY
);
$engine
=
id
(
new
PhabricatorAuthFactorProviderEditEngine
())
->
setController
(
$this
);
$id
=
$request
->
getURIData
(
'id'
);
if
(!
$id
)
{
$factor_key
=
$request
->
getStr
(
'providerFactorKey'
);
$map
=
PhabricatorAuthFactor
::
getAllFactors
();
$factor
=
idx
(
$map
,
$factor_key
);
if
(!
$factor
)
{
return
$this
->
buildFactorSelectionResponse
();
}
$engine
->
addContextParameter
(
'providerFactorKey'
,
$factor_key
)
->
setProviderFactor
(
$factor
);
}
return
$engine
->
buildResponse
();
}
private
function
buildFactorSelectionResponse
()
{
$request
=
$this
->
getRequest
();
$viewer
=
$this
->
getViewer
();
$cancel_uri
=
$this
->
getApplicationURI
(
'mfa/'
);
$factors
=
PhabricatorAuthFactor
::
getAllFactors
();
$menu
=
id
(
new
PHUIObjectItemListView
())
->
setUser
(
$viewer
)
->
setBig
(
true
)
->
setFlush
(
true
);
$factors
=
msortv
(
$factors
,
'newSortVector'
);
foreach
(
$factors
as
$factor_key
=>
$factor
)
{
$factor_uri
=
id
(
new
PhutilURI
(
'/mfa/edit/'
))
->
setQueryParam
(
'providerFactorKey'
,
$factor_key
);
$factor_uri
=
$this
->
getApplicationURI
(
$factor_uri
);
$is_enabled
=
$factor
->
canCreateNewProvider
();
$item
=
id
(
new
PHUIObjectItemView
())
->
setHeader
(
$factor
->
getFactorName
())
->
setImageIcon
(
$factor
->
newIconView
())
->
addAttribute
(
$factor
->
getFactorCreateHelp
());
if
(
$is_enabled
)
{
$item
->
setHref
(
$factor_uri
)
->
setClickable
(
true
);
}
else
{
$item
->
setDisabled
(
true
);
}
$create_description
=
$factor
->
getProviderCreateDescription
();
if
(
$create_description
)
{
$item
->
appendChild
(
$create_description
);
}
$menu
->
addItem
(
$item
);
}
return
$this
->
newDialog
()
->
setTitle
(
pht
(
'Choose Provider Type'
))
->
appendChild
(
$menu
)
->
addCancelButton
(
$cancel_uri
);
}
}
Event Timeline
Log In to Comment