コード例 #1
0
ファイル: TriggerSms.php プロジェクト: kukujiabo/linpai
 private function resetSms()
 {
     $token = ResetPassword::where('mobile', '=', $this->mobile)->where('active', '=', 1)->first();
     if (!empty($token->id)) {
         $token->active = 0;
         $token->save();
     }
     $newToken = rand(100000, 999999);
     $resetPasswd = new ResetPassword();
     $resetPasswd->mobile = $this->mobile;
     $resetPasswd->token = $newToken;
     $resetPasswd->deliver_at = date('Y-m-d H:i:s');
     $res = $resetPasswd->save();
     if ($res) {
         $post_data = array('appid' => $this->appid, 'signature' => $this->signature, 'project' => $this->pro_reset, 'vars' => "{ \"token\": \"{$resetPasswd->token}\"}", 'to' => $this->mobile);
         return $this->send('post', $this->mobile, $post_data);
     }
     return null;
 }
コード例 #2
0
ファイル: UserController.php プロジェクト: kukujiabo/linpai
  public function postPasswdreset(Request $request) 
  {
    $user = User::where('mobile', '=', $request->input('mobile'))->first();

    if (empty($user->id)) {

      if (!empty($request->input('mb'))) {
      
      
      } else {

        return redirect('/user/password');

      }

    }

    $validate = Validator::make($request->input(), [
    
      'reset_code' => 'required',

      'newpassword' => 'required|min:6|max:18',

      'confirmpassword' => 'required|min:6|max:18',
    
    ]); 

    if ($validate->fails()) {

      $failed = $validate->failed();

      return $this->failResponse($failed);

    }

    $inputs = $request->input();

    $rp = ResetPassword::where('token', '=', $inputs['reset_code'])

      ->where('active', '=', 1)

      ->first();

    if (empty($rp->id)) {

      return $this->failResponse([ 'reset_code' => 'not_found' ]);

    }

    if ($inputs['newpassword'] != $inputs['confirmpassword']) {

      return $this->failResponse('not_match');

    }

    $rp->active = 0;

    $rp->status = 1;

    $rp->save();

    $user->password = bcrypt($inputs['newpassword']);
  
    $res = $user->save();

    if ($res) {

      return $this->successResponse();

    } else {

      return $this->failResponse('save_failed');

    }
  
  }