2012-05-07 21:54:44 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
2014-05-22 07:33:40 +00:00
|
|
|
* Proxy page that redirects to the proper OATH special page
|
2012-05-07 21:54:44 +00:00
|
|
|
*/
|
2014-05-22 07:33:40 +00:00
|
|
|
class SpecialOATH extends ProxySpecialPage {
|
2014-05-11 08:16:03 +00:00
|
|
|
/**
|
2014-05-22 07:33:40 +00:00
|
|
|
* If the user already has OATH enabled, show them a page to disable
|
|
|
|
* If the user has OATH disabled, show them a page to enable
|
2014-05-11 08:16:03 +00:00
|
|
|
*
|
2014-05-27 18:00:21 +00:00
|
|
|
* @return SpecialOATHDisable|SpecialOATHEnable|SpecialOATHLogin|SpecialPage
|
2012-05-07 21:54:44 +00:00
|
|
|
*/
|
2014-05-22 07:33:40 +00:00
|
|
|
protected function getTargetPage() {
|
2015-05-25 23:47:03 +00:00
|
|
|
$repo = OATHAuthHooks::getOATHUserRepository();
|
2012-05-07 21:54:44 +00:00
|
|
|
|
2014-05-27 18:00:21 +00:00
|
|
|
/** @var array $sessionUser */
|
|
|
|
$loginInfo = $this->getRequest()->getSessionData( 'oath_login' );
|
|
|
|
|
|
|
|
/** @var SpecialOATHDisable|SpecialOATHEnable|SpecialOATHLogin|SpecialPage $page */
|
|
|
|
$page = null;
|
|
|
|
if ( $this->getUser()->isAnon() && $loginInfo !== null ) {
|
|
|
|
// User is anonymous, so they are logging in
|
|
|
|
$page = new SpecialOATHLogin(
|
|
|
|
$repo->findByUser(User::newFromName( $loginInfo['wpName'] ) ),
|
|
|
|
new DerivativeRequest(
|
|
|
|
$this->getRequest(),
|
|
|
|
$loginInfo,
|
|
|
|
$this->getRequest()->wasPosted()
|
|
|
|
)
|
|
|
|
);
|
2012-05-07 21:54:44 +00:00
|
|
|
} else {
|
2014-05-27 18:00:21 +00:00
|
|
|
$user = $repo->findByUser( $this->getUser() );
|
|
|
|
|
|
|
|
if ( $user->getKey() === null ) {
|
|
|
|
$page = new SpecialOATHEnable( $repo, $user );
|
|
|
|
} else {
|
|
|
|
$page = new SpecialOATHDisable( $repo, $user );
|
|
|
|
}
|
2012-05-07 21:54:44 +00:00
|
|
|
}
|
2014-05-27 18:00:21 +00:00
|
|
|
|
|
|
|
return $page;
|
2012-05-07 21:54:44 +00:00
|
|
|
}
|
|
|
|
|
2015-06-23 18:57:40 +00:00
|
|
|
protected function getGroupName() {
|
|
|
|
return 'oath';
|
|
|
|
}
|
2012-05-07 21:54:44 +00:00
|
|
|
}
|