Skip to content

Commit

Permalink
extract methods: isUseCookieUid() and isUseMobileUid() (refs #2926)
Browse files Browse the repository at this point in the history
  • Loading branch information
balibali committed Jun 12, 2012
1 parent 4c12822 commit 75c9b9f
Showing 1 changed file with 25 additions and 10 deletions.
35 changes: 25 additions & 10 deletions lib/form/opAuthLoginFormMobileUID.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,7 @@ public function isUtn()

public function validateMobileUid($validator, $values, $arguments = array())
{
$uidType = $this->adapter->getAuthConfig('uid_type');

$isUseMobileCookie = sfConfig::get('op_is_use_mobile_cookie', true);
if (self::MUST_USE_MOBILE_UID != $uidType && $isUseMobileCookie)
if ($this->isUseCookieUid())
{
$values = $this->validateUsingMobileCookieUid($values);
if (isset($values['member']))
Expand All @@ -66,22 +63,40 @@ public function validateMobileUid($validator, $values, $arguments = array())
}
}

if (self::MUST_USE_COOKIE_UID != $uidType)
if ($this->isUseMobileUid())
{
$values = $this->validateUsingMobileUid($values);

$hasMobileCookieUid = isset($values['member']) && $values['member']->getConfig('mobile_cookie_uid');
if ($hasMobileCookieUid && $isUseMoileCookie)
if ($this->isUseCookieUid())
{
// The specified member already use mobile_cookie_uid, but this request doesn't contain the cookie.
// This request must not be allowed.
unset($values['member']);
$hasMobileCookieUid = isset($values['member']) && $values['member']->getConfig('mobile_cookie_uid');
if ($hasMobileCookieUid)
{
// The specified member already use mobile_cookie_uid, but this request doesn't contain the cookie.
// This request must not be allowed.
unset($values['member']);
}
}
}

return $values;
}

private function isUseCookieUid()
{
$uidType = $this->adapter->getAuthConfig('uid_type');
$isUseMobileCookie = sfConfig::get('op_is_use_mobile_cookie', true);

return $isUseMobileCookie && self::MUST_USE_MOBILE_UID != $uidType;
}

private function isUseMobileUid()
{
$uidType = $this->adapter->getAuthConfig('uid_type');

return self::MUST_USE_COOKIE_UID != $uidType;
}

private function validateUsingMobileCookieUid($values)
{
$validator = new opAuthValidatorMemberConfig(array(
Expand Down

0 comments on commit 75c9b9f

Please sign in to comment.