public function executeAction($parameters) { // authenticate $userEmail = FacebookSdk::getInstance($this->_websoccer)->getUserEmail(); // not authenticated if (!strlen($userEmail)) { $this->_websoccer->addFrontMessage(new FrontMessage(MESSAGE_TYPE_WARNING, $this->_i18n->getMessage("facebooklogin_failure"), "")); return "home"; } // authenticated. Check if user exists. $userEmail = strtolower($userEmail); $userId = UsersDataService::getUserIdByEmail($this->_websoccer, $this->_db, $userEmail); // if does not exist, then create new user if ($userId < 1) { $userId = UsersDataService::createLocalUser($this->_websoccer, $this->_db, null, $userEmail); } // log in user SecurityUtil::loginFrontUserUsingApplicationSession($this->_websoccer, $userId); $this->_websoccer->addFrontMessage(new FrontMessage(MESSAGE_TYPE_SUCCESS, $this->_i18n->getMessage("facebooklogin_success"), "")); return strlen($this->_websoccer->getUser()->username) ? "office" : "enter-username"; }
/** * (non-PHPdoc) * @see IActionController::executeAction() */ public function executeAction($parameters) { $loginMethodClass = $this->_websoccer->getConfig("login_method"); if (!class_exists($loginMethodClass)) { throw new Exception("Login method class does not exist: " . $loginMethodClass); } $loginMethod = new $loginMethodClass($this->_websoccer, $this->_db); // sign in with e-mail if ($this->_websoccer->getConfig("login_type") == "email") { $userId = $loginMethod->authenticateWithEmail($parameters["loginstr"], $parameters["loginpassword"]); // sign in with user name } else { $userId = $loginMethod->authenticateWithUsername($parameters["loginstr"], $parameters["loginpassword"]); } // sign in failed if (!$userId) { sleep(SLEEP_SECONDS_ON_FAILURE); throw new Exception($this->_i18n->getMessage("formlogin_invalid_data")); } SecurityUtil::loginFrontUserUsingApplicationSession($this->_websoccer, $userId); // "remember me" if (isset($parameters["rememberme"]) && $parameters["rememberme"] == 1) { $fromTable = $this->_websoccer->getConfig("db_prefix") . "_user"; $whereCondition = "id = %d"; $parameter = $userId; // get password salt $result = $this->_db->querySelect("passwort_salt", $fromTable, $whereCondition, $parameter); $saltinfo = $result->fetch_array(); $result->free(); $salt = $saltinfo["passwort_salt"]; if (!strlen($salt)) { $salt = SecurityUtil::generatePasswordSalt(); } $sessionToken = SecurityUtil::generateSessionToken($userId, $salt); $columns = array("tokenid" => $sessionToken, "passwort_salt" => $salt); $this->_db->queryUpdate($columns, $fromTable, $whereCondition, $parameter); CookieHelper::createCookie("user", $sessionToken, REMEMBERME_COOKIE_LIFETIME_DAYS); } return strlen($this->_websoccer->getUser()->username) ? "office" : "enter-username"; }