コード例 #1
0
 /**
  * Create a user
  *
  * @param  Request $request
  * @return Symfony\Component\HttpFoundation\Response
  */
 public function post(Request $request)
 {
     $userData = $this->getContentAsArray($request);
     $errors = $this->userRegistrationValidator->validate($userData ?: []);
     if (count($errors) > 0) {
         return $this->createConstraintViolationResponse($errors);
     }
     try {
         $newUser = $this->userService->register($userData);
     } catch (OutOfBoundsException $e) {
         return $this->createEmailNotUniqueResponse();
     }
     $newUser = $this->userArrayWithoutPassword($newUser);
     $newUser['_href'] = $this->url('user-entity', array('user' => $newUser['id']));
     return $this->createJsonResponse($newUser, 201);
 }
コード例 #2
0
ファイル: RegisterAction.php プロジェクト: CHILMEX/amocasion
 protected function returnSuccess($user)
 {
     $registrationSuccessful = UserService::register($user);
     $message = $registrationSuccessful ? "" : Yii::t('user', 'An email was sent with the registration password');
     if ($this->isAjax()) {
         echo CJSON::encode(array('result' => $registrationSuccessful ? 0 : -1, 'message' => $message));
         Yii::app()->end();
     } else {
         if ($registrationSuccessful) {
             Flashes::addInfoFlash($message);
             $this->getController()->redirect(Yii::app()->user->returnUrl);
         }
     }
 }
コード例 #3
0
ファイル: registerprocess.php プロジェクト: justfu/lavender
 * Date: 2016/1/29
 * Time: 19:20
 */
session_start();
require_once $_SERVER['DOCUMENT_ROOT'] . '/lavender/model/UserService.class.php';
require_once $_SERVER['DOCUMENT_ROOT'] . '/lavender/model/User.class.php';
if (isset($_POST['username']) && isset($_POST['tel']) && isset($_POST['password1'])) {
    $username = $_POST['username'];
    $tel = $_POST['tel'];
    $password1 = $_POST['password1'];
} else {
    echo "请求非法";
    exit;
}
$userService = new UserService();
$user = new User();
$user->setUsername($username);
$user->setTel($tel);
$user->getPassword($password1);
$res = $userService->register($user);
$res_class = $userService->getId($tel);
if ($res == 1) {
    $user_id = $userService->getId($tel);
    $_SESSION['username'] = $username;
    $_SESSION['user_id'] = $res_class->getId();
    echo "<script type='text/javascript'>alert('注册成功!点击回到首页!');location.href='../index.php';</script>";
    exit;
} else {
    echo "<script type='text/javascript'>alert('注册失败!');history.go(-1);</script>";
    exit;
}
コード例 #4
0
ファイル: user_signup.php プロジェクト: samuel072/PHP
/**
*	@author han
* 注册
*
*/
require_once ykfile("source/score_service.php");
require_once ykfile("source/modules/score_module.php");
$json_data = file_get_contents("php://input");
$json_param = json_decode($json_data);
$mobile = $json_param->mobile;
$nickname = $json_param->nickname;
$password = $json_param->password;
$verify_code = $json_param->verify_code;
// 根据手机号码查询服务器端发送的verify_code  对比是否是一样的
$userService = new UserService(@$user_id);
$id = $userService->register($mobile, $password, $nickname);
if ($id) {
    $user_info = $userService->get_by_id($id);
    if (!empty($user_info)) {
        $scoSer = new ScoreService();
        $rule_list = $scoSer->apply_rule($user_info, GET_SCORE, ScoreModule::point_signup);
        $user_info = $userService->get_by_uuid($user_info->uuid);
        unset($_SESSION['current_user']);
        // 成功登陆 干掉session中关于前一个用户信息
        $_SESSION['current_user'] = serialize($user_info);
        // 装载新的用户信息
        $message = "";
        foreach ($rule_list as $rule) {
            $msg = $rule->title . " + " . $rule->amount;
            $message[] = $msg;
        }