/**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::table('three_step_admin')->delete();
     ThreeStepAdmin::create(array('ts_implement' => 1, 'ts_bypass' => 1, 'ts_test' => 1, 'permit_delay' => 5, 'ts_user' => 'admin'));
 }
 public function postStepOne(Request $request, ThreeStep $threeStep, ThreeStepAdmin $threeStepAdmin, ThreeStepLog $three_step_log, ThreeStepUser $tSUser)
 {
     $three_step_log->ip_address = $request->getClientIp();
     $three_step_log->step = 'three step step one post entry';
     $three_step_log->save();
     $validation_rules = $threeStep->getValidationRules();
     $this->validate($request, $validation_rules);
     $arr_request = $threeStep->getRequestArray($request);
     $obj_ts_user = $tSUser->where('role_id', 1)->first();
     if (!($obj_ts_user == null)) {
         if (!Hash::check($arr_request['password'], $obj_ts_user->password)) {
             $errors = array('message' => 'Your credentials for this page could not be validated');
             $data = $threeStep->getDataArrayGetStepOne($obj_ts_user->hint, $arr_request['confidence_msg']);
             return view('three_step/step_one')->with('data', $data)->withErrors($errors);
         } else {
             $ts_bypass = $threeStepAdmin->getTSBypass();
             $ts_test = $threeStepAdmin->getTSTest();
             $threeStep->three_step_id = Hash::make((string) time());
             $threeStep->session_id = $request->session()->getId();
             $threeStep->save();
             if ($ts_bypass) {
                 $three_step_log->ip_address = $request->getClientIp();
                 $three_step_log->step = 'three step step two success';
                 $three_step_log->save();
                 Session::put('three_step_id_from_step_two', $threeStep->three_step_id);
                 return redirect('admin/home')->withInput();
             } else {
                 $three_step_url = $threeStep->prepareURL($threeStep->three_step_id);
                 $recipient = $obj_ts_user->email;
                 $data = $threeStep->getDataArrayEmail($arr_request['confidence_msg'], $three_step_url, $ts_test);
                 $mail_content = view('emails/three_step')->with('data', $data)->render();
                 $three_step_log->ip_address = $request->getClientIp();
                 $three_step_log->step = 'three step step one post mail sent';
                 $three_step_log->save();
                 return view('three_step/step_one_success')->with('data', $data);
                 // this is the laravel mail
                 // commented out as no credentials for mail server are available
                 // see function in user.php moldel for more info
                 /*
                  $user->sendMailResetPassword(
                  		$password_reset_url,
                  		$obj_user
                  );
                 */
                 // echo "line 103 reached<br>";
                 /*
                     			if ($threeStep->sendMailThreeStep(
                     					$mail_content,
                     					$recipient
                     				))
                     			{
                     				return view('three_step/step_one_success');
                     			}
                 */
             }
             // end else, if no bypass
         }
         //    	$data = $threeStep->getDataArray(
         //   			$arr_request['password']);
     }
     //    	return view('three_step/step_one_fail');
 }
 public function postConfigure(Request $request, ThreeStepUser $three_step_user, ThreeStepAdmin $threeStepAdmin)
 {
     //    	echo "<pre>";
     //   	print_r($request);
     //    	echo "</pre>";
     $validationRules = $threeStepAdmin->getValidationRulesConfigure();
     $this->validate($request, $validationRules);
     $arrRequest = $threeStepAdmin->getRequestArrayConfigure($request);
     $threeStepAdmin = $threeStepAdmin->where('ts_user', 'admin')->first();
     if (!$threeStepAdmin == null) {
         $threeStepAdmin->ts_implement = $arrRequest['ts_implement'];
         $threeStepAdmin->ts_bypass = $arrRequest['ts_bypass'];
         $threeStepAdmin->ts_test = $arrRequest['ts_test'];
         $threeStepAdmin->permit_delay = $arrRequest['permit_delay'];
         $threeStepAdmin->save();
         $data = $threeStepAdmin->getDataArrayChangePassword(null, $this->arr_logged_in_user);
         return view('three_step_admin/configure_results')->with('data', $data);
     } else {
         $data = $three_step_admin->getDataArrayChangePassword('No three step user found.', $this->arr_logged_in_user);
         return view('three_step_admin/change_password_hint')->with('data', $data);
     }
 }