public function register(Request $request) { $validate = validateuser::validate(Request::all()); if ($validate->passes()) { $user = new Member(); $user->email = $request::input('email'); $user->password = \Hash::make($request::input('password')); $user->name = $request::input('name'); $user->surname = $request::input('surname'); $user->nickname = $request::input('nickname'); $user->phone = $request::input('phone'); $user->id_card = $request::input('id_card'); $user->bank = $request::input('bank'); $user->account_no = $request::input('account'); $user->education = $request::input('education'); $user->institute = $request::input('institute'); $user->reference = $request::input('reference'); $link = ''; if ($user->save()) { $userinfo = $request::only('email', 'password'); if (Auth::attempt($userinfo)) { $link = '/'; } //ส่ง email //จบส่ง email } else { $link = 'register'; } return Redirect::to($link); } else { return redirect::to('register')->withInput(Request::except('password'))->withErrors($validate->messages()); } }
public function register(Request $request) { $validate = validateuser::validate(Request::all()); //Generate validate code $validatecode = MD5(app('App\\Http\\Controllers\\Sendmail')->generateRandomString()); if ($validate->passes()) { $input_birthday = explode("/", Request::input('birthday')); $birthday = $input_birthday[2] . "-" . $input_birthday[1] . "-" . $input_birthday[0]; $user = new Member(); $user->email = $request::input('email'); $user->password = \Hash::make($request::input('password')); $user->name = $request::input('name'); $user->surname = $request::input('surname'); $user->nickname = $request::input('nickname'); $user->phone = $request::input('phone'); $user->id_card = $request::input('id_card'); $user->birthday = $birthday; //$user->bank = $request::input('bank'); //$user->account_no = $request::input('account'); //$user->education = $request::input('education'); //$user->institute = $request::input('institute'); //$user->reference = $request::input('reference'); //$user->address = $request::input('address'); //$user->province = $request::input('province'); /*if($request::input('province') != 69){ $user->district = 0; }else{ $user->district = $request::input('district'); }*/ $user->userstatus = 1; $user->permission = 1; $user->validate = 1000; $user->email_valid_code = $validatecode; $link = ''; if ($user->save()) { $userinfo = $request::only('email', 'password'); if (Auth::attempt($userinfo)) { $link = 'poatregister'; } //ส่ง email Sendverify::sendEmailReminder($request::input('name') . " " . $request::input('surname'), $request::input('email'), $validatecode); //จบส่ง email } else { $link = 'register'; } //ตรวจสอบสถาบันว่ามีไหมถ้าไม่มีให้เพิ่มไป /*$countinstitute = institute::where('name', 'LIKE', $request::input('institute'))->count(); if($countinstitute < 1){ $institute = new institute(); $institute->name = $request::input('institute'); $institute->save(); }*/ //จบตรวจสอบสถาบันว่ามีไหมถ้าไม่มีให้เพิ่มไป return Redirect::to($link); } else { return redirect::to('register')->withInput(Request::except('password'))->withErrors($validate->messages()); } }
public static function reset() { if (Request::input('rs_type') == "change") { $validate = validateuser::validatechangepass(Request::all()); if ($validate->passes()) { $user = Member::where("id", "=", Request::input('id'))->first(); $dbpass = $user->password; $passcheck = \Hash::check(Request::input('old_password'), $dbpass); if ($passcheck == TRUE) { $user->password = \Hash::make(Request::input('password')); if ($user->save()) { return Redirect::to('user_profile')->with('status', 'Change password has been completed'); } } else { return redirect()->back()->withErrors('Old Password is Wrong!'); } } else { return redirect()->back()->withErrors($validate->messages()); } } else { if (Request::input('rs_type') == "forgot") { $validate = validateuser::validateforgotpass(Request::all()); if ($validate->passes()) { //get email from server $user = Member::where("id", "=", Request::input('id'))->first(); $email = $user->email; //get key from server $reset = Reset::where("email", "=", $email)->first(); $key = $reset->token; //Check email match if ($email == Request::input('email')) { //Check key match if ($key == Request::input('key')) { $user->password = \Hash::make(Request::input('password')); //Change completed if ($user->save()) { return Redirect::to('login')->with('status', 'Change password has been completed'); } } else { return redirect()->back()->withErrors('key is Wrong! Please resend forgot password.'); } } else { return redirect()->back()->withErrors('email is Wrong!'); } } else { return redirect()->back()->withInput(Request::except('password'))->withErrors($validate->messages()); } } else { //Not match all } } }
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()); } }
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()); } }
public static function updateuser() { $validate = validateuser::validateupdateuser(Request::all()); if ($validate->passes()) { $address_id = Request::input('address_id'); if (Request::input('address_id_checkbox') == true) { $address_id = Request::input('address'); } $input_birthday = explode("/", Request::input('birthday')); $birthday = $input_birthday[2] . "-" . $input_birthday[1] . "-" . $input_birthday[0]; $user = Member::where("id", "=", Request::input('id'))->first(); $user->name = Request::input('name'); $user->surname = Request::input('surname'); $user->nickname = Request::input('nickname'); $user->phone = Request::input('phone'); $user->bank = Request::input('bank'); $user->account_no = Request::input('account'); $user->education = Request::input('education'); $user->institute = Request::input('institute'); $user->reference = Request::input('reference'); $user->address = Request::input('address'); $user->province = Request::input('province'); $user->birthday = $birthday; $user->lineid = Request::input('lineid'); $user->address_id = $address_id; if (Request::input('province') != 69) { $user->district = 0; } else { $user->district = Request::input('district'); } if ($user->save()) { $userinfo = Request::only('email', 'password'); //ตรวจสอบสถาบันว่ามีไหมถ้าไม่มีให้เพิ่มไป $countinstitute = institute::where('name', 'LIKE', Request::input('institute'))->count(); if ($countinstitute < 1) { $institute = new institute(); $institute->name = Request::input('institute'); $institute->save(); } //จบตรวจสอบสถาบันว่ามีไหมถ้าไม่มีให้เพิ่มไป return Redirect::to('useredit/' . Request::input('id'))->with('status', 'Update has been completed'); } else { return Redirect::to('useredit/' . Request::input('id'))->withErrors('Error some thing is wrong!'); } } else { return redirect::to('useredit/' . Request::input('id'))->withInput(Request::except('password'))->withErrors($validate->messages()); } }