Permalink
Browse files

Merge pull request #16 from jeremiahsmall/session_storage

Session storage
  • Loading branch information...
2 parents 64cd39c + 6fee8c8 commit 549744d486eeea00aba7bfcea409b679afe6fba8 @jeremiahsmall jeremiahsmall committed Mar 10, 2013
@@ -2,11 +2,5 @@
namespace Soliant\SimpleFM\ZF2\Authentication\Adapter\Exception;
-/**
- * @uses Soliant\SimpleFM\ZF2\Authentication\Exception
- * @category Apple, Inc.
- * @package Soliant\SimpleFM\ZF2\Authentication
- * @subpackage Adapter\Exception
- */
interface ExceptionInterface extends \Zend\Authentication\Adapter\Exception\ExceptionInterface
{}
@@ -14,7 +14,7 @@
use Soliant\SimpleFM\Adapter;
use Zend\Authentication\Result;
-class Auth implements \Zend\Authentication\Adapter\AdapterInterface
+class SimpleFM implements \Zend\Authentication\Adapter\AdapterInterface
{
/**
@@ -163,24 +163,37 @@ public function authenticate()
$result = $this->simpleFmValidateAdapter->execute();
+ $error = $result['error'];
+ $errortext = $result['errortext'];
+ $errortype = $result['errortype'];
+
// Based on the status, return auth result
- switch ($result['error']) {
+ switch ($error) {
case '0':
- // Return result as identity only for status '0'
+ // Return null as identity only for error 0
$identity = new Identity($this->username, $this->password, $this->encryptionKey, $result['rows'][0]);
$identity->setIsLoggedIn(TRUE);
return new Result(
Result::SUCCESS,
$identity
);
+ case '401':
+ // Return null identity plus reason as message array for HTTP 401
+ if ($errortype == 'HTTP') {
+ $identity = null;
+ return new Result(
+ Result::FAILURE,
+ $identity,
+ array('reason' => 'Username and/or password not valid' ,'sfm_auth_response' => $result)
+ );
+ }
default:
- // Return empty identity and result as message array for every other result status
- $identity = new Identity($this->username, $this->password, $this->encryptionKey);
- $identity->setIsLoggedIn(FALSE);
+ // Return empty identity plus reason as message array for every other result status
+ $identity = null;
return new Result(
Result::FAILURE,
- array(),
- array('reason' => 'Auth request failed','sfm_auth_response' => $result)
+ $identity,
+ array('reason' => $errortype . ' error ' . $error . ': ' . $errortext ,'sfm_auth_response' => $result)
);
}
}
@@ -2,11 +2,5 @@
namespace Soliant\SimpleFM\ZF2\Authentication\Mapper\Exception;
-/**
- * @uses Soliant\SimpleFM\ZF2\Authentication\Mapper\Exception
- * @category Apple, Inc.
- * @package Soliant\SimpleFM\ZF2\Authentication
- * @subpackage Adapter\Exception
- */
interface ExceptionInterface extends \Zend\Authentication\Adapter\Exception\ExceptionInterface
{}
@@ -0,0 +1,6 @@
+<?php
+
+namespace Soliant\SimpleFM\ZF2\Authentication\Storage\Exception;
+
+interface ExceptionInterface extends \Zend\Authentication\Adapter\Exception\ExceptionInterface
+{}
@@ -0,0 +1,9 @@
+<?php
+
+namespace Soliant\SimpleFM\ZF2\Authentication\Storage\Exception;
+
+class InvalidArgumentException
+ extends \InvalidArgumentException
+ implements ExceptionInterface
+{
+}
@@ -0,0 +1,27 @@
+<?php
+/**
+ * This source file is subject to the MIT license that is bundled with this package in the file LICENSE.txt.
+ *
+ * @package Soliant\SimpleFM\ZF2
+ * @copyright Copyright (c) 2007-2013 Soliant Consulting, Inc. (http://www.soliantconsulting.com)
+ * @author jsmall@soliantconsulting.com
+ */
+
+namespace Soliant\SimpleFM\ZF2\Authentication\Storage;
+
+use Zend\Authentication\Storage\Session as ZendSession;
+
+class Session extends ZendSession
+{
+ public function setRememberMe($rememberMe = 0, $time = 1209600)
+ {
+ if ($rememberMe == 1) {
+ $this->session->getManager()->rememberMe($time);
+ }
+ }
+
+ public function forgetMe()
+ {
+ $this->session->getManager()->forgetMe();
+ }
+}

0 comments on commit 549744d

Please sign in to comment.