本文整理匯總了PHP中Parse\ParseUser::signUp方法的典型用法代碼示例。如果您正苦於以下問題:PHP ParseUser::signUp方法的具體用法?PHP ParseUser::signUp怎麽用?PHP ParseUser::signUp使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Parse\ParseUser
的用法示例。
在下文中一共展示了ParseUser::signUp方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: createUser
/**
* Creating new user
* @param String $name User full name
* @param String $email User login email id
* @param String $password User login password
*/
public function createUser(CustomParseUser $cpu)
{
$response = array();
// First check if user already existed in db
if (!$this->isUserExists($cpu->getUserName(), $cpu->getEmail())) {
// Generating API key
$api_key = $this->generateApiKey($cpu->getEmail());
$user = new ParseUser();
$user->set("username", $cpu->getUsername());
$user->set("password", $cpu->getPassword());
$user->set("email", $cpu->getEmail());
$user->set("firstName", $cpu->getFirstName());
$user->set("lastName", $cpu->getLastName());
$user->set("birthday", $cpu->getBirthday());
$user->set("apiKey", $api_key);
try {
$user->signUp();
// Hooray! Let them use the app now.
return 'USER_CREATED_SUCCESSFULLY';
} catch (Parse\ParseException $ex) {
// Show the error message somewhere and let the user try again.
echo "Error: " . $ex->getCode() . " " . $ex->getMessage();
return 'USER_CREATE_FAILED';
}
} else {
// User with same email already existed in the db
return 'USER_ALREADY_EXISTED';
}
return $response;
}
示例2: register
function register($name, $email, $password, $teacher)
{
$user = new ParseUser();
$user->set("username", $email);
$user->set("email", $email);
$user->set("password", $password);
$user->set("name", $name);
if ($teacher == "true") {
$user->set("Teacher", true);
} else {
$user->set("Teacher", false);
}
try {
$user->signUp();
$user->save();
if ($teacher == "true") {
header("Location: profile.php");
} else {
header("Location: howToLearn.php");
}
// Hooray! Let them use the app now.
} catch (ParseException $ex) {
// Show the error message somewhere and let the user try again.
}
}
示例3: singup
public static function singup($name, $lastname, $email, $password)
{
if (!empty($name) && !empty($lastname) && !empty($email) && !empty($password)) {
$cleanName = filter_var($name, FILTER_SANITIZE_STRING);
$cleanLastName = filter_var($lastname, FILTER_SANITIZE_STRING);
$cleanEmail = filter_var($email, FILTER_SANITIZE_EMAIL);
$cleanPassword = filter_var($password, FILTER_SANITIZE_STRING);
$user = new ParseUser();
$user->set("username", $cleanEmail);
$user->set("password", $cleanPassword);
$user->set("email", $cleanEmail);
$customer = self::createStripeId($cleanEmail);
// other fields can be set just like with ParseObject
$user->set("stripeId", $customer['id']);
$user->set("name", $cleanName);
$user->set("lastname", $cleanLastName);
try {
$user->signUp();
return 200;
} catch (ParseException $ex) {
return 500;
}
} else {
return 500;
}
}
示例4: createUser
public function createUser($params)
{
$user = new ParseUser();
$user->setUsername($params['login']);
$user->setPassword($params['passwd']);
try {
$user->signUp();
} catch (ParseException $ex) {
die("Exception: " . $ex->getMessage());
}
return $user;
}
示例5: signUp
public function signUp($name, $password, $email)
{
$user = new ParseUser();
$user->set("username", $name);
$user->set("password", $password);
$user->set("email", $email);
try {
$user->signUp();
} catch (ParseException $ex) {
echo "Error: " . $ex->getCode() . " " . $ex->getMessage();
}
return $user->get('username');
}
示例6: signup
function signup()
{
$username = $_POST["id"];
$user = new ParseUser();
$user->set("username", $username);
$user->set("password", $_POST["pass"]);
$user->set("email", $username . "@example.com");
try {
$user->signUp();
// Hooray! Let them use the app now.
} catch (ParseException $ex) {
// Show the error message somewhere and let the user try again.
echo "Error: " . $ex->getCode() . " " . $ex->getMessage();
}
}
示例7: signupAction
/**
* Expects a post with email / password (or the form is just shown). Creates a new user (if possible) then redirects
* to the app controller on success, or itself (PRG) with a flash message on error.
*/
public function signupAction()
{
if (!$this->request instanceof Request or !$this->request->isPost()) {
return;
//nothing to do
}
$email = $this->request->getPost('email');
$password = $this->request->getPost('password');
$user = new ParseUser();
$user->setUsername($email);
$user->setPassword($password);
try {
$user->signUp();
$_SESSION['todo']['user'] = $user->getUsername();
$this->redirect()->toRoute('app');
} catch (ParseException $e) {
$this->flashMessenger()->addErrorMessage($e->getMessage());
$this->redirect()->toRoute('auth', ['action' => 'signup']);
}
}
示例8: testRevocableSession
public function testRevocableSession()
{
ParseClient::enableRevocableSessions();
$user = new ParseUser();
$user->setUsername("username");
$user->setPassword("password");
$user->signUp();
$session = ParseSession::getCurrentSession();
$this->assertEquals($user->getSessionToken(), $session->getSessionToken());
$this->assertTrue($session->isCurrentSessionRevocable());
ParseUser::logOut();
ParseUser::logIn("username", "password");
$session = ParseSession::getCurrentSession();
$this->assertEquals(ParseUser::getCurrentUser()->getSessionToken(), $session->getSessionToken());
$this->assertTrue($session->isCurrentSessionRevocable());
$sessionToken = $session->getSessionToken();
ParseUser::logOut();
$this->setExpectedException('Parse\\ParseException', 'invalid session token');
ParseUser::become($sessionToken);
}
示例9: reguistraUsuario
/**
* Registra a un usuario nuevo tomando sus datos, si todo fue bien retorna el
* objeto conteniendo al usuario, si no, retorna un mensaje de error.
* @param type $nombre nombre del usuario
* @param type $contraseña su contraseña
* @param type $email el email del usuario
* @param type $tipo el tipo de usuario (1 persona fisica, 2 persona moral).
* @return objeto json
*/
public static function reguistraUsuario($usuario)
{
$user = new ParseUser();
$user->set("username", $usuario->getNombre());
$user->set("password", $usuario->getPassword());
$user->set("email", $usuario->getEmail());
$user->set("tipo", $usuario->getTipo());
try {
$user->signUp();
return json_encode([reg => 1, mensaje => 'Usuario registrado']);
} catch (ParseException $ex) {
if ($ex->getCode() == 203) {
return json_encode([reg => 0, mensaje => "La direccion email " . $usuario->getEmail() . " ya esta ocupada"]);
} else {
if ($ex->getCode() == 202) {
return json_encode([reg => 0, mensaje => "El nombre de usuario " . $usuario->getNombre() . " ya esta ocupado"]);
} else {
return json_encode([reg => 0, mensaje => $ex->getMessage()]);
}
}
}
}
示例10: getIndex
/**
* Show the profile for the given user.
*
* @param int $id
* @return Response
*/
public function getIndex()
{
ParseClient::initialize(env('PARSE_APP_ID'), env('ARSE_REST_KEY'), env('PARSE_MASTER_KEY'));
$user = new ParseUser();
$user->setUsername("foo");
$user->setPassword("Q2w#4!o)df");
try {
$user->signUp();
dd(1112);
} catch (ParseException $ex) {
echo $ex->getMessage() . "<br>";
}
// Login
try {
$user = ParseUser::logIn("foo", "Q2w#4!o)df");
} catch (ParseException $ex) {
echo $ex->getMessage();
}
// Current user
$user = ParseUser::getCurrentUser();
dd($user);
}
示例11: testACLModifyingAfterLoad
public function testACLModifyingAfterLoad()
{
$user = new ParseUser();
$user->setUsername('alice');
$user->setPassword('wonderland');
$user->signUp();
$object = ParseObject::create('Object');
$acl = ParseACL::createACLWithUser($user);
$object->setACL($acl);
$object->save();
$this->assertTrue($object->getACL()->getUserReadAccess($user));
$this->assertTrue($object->getACL()->getUserWriteAccess($user));
$this->assertFalse($object->getACL()->getPublicReadAccess());
$this->assertFalse($object->getACL()->getPublicWriteAccess());
$query = new ParseQuery('Object');
$objectAgain = $query->get($object->getObjectId());
$objectAgain->getACL()->setPublicReadAccess(true);
$this->assertTrue($objectAgain->getACL()->getUserReadAccess($user));
$this->assertTrue($objectAgain->getACL()->getUserWriteAccess($user));
$this->assertTrue($objectAgain->getACL()->getPublicReadAccess());
$this->assertFalse($objectAgain->getACL()->getPublicWriteAccess());
}
示例12: ParseUser
}
$file = ParseFile::createFromFile($target_dir . $name, "logo");
$file->save();
// create new user object
$user = new ParseUser();
$user->set("username", $email);
$user->set("password", $pass);
$user->set("email", $email);
$user->set("corporate", true);
$user->set("name", $company_name);
$user->set("logo", $file);
$user->set("logo_url", $file->getURL());
unlink($target_dir . $name);
// try signup
try {
$user->signUp();
// Hooray! Let them use the app now.
$_SESSION['login'] = "1";
$_SESSION['email'] = $email;
$_SESSION['userid'] = $user->getObjectId();
header("Location: index.php");
} catch (ParseException $ex) {
// Show the error message somewhere and let the user try again.
echo "Error: " . $ex->getCode() . " " . $ex->getMessage();
}
}
}
echo include "assets/templates/header.php";
?>
<br>
<br>
示例13: userSignUp
public function userSignUp($params)
{
// creat new ParseUser object
$user = new ParseUser();
// set params
foreach ($params as $name => $data) {
switch ($data['type']) {
case 'array':
$user->setArray($name, $data['value']);
break;
default:
$user->set($name, $data['value']);
break;
}
}
try {
$user->signUp();
return array('status' => '1', 'data' => $user);
} catch (ParseException $e) {
return array('status' => '0', 'data' => $e->getMessage());
}
}
示例14: user_register_report
function user_register_report($first, $last, $pass, $email, $report_id)
{
$response = new Response();
$name = $first . "_" . $last;
$user = new ParseUser();
$user->set("username", strtolower($name));
$user->set("email", $email);
$user->set("password", $pass);
try {
$user->signUp();
$_SESSION['user'] = $user;
$_SESSION['notification'] = true;
$query = new ParseQuery("_Session");
$query->equalTo("user", $user);
$query->includeKey("user");
$query->descending("createdAt");
$query->limit(1);
$new = $query->find(true);
$_SESSION['last_date'] = date_format($new[0]->getCreatedAt(), 'Y-m-d\\TH:i:s.u\\Z');
echo add_user_report($report_id, $user);
} catch (ParseException $ex) {
$response->success = false;
$response->message = 'Error: Failed to register: ' . $error;
echo json_encode($response);
}
}
示例15: doAddManager
public function doAddManager($adminfName, $adminlName, $adminMail, $adminPass, $adminPerm)
{
# code...
$currentUser = ParseUser::getCurrentUser();
$dbusername = $this->session->userdata('username');
$userDetails = $this->db->get_where('userdetails', ['username' => $dbusername])->row();
$dbgetusername = $userDetails->username;
$dbgetpassword = $userDetails->password;
$user = new ParseUser();
$user->set("username", $adminMail);
$user->set("password", $adminPass);
$user->set("email", $adminMail);
$user->set("creator", $currentUser);
// other fields can be set just like with ParseObject
$user->set("firstName", $adminfName);
$user->set("lastName", $adminlName);
try {
// Query for the role to be assigned to the owner of the company
$role = new ParseObject("_Role");
$query = new ParseQuery("_Role");
$role = $query->get($adminPerm);
$user->signUp();
$role->getUsers()->add($user);
$user->set("role", $role);
$role->save();
$user->save();
ParseUser::logOut();
$prevUser = ParseUser::logIn($dbgetusername, $dbgetpassword);
// Hooray! Let them use the app now.
return ['status' => true];
} catch (ParseException $ex) {
// Show the error message somewhere and let the user try again.
// echo "Error: " . $ex->getCode() . " " . $ex->getMessage();
return ['status' => false, 'parseMsg' => $ex->getMessage()];
}
}