Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F93914715
PhabricatorOAuthClientDisableController.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
Mon, Dec 2, 11:43
Size
2 KB
Mime Type
text/x-php
Expires
Wed, Dec 4, 11:43 (2 d)
Engine
blob
Format
Raw Data
Handle
22721937
Attached To
rPH Phabricator
PhabricatorOAuthClientDisableController.php
View Options
<?php
final
class
PhabricatorOAuthClientDisableController
extends
PhabricatorOAuthClientController
{
public
function
handleRequest
(
AphrontRequest
$request
)
{
$viewer
=
$this
->
getViewer
();
$client
=
id
(
new
PhabricatorOAuthServerClientQuery
())
->
setViewer
(
$viewer
)
->
withIDs
(
array
(
$request
->
getURIData
(
'id'
)))
->
requireCapabilities
(
array
(
PhabricatorPolicyCapability
::
CAN_VIEW
,
PhabricatorPolicyCapability
::
CAN_EDIT
,
))
->
executeOne
();
if
(!
$client
)
{
return
new
Aphront404Response
();
}
$done_uri
=
$client
->
getViewURI
();
$is_disable
=
!
$client
->
getIsDisabled
();
if
(
$request
->
isFormPost
())
{
$xactions
=
array
();
$xactions
[]
=
id
(
new
PhabricatorOAuthServerTransaction
())
->
setTransactionType
(
PhabricatorOAuthServerTransaction
::
TYPE_DISABLED
)
->
setNewValue
((
int
)
$is_disable
);
$editor
=
id
(
new
PhabricatorOAuthServerEditor
())
->
setActor
(
$viewer
)
->
setContentSourceFromRequest
(
$request
)
->
setContinueOnNoEffect
(
true
)
->
setContinueOnMissingFields
(
true
)
->
applyTransactions
(
$client
,
$xactions
);
return
id
(
new
AphrontRedirectResponse
())->
setURI
(
$done_uri
);
}
if
(
$is_disable
)
{
$title
=
pht
(
'Disable OAuth Application'
);
$body
=
pht
(
'Really disable the %s OAuth application? Users will no longer be '
.
'able to authenticate against it, nor access Phabricator using '
.
'tokens generated by this application.'
,
phutil_tag
(
'strong'
,
array
(),
$client
->
getName
()));
$button
=
pht
(
'Disable Application'
);
}
else
{
$title
=
pht
(
'Enable OAuth Application'
);
$body
=
pht
(
'Really enable the %s OAuth application? Users will be able to '
.
'authenticate against it, and existing tokens will become usable '
.
'again.'
,
phutil_tag
(
'strong'
,
array
(),
$client
->
getName
()));
$button
=
pht
(
'Enable Application'
);
}
return
$this
->
newDialog
()
->
setTitle
(
$title
)
->
appendParagraph
(
$body
)
->
addCancelButton
(
$done_uri
)
->
addSubmitButton
(
$button
);
}
}
Event Timeline
Log In to Comment