예제 #1
0
 public function memberEdit(Request $request)
 {
     $member = Member::find($request->input('id', ''));
     $member->nickname = $request->input('nickname', '');
     $member->phone = $request->input('phone', '');
     $member->email = $request->input('email', '');
     $member->save();
     $m3_result = new M3Result();
     $m3_result->status = 0;
     $m3_result->message = '添加成功';
     return $m3_result->toJson();
 }
 public function validateEmail(Request $request)
 {
     $member_id = $request->input('member_id', '');
     $code = $request->input('code', '');
     if ($member_id == '' || $code == '') {
         return '验证异常';
     }
     $tempEmail = TempEmail::where('member_id', $member_id)->first();
     if ($tempEmail == null) {
         return '验证异常';
     }
     if ($tempEmail->code == $code) {
         if (time() > strtotime($tempEmail->deadline)) {
             return '该链接已失效';
         }
         $member = Member::find($member_id);
         $member->active = 1;
         $member->save();
         return redirect('/login');
     } else {
         return '该链接已失效';
     }
 }
예제 #3
0
 public function login(Request $request)
 {
     $username = $request->get('username', '');
     $password = $request->get('password', '');
     $validate_code = $request->get('validate_code', '');
     $m3_result = new M3Result();
     // 校验
     // ....
     // 判断
     // $validate_code_session = $request->session()->get('validate_code');
     // if($validate_code != $validate_code_session) {
     //   $m3_result->status = 1;
     //   $m3_result->message = '验证码不正确';
     //   return $m3_result->toJson();
     // }
     $member = null;
     if (strpos($username, '@') == true) {
         $member = Member::where('email', $username)->first();
     } else {
         $member = Member::where('phone', $username)->first();
     }
     if ($member == null) {
         $m3_result->status = 2;
         $m3_result->message = '该用户不存在';
         return $m3_result->toJson();
     } else {
         if (md5('bk' + $password) != $member->password) {
             $m3_result->status = 3;
             $m3_result->message = '密码不正确';
             return $m3_result->toJson();
         }
     }
     $request->session()->put('member', $member);
     $m3_result->status = 0;
     $m3_result->message = '登录成功';
     return $m3_result->toJson();
 }