From 37a767ad48e4a8f621f4fa5579fded71881a2766 Mon Sep 17 00:00:00 2001 From: Victor Dubiniuk Date: Sat, 10 Aug 2013 01:18:19 +0300 Subject: [PATCH] Generate memberId on joinig the session --- ajax/controller.php | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/ajax/controller.php b/ajax/controller.php index dc0a2880..e7293156 100644 --- a/ajax/controller.php +++ b/ajax/controller.php @@ -43,12 +43,13 @@ class Controller { $session = Session::add($genesisPath, $hash, $path); } - $session['member_id'] = Member::add($session['es_id'], \OCP\User::getDisplayName(), '#00f000'); + $session['member_id'] = Member::add($session['es_id'], \OCP\User::getUser(), '#00f000'); \OCP\JSON::success($session); exit(); } catch (\Exception $e){ - throw $e; + //TODO: Log + throw $e; //Debug } } \OCP\JSON::error(); @@ -66,12 +67,18 @@ class Controller { public static function joinSession($args){ $esId = @$args['es_id']; \OCP\JSON::checkLoggedIn(); - - if ($esId){ - $session = Session::getSession($esId); - // !TODO: return member_id here ??? - \OCP\JSON::success($session); - exit(); + try { + if ($esId){ + $session = Session::getSession($esId); + + $session['member_id'] = Member::add($session['es_id'], \OCP\User::getUser(), '#00f000'); + \OCP\JSON::success($session); + exit(); + } + + throw new \Exception(); + } catch (\Exception $e){ + //TODO: Log } \OCP\JSON::error(); }