コード例 #1
0
 public function postForgotpass()
 {
     $rules = array('email' => 'required|email');
     if (CNF_RECAPTCHA == 'true') {
         $rules['recaptcha_response_field'] = 'required|recaptcha';
     }
     $validator = Validator::make(Input::all(), $rules);
     if ($validator->passes()) {
         $cus = DB::table('customer')->where('email', '=', Input::get('email'))->first();
         if (count($cus) > 0) {
             $pass = SiteHelpers::randomPassword();
             DB::table('customer')->where('email', '=', Input::get('email'))->update(array('password' => md5($pass)));
             $data = array('name' => $cus->name, 'username' => $cus->username, 'pass' => $pass);
             Mail::send('emails.forgotpass', $data, function ($message) {
                 $message->from(CNF_EMAIL, 'Admin');
                 $message->to(Input::get('email'), '')->subject('Thông tin đăng nhập');
             });
         }
         return Redirect::to('thong-bao.html')->with('message', SiteHelpers::alert('success', 'Vui lòng kiểm tra Email để nận mật khẩu mới !'));
     } else {
         return Redirect::to('forgotpass.html')->with('message_forgotpass', SiteHelpers::alert('error', 'Vui lòng xác nhận các thông tin bên dưới'))->withErrors($validator)->withInput();
     }
 }