Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Allow extensible user attribute information to be stored.

  • Loading branch information...
commit cb2cd5cfa95186686ac2809344f265695c595b57 1 parent 20c6cb5
@JeffRMoore JeffRMoore authored
Showing with 45 additions and 18 deletions.
  1. +45 −18 Solar/Auth.php
View
63 Solar/Auth.php
@@ -166,6 +166,7 @@ class Solar_Auth extends Solar_Base {
'moniker',
'uri',
'uid',
+ 'info',
);
/**
@@ -242,6 +243,11 @@ public function __get($key)
if ($key == 'status' && ! $val) {
$val = Solar_Auth::ANON;
}
+
+ // special behavior for 'info'
+ if ($key == 'info' && ! $val) {
+ $val = array();
+ }
return $val;
}
@@ -406,6 +412,41 @@ public function isValid()
{
return $this->status == Solar_Auth::VALID;
}
+
+ /**
+ *
+ * Set user information. Only serializable information may be included.
+ *
+ * @param array $info Array of user attributes
+ *
+ * @return void
+ *
+ */
+ protected function _setInfo($info = array())
+ {
+ // baseline user information
+ $base = array(
+ 'handle' => null,
+ 'moniker' => null,
+ 'email' => null,
+ 'uri' => null,
+ 'uid' => null,
+ );
+
+ // Set default values for require info keys
+ $info = array_merge($base, (array) $info);
+
+ // Store any additional information gathered from the login protocol
+ // or from the backend storage.
+ $this->info = $info;
+
+ // For historical reasons, some user attributes get their own properties
+ $this->handle = $info['handle'];
+ $this->moniker = $info['moniker'];
+ $this->email = $info['email'];
+ $this->uri = $info['uri'];
+ $this->uid = $info['uid'];
+ }
/**
*
@@ -426,16 +467,8 @@ public function isValid()
*/
public function reset($status = Solar_Auth::ANON, $info = array())
{
- // baseline user information
- $base = array(
- 'handle' => null,
- 'moniker' => null,
- 'email' => null,
- 'uri' => null,
- 'uid' => null,
- );
-
- // reset the status
+
+ // canonicalize the status value
$this->status = strtoupper($status);
// change properties
@@ -451,14 +484,8 @@ public function reset($status = Solar_Auth::ANON, $info = array())
$info = null;
}
- // set the user-info properties
- $info = array_merge($base, (array) $info);
- $this->handle = $info['handle'];
- $this->moniker = $info['moniker'];
- $this->email = $info['email'];
- $this->uri = $info['uri'];
- $this->uid = $info['uid'];
-
+ $this->_setInfo($info);
+
// reset the session id and delete previous session
$this->_session->regenerateId();
Please sign in to comment.
Something went wrong with that request. Please try again.