本文整理汇总了PHP中UserManager::createUser方法的典型用法代码示例。如果您正苦于以下问题:PHP UserManager::createUser方法的具体用法?PHP UserManager::createUser怎么用?PHP UserManager::createUser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UserManager
的用法示例。
在下文中一共展示了UserManager::createUser方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: service
public function service()
{
$userManager = new UserManager($this->config, $this->args);
$email = strtolower($this->secure($_REQUEST["email"]));
$name = $this->secure($_REQUEST["name"]);
$phone = $this->secure($_REQUEST["phone"]);
$pass = $this->secure($_REQUEST["pass"]);
$invitation_code = $this->secure($_COOKIE["invc"]);
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
$jsonArr = array('status' => "err", "errText" => $this->getPhraseSpan(471));
echo json_encode($jsonArr);
return false;
}
$custDto = $userManager->getCustomerByEmail($email);
if ($custDto) {
$jsonArr = array('status' => "err", "errText" => $this->getPhraseSpan(359));
echo json_encode($jsonArr);
return false;
}
if (!$userManager->checkPassword($pass)) {
$jsonArr = array('status' => "err", "errText" => $this->getPhraseSpan(358));
echo json_encode($jsonArr);
return false;
}
if (!$name || strlen($name) == 0) {
$jsonArr = array('status' => "err", "errText" => $this->getPhraseSpan(356));
echo json_encode($jsonArr);
return false;
}
if ($phone != null) {
if (strpos($phone, ',') !== false) {
$jsonArr = array('status' => "err", "errText" => $this->getPhraseSpan(521));
echo json_encode($jsonArr);
return false;
}
}
$userId = $userManager->createUser($email, $pass, $name, $phone);
$userManager->setSubUser($invitation_code, $userId, $email);
$userDto = $userManager->selectByPK($userId);
//sending activation email using $userDto->getActivationCode();
$emailSenderManager = new EmailSenderManager('gmail');
$username = $name;
$subject = "PcStore Activation!";
$activation_code = $userDto->getActivationCode();
$template = "account_activation";
$params = array("user_name" => $username, "activation_code" => $activation_code);
$emailSenderManager->sendEmail('registration', $email, $subject, $template, $params);
$jsonArr = array('status' => "ok");
echo json_encode($jsonArr);
return true;
}
示例2: loadUserByOAuthUserResponse
public function loadUserByOAuthUserResponse(UserResponseInterface $response)
{
$socialID = $response->getUsername();
/** @var User $user */
$user = $this->userManager->loadUser(['facebookId' => $socialID]);
$update = true;
$email = $response->getEmail();
//check if the user already has the corresponding social account
if (null === $user) {
//check if the user has a normal account
$user = $this->userManager->loadUser($email, 'email');
if (null === $user || !$user instanceof UserInterface) {
//if the user does not have a normal account, set it up:
/** @var User $user */
$name = $response->getNickname() ?? $response->getRealName();
$user = $this->userManager->createUser($name, md5(uniqid()), $response->getEmail(), ['ROLE_OAUTH_USER']);
$user->setEmail($email);
$user->setFullName($name);
$user->setEnabled(true);
$violations = $this->validator->validate($user);
$update = !$violations->count() === 0;
if ($violations->count() === 0) {
$this->session->getFlashBag()->add('warning', 'Welcome! You must complete your profile in order to use the features on the site.');
} else {
throw new CustomUserMessageAuthenticationException('An account in your name already exists.');
}
}
if ($update) {
//then set its corresponding social id
$service = $response->getResourceOwner()->getName();
switch ($service) {
case 'google':
$user->setGoogleID($socialID);
break;
case 'facebook':
$user->setFacebookID($socialID);
break;
}
$this->userManager->updateUser($user);
}
} else {
//and then login the user
$token = new UsernamePasswordToken($user, null, 'main', $user->getRoles());
$this->tokenStorage->setToken($token);
}
$user->setLastLoggedIn(new \DateTime());
$this->userManager->updateUser($user);
return $user;
}
示例3: showSignInForm
static function showSignInForm($error = null)
{
if ($error == null && count($_POST) > 0) {
$data = array();
$error = array();
$privatekey = CAPTCHA_PRIVATE;
$logger = Logger::getLogger();
$logger->debug("UserPage", "inizio controllo parametri");
if (isset($_POST["nickname"]) && $_POST["nickname"] != "") {
if (!UserManager::nicknameExist($_POST["nickname"])) {
$data["nickname"] = $_POST["nickname"];
$logger->debug("UserPage", "nickname: " . $data["nickname"]);
} else {
$error[] = "il nickname scelto non è disponibile";
$logger->debug("UserPage", "error: nickname non disponibile");
}
} else {
$error[] = "non c'è il nickname";
$logger->debug("UserPage", "error: nickname");
}
if (isset($_POST["check_password"]) && $_POST["check_password"] != "" && (isset($_POST["password_signin"]) && $_POST["password_signin"] != "")) {
if ($_POST["password_signin"] == $_POST["check_password"]) {
$data["password_signin"] = $_POST["password_signin"];
$logger->debug("UserPage", "password_signin: " . $data["password_signin"]);
} else {
$error[] = "le password non corrispondono";
$logger->debug("UserPage", "error: password non coincidenti");
}
} else {
$error[] = "password non presente";
$logger->debug("UserPage", "error: no password");
}
if (isset($_POST["email"]) && $_POST["email"] != "") {
if (UserManager::checkMail($_POST["email"])) {
if (!UserManager::emailExist($_POST["email"])) {
$data["email"] = $_POST["email"];
$logger->debug("UserPage", "email: " . $_POST["email"]);
} else {
$error[] = "questo indirizzo e-mail è già stato utilizzato";
$logger->debug("UserPage", "error: email gia utilizzata");
}
} else {
$error[] = "l'indirizzo e-mail non è valido";
$logger->debug("UserPage", "error: email non valida");
}
} else {
$error[] = "non c'è l'email";
$logger->debug("UserPage", "error: email");
}
/* check reCHAPTCHA response */
require_once 'recaptchalib.php';
$resp = recaptcha_check_answer($privatekey, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]);
if (!$resp->is_valid) {
$error[] = "Il reCAPTCHA non è stato inserito correttamente. Prova di nuovo";
$logger->debug("UserPage", "reCaptha : failed");
} else {
$logger->debug("UserPage", "reCaptha : ok");
}
if (count($error) > 0) {
self::showSignInForm($error);
$logger->debug("UserPage", "error : yes");
} else {
$logger->debug("UserPage", "error : no");
$dataFiltered = Filter::filterArray($data);
$userRole = DEFAULT_ROLE;
$user = UserManager::createUser($data["nickname"], $data["email"], $data["password_signin"], $userRole);
self::showProfile($user);
}
} else {
$POST_data = count($_POST) > 0;
?>
<script type="text/javascript">
//change reCAPTCHA theme
var RecaptchaOptions = {theme : 'clean'};
</script>
<form name="signIn" action="" method="post">
<?php
if ($error != null) {
?>
<div class="error">
<?php
foreach ($error as $err) {
?>
<p><?php
echo $err;
?>
</p>
<?php
}
?>
</div>
<?php
}
?>
Nickname: <input type="text" name="nickname" value="<?php
if ($POST_data) {
echo $_POST["nickname"];
}
?>
" /><br>
//.........这里部分代码省略.........
示例4: service
public function service()
{
$userManager = new UserManager($this->config, $this->args);
if (isset($_REQUEST['login_type'])) {
$json_profile = $_REQUEST['json_profile'];
$social_user_id = $this->secure($_REQUEST['social_user_id']);
$first_name = $this->secure($_REQUEST['first_name']);
$last_name = $this->secure($_REQUEST['last_name']);
$custDto = $userManager->getUserByEmail($social_user_id);
if (!isset($custDto)) {
$userId = $userManager->createUser($social_user_id, uniqid(), $first_name, '', $last_name, $_REQUEST['login_type']);
$userManager->setActive($userId);
$userManager->setUserSocialProfile($userId, $json_profile);
$custDto = $userManager->getUserByEmail($social_user_id);
//bonus to inviter
$invitation_code = $this->secure($_COOKIE["invc"]);
$inviterId = $userManager->setSubUser($invitation_code, $userId);
if ($inviterId > 0) {
$invbonus = intval($this->getCmsVar("bonus_points_for_every_accepted_invitation"));
$userManager->addUserPoints($inviterId, $invbonus, "{$invbonus} bonus for invitation accept from user number: {$userId}");
}
}
$userType = UserGroups::$USER;
} else {
$email = strtolower($userManager->secure($_REQUEST["user_email"]));
$pass = $userManager->secure($_REQUEST["user_pass"]);
$custDto = $userManager->getCustomerByEmailAndPassword($email, $pass);
$userType = $userManager->getCustomerType($email, $pass);
if ($userType == UserGroups::$USER && $custDto->getActive() == 0) {
$jsonArr = array('status' => "err", "errText" => sprintf($this->getPhrase(380), $custDto->getEmail()));
echo json_encode($jsonArr);
return false;
}
}
if ($custDto) {
if ($userType !== UserGroups::$ADMIN && $custDto->getBlocked() == 1) {
$jsonArr = array('status' => "err", "errText" => $this->getPhraseSpan(411) . ' ' . $this->getCmsVar("pcstore_support_phone_number"));
echo json_encode($jsonArr);
return false;
}
$user = null;
if ($userType === UserGroups::$ADMIN) {
$user = new AdminUser($custDto->getId());
} else {
if ($userType === UserGroups::$USER) {
$user = new CustomerUser($custDto->getId());
$this->setcookie('ul', $custDto->getLanguageCode());
} else {
if ($userType === UserGroups::$COMPANY) {
$user = new CompanyUser($custDto->getId());
$companyManager = CompanyManager::getInstance($this->config, $this->args);
$companyManager->updateCompanyRating($custDto);
$this->setcookie('ul', $custDto->getLanguageCode());
} else {
if ($userType === UserGroups::$SERVICE_COMPANY) {
$user = new ServiceCompanyUser($custDto->getId());
$companyManager = ServiceCompanyManager::getInstance($this->config, $this->args);
$this->setcookie('ul', $custDto->getLanguageCode());
}
}
}
}
$user->setUniqueId($custDto->getHash());
$this->sessionManager->setUser($user, true, true);
$jsonArr = array('status' => "ok");
echo json_encode($jsonArr);
return true;
} else {
$jsonArr = array('status' => "err", "errText" => $this->getPhrase(412));
echo json_encode($jsonArr);
return false;
}
}
示例5: showSignInForm
static function showSignInForm($error = null)
{
if ($error == null && count($_POST) > 0) {
$data = array();
$error = array();
$privatekey = CAPTCHA_PRIVATE;
if (isset($_POST["nickname"])) {
$data["nickname"] = $_POST["nickname"];
} else {
$error[] = "non c'è il nickname";
}
if (isset($_POST["check_password"]) && isset($_POST["password"])) {
if ($_POST["password"] == $_POST["check_password"]) {
$data["password"] = $_POST["password"];
} else {
$error[] = "le password non corrispondono";
}
} else {
$error[] = "password non presente";
}
if (isset($_POST["email"])) {
$data["email"] = $_POST["email"];
} else {
$error[] = "non c'è l'email";
}
/* check reCHAPTCHA response */
require_once 'recaptchalib.php';
$resp = recaptcha_check_answer($privatekey, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]);
if (!$resp->is_valid) {
$error[] = "Il reCAPTCHA non è stato inserito correttamente. Prova di nuovo";
if (count($error) > 0) {
self::showSignInForm($error);
} else {
$dataFiltered = Filter::filterArray($data);
$user = UserManager::createUser($dataFiltered);
self::showProfile($user);
}
}
} else {
$POST_data = count($_POST) > 0;
?>
<script type="text/javascript">
//change reCAPTCHA theme
var RecaptchaOptions = {theme : 'clean'};
</script>
<form name="signIn" action="" method="post"><!-- show error messages --> <?php
if ($error != null) {
foreach ($error as $valore) {
echo "{$valore}<br>";
}
}
?>
Nickname: <input type="text" name="nickname" value="<?php
if ($POST_data) {
echo $_POST["nickname"];
}
?>
" /><br>
Password: <input type="password" name="password" value="" /><br>
Check Password: <input type="password" name="check_password" value="" /><br>
Email: <input type="text" name="email" value="<?php
if ($POST_data) {
echo $_POST["email"];
}
?>
" /><br>
<!-- show reCAPTCHA --> <?php
require_once 'recaptchalib.php';
$publickey = CAPTCHA_PUBLIC;
echo recaptcha_get_html($publickey);
?>
<input type="submit" value="Sign In"></form>
<?php
}
}
示例6: testDeleteFollow
/**
* Tests removing follow.
*/
function testDeleteFollow()
{
$u1 = UserManager::loadUserByNickname($this->user_data[NICKNAME]);
if ($u1 === false) {
$u1 = UserManager::createUser($this->user_data);
}
$u2 = UserManager::loadUserByNickname($this->user_data2[NICKNAME]);
if ($u2 === false) {
$u2 = UserManager::createUser($this->user_data2);
}
UserManager::followUser($u2, $u1);
//echo "<p>" . $u1 . "</p>"; //DEBUG
$oldfollowerscount = count($u1->getFollowers());
$oldfollowscount = count($u2->getFollows());
UserManager::stopFollowingUser($u2, $u1);
if (count($u1->getFollowers()) >= $oldfollowerscount) {
return "Test follow deleting NOT PASSED: not updated subject.";
}
if (count($u2->getFollows()) >= $oldfollowscount) {
return "Test follow deleting NOT PASSED: not updated follower.";
}
return "Test follow deleting passed.";
}
示例7: createUser
public function createUser(User $user)
{
$newUserId = parent::createUser($user);
$this->invalidateUserCacheByUserId($newUserId);
return $newUserId;
}