public function testHandlePayload() { $w = new MailgunWebhook($this->container); $p = new Project($this->container); $pp = new ProjectPermission($this->container); $u = new User($this->container); $tc = new TaskCreation($this->container); $tf = new TaskFinder($this->container); $this->assertEquals(2, $u->create(array('name' => 'me', 'email' => 'me@localhost'))); $this->assertEquals(1, $p->create(array('name' => 'test1'))); $this->assertEquals(2, $p->create(array('name' => 'test2', 'identifier' => 'TEST1'))); // Empty payload $this->assertFalse($w->parsePayload(array())); // Unknown user $this->assertFalse($w->parsePayload(array('sender' => 'a@b.c', 'subject' => 'Email task', 'recipient' => 'foobar', 'stripped-text' => 'boo'))); // Project not found $this->assertFalse($w->parsePayload(array('sender' => 'me@localhost', 'subject' => 'Email task', 'recipient' => 'foo+test@localhost', 'stripped-text' => 'boo'))); // User is not member $this->assertFalse($w->parsePayload(array('sender' => 'me@localhost', 'subject' => 'Email task', 'recipient' => 'foo+test1@localhost', 'stripped-text' => 'boo'))); $this->assertTrue($pp->addMember(2, 2)); // The task must be created $this->assertTrue($w->parsePayload(array('sender' => 'me@localhost', 'subject' => 'Email task', 'recipient' => 'foo+test1@localhost', 'stripped-text' => 'boo'))); $task = $tf->getById(1); $this->assertNotEmpty($task); $this->assertEquals(2, $task['project_id']); $this->assertEquals('Email task', $task['title']); $this->assertEquals('boo', $task['description']); $this->assertEquals(2, $task['creator_id']); }
public function testHtml2Markdown() { $w = new Postmark($this->container); $p = new Project($this->container); $pp = new ProjectPermission($this->container); $u = new User($this->container); $tc = new TaskCreation($this->container); $tf = new TaskFinder($this->container); $this->assertEquals(2, $u->create(array('username' => 'me', 'email' => 'me@localhost'))); $this->assertEquals(1, $p->create(array('name' => 'test2', 'identifier' => 'TEST1'))); $this->assertTrue($pp->addMember(1, 2)); $this->assertTrue($w->receiveEmail(array('From' => 'me@localhost', 'Subject' => 'Email task', 'MailboxHash' => 'test1', 'TextBody' => 'boo', 'HtmlBody' => '<p><strong>boo</strong></p>'))); $task = $tf->getById(1); $this->assertNotEmpty($task); $this->assertEquals(1, $task['project_id']); $this->assertEquals('Email task', $task['title']); $this->assertEquals('**boo**', $task['description']); $this->assertEquals(2, $task['creator_id']); $this->assertTrue($w->receiveEmail(array('From' => 'me@localhost', 'Subject' => 'Email task', 'MailboxHash' => 'test1', 'TextBody' => '**boo**', 'HtmlBody' => ''))); $task = $tf->getById(2); $this->assertNotEmpty($task); $this->assertEquals(1, $task['project_id']); $this->assertEquals('Email task', $task['title']); $this->assertEquals('**boo**', $task['description']); $this->assertEquals(2, $task['creator_id']); }
public function run() { $iAccountID = $this->get('id'); $oAccount = new m\Account(); $aDetail = $oAccount->getAccountDetail($iAccountID); if (empty($aDetail)) { c\Router::redirect(c\Router::genURL('Home')); } $aFields = $oAccount->getAccountFields($iAccountID); $oUser = new m\User(); $aDefaultPassword = $oUser->getDefaultPassword(); $aEmails = $oUser->getEmails(); foreach ($aFields as $k => $v) { $aFields[$k]['display'] = u\Str::partCover($v['value'], 2, 1); } sort($aFields); $aFieldNames = array_map(function ($v) { foreach ($v as $key => $value) { if ($key !== 'name') { unset($v[$key]); } } return $v; }, $aFields); $aAccountAll = $oAccount->getAllAccount(); $aSiteList = []; foreach ($aAccountAll as $aAccountDetail) { $aSiteList[] = ['name' => 'link:' . $aAccountDetail['name']]; } $aData = ['page_title' => 'Open Sesame - ' . $aDetail['name'], 'app' => $aDetail, 'fields' => $aFields, 'form_action_add' => c\Router::genURL('AddField'), 'form_action_del' => c\Router::genURL('DeleteField'), 'form_action_updatefield' => c\Router::genURL('UpdateField'), 'form_action_updateaccount' => c\Router::genURL('UpdateAccount'), 'site_list' => json_encode($aSiteList), 'field_names' => json_encode($aFieldNames), 'default_password' => $aDefaultPassword['data'], 'emails' => $aEmails['data']]; return $aData; }
public function testCloneProjectWithUsers() { $p = new Project($this->container); $c = new Category($this->container); $pp = new ProjectPermission($this->container); $u = new User($this->container); $this->assertEquals(2, $u->create(array('username' => 'unittest1', 'password' => 'unittest'))); $this->assertEquals(3, $u->create(array('username' => 'unittest2', 'password' => 'unittest'))); $this->assertEquals(4, $u->create(array('username' => 'unittest3', 'password' => 'unittest'))); $this->assertEquals(1, $p->create(array('name' => 'P1'))); $this->assertTrue($pp->addMember(1, 2)); $this->assertTrue($pp->addMember(1, 4)); $this->assertTrue($pp->addManager(1, 3)); $this->assertTrue($pp->isMember(1, 2)); $this->assertTrue($pp->isMember(1, 3)); $this->assertTrue($pp->isMember(1, 4)); $this->assertFalse($pp->isManager(1, 2)); $this->assertTrue($pp->isManager(1, 3)); $this->assertFalse($pp->isManager(1, 4)); $this->assertEquals(2, $p->duplicate(1)); $project = $p->getById(2); $this->assertNotEmpty($project); $this->assertEquals('P1 (Clone)', $project['name']); $this->assertEquals(3, count($pp->getMembers(2))); $this->assertTrue($pp->isMember(2, 2)); $this->assertTrue($pp->isMember(2, 3)); $this->assertTrue($pp->isMember(2, 4)); $this->assertFalse($pp->isManager(2, 2)); $this->assertTrue($pp->isManager(2, 3)); $this->assertFalse($pp->isManager(2, 4)); }
public function saveNewUser(\model\User $newUser) { $newUser->getUserName(); $file = fopen("data/" . $newUser->getUserName() . ".txt", "w"); fwrite($file, $newUser->getPassword()); fclose($file); }
public function SaveLoginOnClient(\model\User $user) { // Prepare values $cookieValues = implode(':', array($user->GetUserName(), $user->GetToken(), $user->GetSignature())); // Save values in cookie (expires in 30 days) return setcookie(self::$COOKIE_ID, $cookieValues, time() + 60 * 60 * 24 * self::$COOKIE_VALID_DAYS); }
public function testGetAll() { $u = new User($this->container); $p = new Project($this->container); $cf = new CustomFilter($this->container); $this->assertEquals(1, $p->create(array('name' => 'UnitTest 1'))); $this->assertEquals(2, $p->create(array('name' => 'UnitTest 2'))); $this->assertEquals(2, $u->create(array('username' => 'user 2'))); $this->assertEquals(1, $cf->create(array('name' => 'My filter 1', 'filter' => 'color:blue', 'project_id' => 1, 'user_id' => 1))); $this->assertEquals(2, $cf->create(array('name' => 'My filter 2', 'filter' => 'color:red', 'project_id' => 1, 'user_id' => 1, 'is_shared' => 1))); $this->assertEquals(3, $cf->create(array('name' => 'My filter 3', 'filter' => 'color:green', 'project_id' => 1, 'user_id' => 2, 'is_shared' => 1))); $this->assertEquals(4, $cf->create(array('name' => 'My filter 4', 'filter' => 'color:brown', 'project_id' => 1, 'user_id' => 2, 'is_shared' => 0))); $this->assertEquals(5, $cf->create(array('name' => 'My filter 5', 'filter' => 'color:grey', 'project_id' => 2, 'user_id' => 2))); // Get filters for the project 1 and user 1 $filters = $cf->getAll(1, 1); $this->assertCount(3, $filters); $this->assertEquals(1, $filters[0]['id']); $this->assertEquals('My filter 1', $filters[0]['name']); $this->assertEquals('color:blue', $filters[0]['filter']); $this->assertEquals(1, $filters[0]['project_id']); $this->assertEquals(1, $filters[0]['user_id']); $this->assertEquals(0, $filters[0]['is_shared']); $this->assertEquals('', $filters[0]['owner_name']); $this->assertEquals('admin', $filters[0]['owner_username']); $this->assertEquals(2, $filters[1]['id']); $this->assertEquals('My filter 2', $filters[1]['name']); $this->assertEquals('color:red', $filters[1]['filter']); $this->assertEquals(1, $filters[1]['project_id']); $this->assertEquals(1, $filters[1]['user_id']); $this->assertEquals(1, $filters[1]['is_shared']); $this->assertEquals('', $filters[1]['owner_name']); $this->assertEquals('admin', $filters[1]['owner_username']); $this->assertEquals(3, $filters[2]['id']); $this->assertEquals('My filter 3', $filters[2]['name']); $this->assertEquals('color:green', $filters[2]['filter']); $this->assertEquals(1, $filters[2]['project_id']); $this->assertEquals(2, $filters[2]['user_id']); $this->assertEquals(1, $filters[2]['is_shared']); $this->assertEquals('', $filters[2]['owner_name']); $this->assertEquals('user 2', $filters[2]['owner_username']); // Get filters for the project 1 and user 2 $filters = $cf->getAll(1, 2); $this->assertCount(3, $filters); $this->assertEquals(2, $filters[0]['id']); $this->assertEquals('My filter 2', $filters[0]['name']); $this->assertEquals(3, $filters[1]['id']); $this->assertEquals('My filter 3', $filters[1]['name']); $this->assertEquals(4, $filters[2]['id']); $this->assertEquals('My filter 4', $filters[2]['name']); // Get filters for the project 2 and user 1 $filters = $cf->getAll(2, 1); $this->assertCount(0, $filters); // Get filters for the project 2 and user 2 $filters = $cf->getAll(2, 2); $this->assertCount(1, $filters); $this->assertEquals(5, $filters[0]['id']); $this->assertEquals('My filter 5', $filters[0]['name']); $this->assertEquals(0, $filters[0]['is_shared']); }
/** * @param User $user * @return UserDataObject */ public function mapToDataObject(User $user) { $userDataObject = new UserDataObject(); $userDataObject->id = $user->getId(); $userDataObject->name = $user->getName(); $userDataObject->passwordHash = $user->getPasswordHash(); return $userDataObject; }
public function doUserExist(User $user) { $this->database->prepare('SELECT * FROM users WHERE username = :username'); $this->database->bindValue(':username', $user->getUsername()); $this->database->fetchAll(); if ($this->database->rowCount() > 0) { throw new exception\UserAlreadyExistException(); } }
public function testHandleFailedLogin() { $u = new User($this->container); $a = new Authentication($this->container); $this->assertFalse($u->isLocked('admin')); for ($i = 0; $i <= 6; $i++) { $a->handleFailedLogin('admin'); } $this->assertTrue($u->isLocked('admin')); }
/** * Used when the person who is currently logged in wants to stop following another user * @param User $user, person who is already following * @param $followee, a person who is being followed * @return bool */ public function removeFollowee(\model\User $user, $followee) { $follower = $user->getUsername(); try { DB::getInstance()->deleteFollowee($follower, $followee); return true; } catch (\Exception $e) { return false; } }
public function testSuccessfulAuthentication() { $_SERVER[REVERSE_PROXY_USER_HEADER] = 'my_user'; $a = new ReverseProxy($this->container); $u = new User($this->container); $this->assertTrue($a->authenticate()); $user = $u->getByUsername('my_user'); $this->assertNotEmpty($user); $this->assertEquals(0, $user['is_admin']); $this->assertEquals(1, $user['is_ldap_user']); $this->assertEquals(1, $user['disable_login_form']); }
public function registerUser() { $user = new User(); $user->setEmail($this->request_body->email); $user->setPassword(md5($this->request_body->password)); $user->save(); $token = new AccessToken(); $token->setTokenContent(uniqid()); $token->setUser($user); $token->save(); return array('user' => $user->toArray(), 'token' => $token->toArray()); }
public function testHandlePayload() { $w = new Sendgrid($this->container); $p = new Project($this->container); $pp = new ProjectPermission($this->container); $u = new User($this->container); $tc = new TaskCreation($this->container); $tf = new TaskFinder($this->container); $this->assertEquals(2, $u->create(array('username' => 'me', 'email' => 'me@localhost'))); $this->assertEquals(1, $p->create(array('name' => 'test1'))); $this->assertEquals(2, $p->create(array('name' => 'test2', 'identifier' => 'TEST1'))); // Empty payload $this->assertFalse($w->receiveEmail(array())); // Unknown user $this->assertFalse($w->receiveEmail(array('envelope' => '{"to":["a@b.c"],"from":"a.b.c"}', 'subject' => 'Email task'))); // Project not found $this->assertFalse($w->receiveEmail(array('envelope' => '{"to":["a@b.c"],"from":"me@localhost"}', 'subject' => 'Email task'))); // User is not member $this->assertFalse($w->receiveEmail(array('envelope' => '{"to":["something+test1@localhost"],"from":"me@localhost"}', 'subject' => 'Email task'))); $this->assertTrue($pp->addMember(2, 2)); // The task must be created $this->assertTrue($w->receiveEmail(array('envelope' => '{"to":["something+test1@localhost"],"from":"me@localhost"}', 'subject' => 'Email task'))); $task = $tf->getById(1); $this->assertNotEmpty($task); $this->assertEquals(2, $task['project_id']); $this->assertEquals('Email task', $task['title']); $this->assertEquals('', $task['description']); $this->assertEquals(2, $task['creator_id']); // Html content $this->assertTrue($w->receiveEmail(array('envelope' => '{"to":["something+test1@localhost"],"from":"me@localhost"}', 'subject' => 'Email task', 'html' => '<strong>bold</strong> text'))); $task = $tf->getById(2); $this->assertNotEmpty($task); $this->assertEquals(2, $task['project_id']); $this->assertEquals('Email task', $task['title']); $this->assertEquals('**bold** text', $task['description']); $this->assertEquals(2, $task['creator_id']); // Text content $this->assertTrue($w->receiveEmail(array('envelope' => '{"to":["something+test1@localhost"],"from":"me@localhost"}', 'subject' => 'Email task', 'text' => '**bold** text'))); $task = $tf->getById(3); $this->assertNotEmpty($task); $this->assertEquals(2, $task['project_id']); $this->assertEquals('Email task', $task['title']); $this->assertEquals('**bold** text', $task['description']); $this->assertEquals(2, $task['creator_id']); // Text + html content $this->assertTrue($w->receiveEmail(array('envelope' => '{"to":["something+test1@localhost"],"from":"me@localhost"}', 'subject' => 'Email task', 'html' => '<strong>bold</strong> html', 'text' => '**bold** text'))); $task = $tf->getById(4); $this->assertNotEmpty($task); $this->assertEquals(2, $task['project_id']); $this->assertEquals('Email task', $task['title']); $this->assertEquals('**bold** html', $task['description']); $this->assertEquals(2, $task['creator_id']); }
/** * Write changes into history * * @param \Model\User $oldUser * @param \Model\User $newUser */ protected function makeHistoryChanges(\Model\User $oldUser, \Model\User $newUser) { try { $history = new \Model\UsersHistory(); $history->user_id = $oldUser->id; $history->was = $oldUser->toJson(); $history->setted = $newUser->toJson(); $history->save(); } catch (\Exception $e) { // write err log } }
public function validate() { unset($this->message); $this->message = array(); $username = $this->getUsername(); $password = $this->getPassword(); $repeatedPassword = $this->getPasswordRepeat(); $validateUser = new User($username, $password); try { $validateUser->testValidUsername(); } catch (InvalidUsernameException $e) { $this->message[] = "Username contains invalid characters."; } catch (\Exception $e) { $this->message[] = $e; } try { $validateUser->testValidPassword(); } catch (InvalidPasswordException $e) { $this->message[] = "Password contains invalid characters."; } catch (\Exception $e) { $this->message[] = $e; } try { $validateUser->testUsernameLength(); } catch (ToShortUsernameException $e) { $this->message[] = "Username has too few characters, at least 3 characters."; } catch (\Exception $e) { $this->message[] = $e; } try { $validateUser->testPasswordLength(); } catch (ToShortPasswordException $e) { $this->message[] = "Password has too few characters, at least 6 characters."; } catch (\Exception $e) { $this->message[] = $e; } if ($password != $repeatedPassword) { $this->message[] = "Passwords do not match."; } try { $this->dal->doUserExist($validateUser); } catch (UserAlreadyExistException $e) { $this->message[] = "User exists, pick another username."; } catch (\Exception $e) { $this->message[] = $e; } if (empty($this->message)) { return true; } else { return false; } }
public function testSendWithoutEmailAddress() { $en = new EmailNotification($this->container); $p = new Project($this->container); $tf = new TaskFinder($this->container); $tc = new TaskCreation($this->container); $u = new User($this->container); $this->assertEquals(1, $p->create(array('name' => 'test'))); $this->assertEquals(1, $tc->create(array('title' => 'test', 'project_id' => 1))); $this->container['emailClient'] = $this->getMockBuilder('\\Core\\EmailClient')->setConstructorArgs(array($this->container))->setMethods(array('send'))->getMock(); $this->container['emailClient']->expects($this->never())->method('send'); $en->send($u->getById(1), Task::EVENT_CREATE, array('task' => $tf->getDetails(1))); }
public function addNewStatus(\model\User $user, $content) { if (strlen($content) > 255) { return false; } try { $username = $user->getUsername(); DB::getInstance()->addStatusToDB($username, $content); return true; } catch (\Exception $e) { return false; } }
public function save(\model\User $user) { if ($this->doExists($user->getUsername())) { throw new \Exception(); } $stmt = $this->database->prepare("INSERT INTO `lab4` (`username` , `password`) VALUES (?, ?)"); if ($stmt === FALSE) { throw new \Exception($this->database->error); } $username = $user->getUsername(); $password = $user->getPassword(); $stmt->bind_param('ss', $username, $password); $stmt->execute(); }
public static function helloMathis($app) { $ajout = false; $username = '******'; $user = User::find($username); // Si $user n'est pas set, c'est qu'il n'y a rien et on ajoute donc en base ! if (!isset($user)) { $user = new User(); $user->name = $username; $user->save(); $ajout = true; } $app->render('user.html.twig', array('ajout' => $ajout, 'autre' => 'ahah !', 'name' => $user->name)); }
/** * Login user * * @param \model\User $credential * @return bool */ public function doLogin(\model\User $credential) { $username = $credential->getUsername(); $password = $credential->getPassword(); $records = new \Db(); $records->query('SELECT username, password FROM users WHERE BINARY username = :username'); $records->bind(':username', $username); $results = $records->single(); if (count($results) > 0 && password_verify($password, $results['password'])) { return $this->sessionStorage->set(SessionStorage::$auth, $username); } else { return false; } }
public function addUserToDatabase(\model\User $user) { //Checking if username already exists if (isset($this->users[$user->getUserName()])) { throw new \Exception("Username already exists"); } else { if (isset($this->users[$user->getPassword()])) { throw new \Exception("Password already exists"); } else { //saving to "database with username as index key" $key = $user->getUserName(); $this->users[$key] = $user->getPassword(); } } }
public function check() { if (self::$isCheck) { return false; } if (User::getCurrent()->isAdmin()) { $current_version = Option::get("version"); $git_current_version = file_get_contents(DATA_PATH . 'version.lock'); // 从 update.loacg.com 服务器上获取版本变化 $response = self::doGet(self::UPDATE_SERVER . self::CHECK, array("Cookie: ver:" . $current_version)); if ($response != null) { $response = json_decode($response, true); $data = $response['data']; $online_version = $data['version']; if ($data['download_url'] != null) { } $message = ""; if ($data['message'] != null) { $message = $data['message']; } self::$isCheck = true; if ($current_version != $online_version) { if ($git_current_version == $online_version) { Option::set("version", $git_current_version); return false; } if ($message == "") { $message = "发现新版本 " . $online_version . " , 可以前往Github下载更新(本消息仅管理员可接收到)"; } return htmlspecialchars($message); } } } return false; }
public function index() { $data['user'] = User::getCurrent(); $data['nodes'] = NodeModel::getNodeArray(); Template::setContext($data); Template::setView('admin/node'); }
public function validate() { // $except中指定的资源不需要认证 $rName = $this->getManager()->getRequest()->getResource(); if (!in_array($rName, $this->except)) { // 验证HTTP_KEY是否有效 if (!isset($_SERVER['HTTP_KEY'])) { throw new Unauthorized(); } $keygen = explode(',', base64_decode($_SERVER['HTTP_KEY'])); list($username, $md5Password, $sessionId) = $keygen; $sessionPath = session_save_path() == '' ? '/SmartGrid/tmp' : session_save_path(); $sessionFile = rtrim($sessionPath, '/') . '/sess_' . $sessionId; if (!file_exists($sessionFile)) { $user = User::model($this->getManager()->getComponent('db')); $where = "`username`='{$username}' AND `password`='{$md5Password}'"; $userinfo = $user->where($where)->find(); if ($userinfo == null) { throw new Unauthorized(); } session_id($sessionId); session_start(); $_SESSION['userid'] = $userinfo['id']; $_SESSION['username'] = $userinfo['username']; $_SESSION['userrole'] = $userinfo['userrole']; $_SESSION['authtype'] = $userinfo['authtype']; $_SESSION['permission'] = json_decode($userinfo['permission']); } session_id($sessionId); session_start(); } }
public function doExist(\model\User $user) { $sqlQuery = $this->dal->prepare("SELECT EXISTS(SELECT 1 FROM Users WHERE Username=?)"); if ($sqlQuery == false) { throw new \Exception($this->dal->error); } $username = $user->getUsername(); $sqlQuery->bind_param('s', $username); $sqlQuery->execute(); $sqlQuery->bind_result($result); $sqlQuery->fetch(); if ($result == 1) { return true; } return false; }
public function homeAction() { $form = new Form\Register($_POST, array('db' => $this->db)); $form_login = new Form\Login($_POST, array('db' => $this->db)); if ($this->method == 'POST' && $form->isValid()) { $user = new Model\User($form->getValues()); $user->save(); $_SESSION['user_id'] = $user->getPk(); $this->redirect('backoffice'); } if ($this->method == 'POST' && $form_login->isValid()) { $_SESSION['user_id'] = $form_login->getValues()['user_id']; $this->redirect('backoffice'); } return array('form' => $form, 'form_login' => $form_login); }
public static function perform(Comment $comment) { if ($comment->comment_id) { return; } $article = $comment->article()->find_one(); if ($article->user_id != $comment->user_id) { Notify::dispense()->create(array('user_id' => $article->user_id, 'from_user_id' => $comment->user_id, 'type' => Notify::REPLY, 'object_type' => $article->type(), 'object_id' => $article->id, 'message' => $comment->text))->save(); } if (!preg_match_all('/@(\\w+)/', $comment->text, $match)) { return; } $users = array(); foreach ($match[1] as $username) { if (isset($users[$username])) { continue; } if (!($user = User::dispense()->where('name', $username)->find_one())) { continue; } // If mention in reply, ignore mention notify if ($user->id == $article->user_id) { continue; } $users[$username] = $user->id; } foreach ($users as $user_id) { Notify::dispense()->create(array('user_id' => $user_id, 'from_user_id' => $comment->user_id, 'type' => Notify::MENTION, 'object_type' => $article->type(), 'object_id' => $article->id, 'message' => $comment->text))->save(); } }
public function index() { $data['user'] = User::getCurrent(); $data['cronList'] = CronModel::getCronArray(); Template::setContext($data); Template::setView('admin/cron'); }
public function actionPost() { $data = $this->getData('user'); if (!isset($data['username'])) { throw new BadRequest("USERNAME_REQUIRED"); } if (!isset($data['password'])) { throw new BadRequest("PASSWORD_REQUIRED"); } $username = $data['username']; $md5Password = md5($data['password']); $user = User::model($this->getManager()->getComponent('db')); $where = "`username`='{$username}' AND `password`='{$md5Password}'"; $userinfo = $user->where($where)->find(); if ($userinfo != null) { session_start(); $roleId = $userinfo['role_id']; $role = Role::model($this->getManager()->getComponent('db')); $roleinfo = $role->where("`id`={$userinfo['role_id']}")->find(); $_SESSION['userid'] = $userinfo['id']; $_SESSION['username'] = $userinfo['username']; $_SESSION['authtype'] = $userinfo['authtype']; $_SESSION['userrole'] = $roleinfo['name']; $_SESSION['permission'] = Json::toArray($roleinfo['permission']); return array('result' => array('success' => true, 'key' => base64_encode($username . ',' . $md5Password . ',' . session_id()))); } else { throw new BadRequest('USERNAME_PASSWORD_INCORRECT'); } }