Return null if user not exists in redis
Change-Id: If97451faac10b33dae152ec2625032e5ff6a4548
diff --git a/redis.php b/redis.php
index edd0f6f..11333ff 100755
--- a/redis.php
+++ b/redis.php
@@ -18,9 +18,12 @@
function redis_get_user($key) {
$redis = connect();
$data = json_decode($redis->get($key));
- $user = new User($data->user_name, $data->first_name, $data->last_name, $data->email, $data->password, $data->organization);
-
- return $user;
+ if ($data && gettype($data) == "object") {
+ $user = new User($data->user_name, $data->first_name, $data->last_name, $data->email, $data->password, $data->organization);
+ return $user;
+ } else {
+ return null;
+ }
}
function redis_set($key, $data, $timeout=null){