public function logout() { $user = Models\User::getCurrent(); if ($user instanceof Models\User) { TigerApp::log("Logout for {$user->username}"); } Session::dispose('user'); $this->slim->response()->redirect("/login"); }
/** * @param $username * @param $password * @return bool */ public function doLogin($username, $password) { // Support logging in with email address $user = Models\User::search()->where('email', $username)->execOne(); // Support logging in with username if (!$user instanceof Models\User) { $user = Models\User::search()->where('username', $username)->execOne(); } if (!$user instanceof Models\User) { TigerApp::log("No such user {$username}", Slim\Log::WARN); return false; } elseif ($user->checkPassword($password)) { Session::set("user", $user); return true; } else { TigerApp::log("Failed login for {$username}", Slim\Log::WARN); return false; } }
public function save($automatic_reload = true) { if (!$this->user_uuid) { $this->user_uuid = UUID::v4(); } if (!$this->user_id) { TigerApp::log("New user created: {$this->username} / {$this->displayname} / {$this->email}"); } return parent::save($automatic_reload); }
/** * @param string $key * @return string|array|false */ public static function Config($key) { $indexes = explode(".", $key); $configData = self::$tigerApp->config; foreach ($indexes as $index) { if (isset($configData[$index])) { $configData = $configData[$index]; } else { TigerApp::log("No such config index: {$key}"); return false; } } return $configData; }