Esempio n. 1
0
 public function sendEmailReminder()
 {
     $validate = validateuser::validateforgot(Request::all());
     if ($validate->passes()) {
         $count = Member::where('email', '=', Request::input('email'))->count();
         if ($count == 1) {
             $forgot_code = sendmail::generateRandomString();
             $sforgot_code = MD5($forgot_code);
             Mail::send('Member.mailforgot', array('code' => $sforgot_code), function ($message) {
                 $message->to(Request::input('email'))->subject('Your Reminder!');
             });
             return redirect::to('/');
         } else {
             $msg = "Not found email!";
             return redirect::to('forgot')->withInput(Request::except('password'))->withErrors($msg);
         }
     } else {
         return redirect::to('forgot')->withInput(Request::except('password'))->withErrors($validate->messages());
     }
 }
Esempio n. 2
0
 public function sendEmailForgot()
 {
     $validate = validateuser::validateforgot(Request::all());
     if ($validate->passes()) {
         $count = Member::where('email', '=', Request::input('email'))->count();
         if ($count == 1) {
             $forgot_code = sendmail::generateRandomString();
             $sforgot_code = MD5($forgot_code);
             $countforgot = Reset::where('email', '=', Request::input('email'))->count();
             if ($countforgot == 1) {
                 $reset = Reset::where("email", "=", Request::input('email'))->first();
                 $reset->token = $sforgot_code;
                 $reset->save();
             } else {
                 $reset = new Reset();
                 $reset->email = Request::input('email');
                 $reset->token = $sforgot_code;
                 $reset->save();
             }
             $profiles = Member::where('email', '=', Request::input('email'))->get();
             foreach ($profiles as $record) {
                 $name = $record->name;
                 $id = $record->id;
             }
             $email = Request::input('email');
             $link = 'http://www.ojconsultinggroup.com/4oj/reset/' . $id . '/token/' . $sforgot_code;
             $data = array('code' => $sforgot_code, 'name' => $name, 'link' => $link);
             Mail::queue('Member.mailforgot', $data, function ($message) use($email, $data) {
                 $message->to($email)->subject('Your Password Reset Link!');
             });
             return Redirect::to('forgot')->with('status', 'อีเมลสำหรับตั้งรหัสผ่านใหม่ได้ถูกส่งไปแล้ว');
         } else {
             $msg = "เกิดข้อผิดพลาด! ไม่พบชื่ออีเมลนี้ในระบบ";
             return Redirect::to('forgot')->withInput(Request::except('password'))->withErrors($msg);
         }
     } else {
         return Redirect::to('forgot')->withInput(Request::except('password'))->withErrors($validate->messages());
     }
 }