Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F5313259
DebugAuthProvider
No One
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Authored By
avivey
Dec 7 2017, 1:56 PM
2017-12-07 13:56:02 (UTC+0)
Size
1 KB
Referenced Files
None
Subscribers
None
DebugAuthProvider
View Options
<?php
/**
* Drop in /extensions/ to quickly switch user accounts. For dev only!
*/
class
DebugAuthProvider
extends
PhabricatorAuthProvider
{
private
$adapter
;
public
function
getProviderName
()
{
return
'Debug'
;
}
public
function
getAdapter
()
{
if
(!
$this
->
adapter
)
{
$this
->
adapter
=
new
DebugAuthAdapter
();
}
return
$this
->
adapter
;
}
public
function
processLoginRequest
(
PhabricatorAuthLoginController
$controller
)
{
$request
=
$controller
->
getRequest
();
$username
=
$request
->
getStr
(
'username'
);
$user
=
id
(
new
PhabricatorUser
())->
loadOneWhere
(
'username = %s'
,
$username
);
if
(
$user
)
{
$account
=
id
(
new
PhabricatorExternalAccount
())
->
setUserPHID
(
$user
->
getPHID
());
return
array
(
$account
,
null
);
}
$response
=
new
Aphront400Response
();
return
array
(
null
,
$response
);
}
protected
function
renderLoginForm
(
AphrontRequest
$request
,
$mode
)
{
$users
=
id
(
new
PhabricatorPeopleQuery
())
->
setViewer
(
PhabricatorUser
::
getOmnipotentUser
())
->
execute
();
$icon
=
id
(
new
PHUIIconView
())
->
setSpriteSheet
(
PHUIIconView
::
SPRITE_LOGIN
)
->
setSpriteIcon
(
$this
->
getLoginIcon
());
$login_uri
=
$this
->
getLoginURI
();
$buttons
=
array
();
foreach
(
$users
as
$user
)
{
$buttons
[]
=
id
(
new
PHUIButtonView
())
->
setTag
(
'a'
)
->
setSize
(
PHUIButtonView
::
BIG
)
->
setColor
(
PHUIButtonView
::
GREY
)
->
setIcon
(
$icon
)
->
setHref
(
hsprintf
(
'%s?username=%s'
,
$login_uri
,
$user
->
getUserName
()))
->
setText
(
$user
->
getUserName
())
->
setSubtext
(
$user
->
getRealName
());
}
return
$buttons
;
}
}
class
DebugAuthAdapter
extends
PhutilAuthAdapter
{
public
function
getAccountID
()
{
return
'moosh'
;
}
public
function
getAdapterType
()
{
return
'debug'
;
}
public
function
getAdapterDomain
()
{
return
'localhost'
;
}
}
File Metadata
Details
Attached
Mime Type
text/plain; charset=utf-8
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
864289
Default Alt Text
DebugAuthProvider (1 KB)
Attached To
Mode
P2081 DebugAuthProvider
Attached
Detach File
Event Timeline
Log In to Comment