Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F118265777
PhabricatorAuthProviderPersona.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
Wed, Jun 18, 21:08
Size
1 KB
Mime Type
text/x-php
Expires
Fri, Jun 20, 21:08 (2 d)
Engine
blob
Format
Raw Data
Handle
26844876
Attached To
rPH Phabricator
PhabricatorAuthProviderPersona.php
View Options
<?php
final
class
PhabricatorAuthProviderPersona
extends
PhabricatorAuthProvider
{
private
$adapter
;
public
function
getProviderName
()
{
return
pht
(
'Persona'
);
}
public
function
getDescriptionForCreate
()
{
return
pht
(
'Allow users to login or register using Mozilla Persona.'
);
}
public
function
getAdapter
()
{
if
(!
$this
->
adapter
)
{
$adapter
=
new
PhutilAuthAdapterPersona
();
$this
->
adapter
=
$adapter
;
}
return
$this
->
adapter
;
}
protected
function
renderLoginForm
(
AphrontRequest
$request
,
$mode
)
{
Javelin
::
initBehavior
(
'persona-login'
,
array
(
'loginURI'
=>
$this
->
getLoginURI
(),
));
return
$this
->
renderStandardLoginButton
(
$request
,
$mode
,
array
(
'uri'
=>
$this
->
getLoginURI
(),
'sigil'
=>
'persona-login-form'
,
));
}
public
function
isLoginFormAButton
()
{
return
true
;
}
public
function
processLoginRequest
(
PhabricatorAuthLoginController
$controller
)
{
$request
=
$controller
->
getRequest
();
$adapter
=
$this
->
getAdapter
();
$account
=
null
;
$response
=
null
;
if
(!
$request
->
isAjax
())
{
throw
new
Exception
(
"Expected this request to come via Ajax."
);
}
$assertion
=
$request
->
getStr
(
'assertion'
);
if
(!
$assertion
)
{
throw
new
Exception
(
"Expected identity assertion."
);
}
$adapter
->
setAssertion
(
$assertion
);
$adapter
->
setAudience
(
PhabricatorEnv
::
getURI
(
'/'
));
try
{
$account_id
=
$adapter
->
getAccountID
();
}
catch
(
Exception
$ex
)
{
// TODO: Handle this in a more user-friendly way.
throw
$ex
;
}
return
array
(
$this
->
loadOrCreateAccount
(
$account_id
),
$response
);
}
}
Event Timeline
Log In to Comment