public function postCreate(Request $request)
 {
     $name = $request->input('name');
     $nameLen = str_gbk_len($name);
     if (!is_user_name($name) || $nameLen < 4 || $nameLen > 24) {
         return response()->json(['status' => false, 'message' => '姓名需要由字母或汉字开始和结束;' . '<br/>中间可包含汉字、字母、数字、_-·;' . '<br/>总长度为4~24个字符,一个汉字为2个字符', 'field' => 'name']);
     }
     $password = $this->getPassword($request);
     if (!is_string($password)) {
         return $password;
     }
     $detail = $this->getVerifiedDetail('register', $request);
     if (!is_array($detail)) {
         return $detail;
     }
     $verifyType = $detail['verify_type'];
     $identifier = $detail['identifier'];
     if (!User::hasBeenUsed($verifyType, $identifier, true)->exists()) {
         try {
             $user = User::create([$verifyType => $identifier, 'realname' => $name, 'password' => $password, 'inviter' => session('inviter_uid') ?: 0, $verifyType . '_verified_at' => time()])->login(null, true);
             return response()->json(['status' => true, 'location' => session('project_invite') ? session('project_invite.active_url') : url('user/home')]);
         } catch (\Exception $e) {
         }
     }
     return response()->json(['status' => false, 'message' => '注册失败,请稍后在尝试注册', 'field' => '']);
 }
Beispiel #2
0
 public function postBasic(Request $request)
 {
     $realname = $request->input('realname');
     $realnameLen = str_gbk_len($realname);
     if (!is_user_name($realname) || $realnameLen < 4 || $realnameLen > 24) {
         return response()->json(['status' => false, 'message' => '姓名需要由字母或汉字开始和结束;' . '<br/>中间可包含汉字、字母、数字、_-·;' . '<br/>总长度为4~24个字符,一个汉字为2个字符', 'field' => 'realname']);
     }
     $user = auth()->user();
     $user->realname = $realname;
     $user->intro = $request->input('intro');
     $result = $user->save();
     return response()->json(['status' => (bool) $result, 'message' => $result ? '保存成功' : '保存失败', 'field' => '']);
 }
Beispiel #3
0
 public function postSaveMemberName($id, Request $request)
 {
     $this->projectId = (int) $id;
     if (!$this->getProjectPermission('setting')) {
         return response()->json(['status' => false, 'message' => '没有权限更改此选项']);
     }
     $member = ProjectMember::where('project_id', $this->projectId)->where('user_id', $request->input('user_id'))->first();
     $userName = $request->input('user_name');
     print_r($member);
     if ($member && is_user_name($userName) && str_gbk_len($userName) <= 24) {
         $member->user_name = $userName;
         $member->save();
         return response()->json(['status' => true, 'message' => '设置成功']);
     } else {
         return response()->json(['status' => false, 'message' => '设置失败']);
     }
 }