public function index()
 {
     if (!isset($_SESSION['login'])) {
         return Redirect::to('login');
     }
     //if(Request::ajax()) {
     $data = \Input::all();
     //print_r($data);die;
     //}
     $FirstName = $data['FirstName'];
     $LastName = $data['LastName'];
     $Email = $data['Email'];
     $password = Password::generatePassword(9);
     /*	$emailExist = DB::table('userdetail')->where('Email', $Email)->count();
     		
     		if($emailExist > 0)
     		{
     			\Session::flash('flash_error','Email is already available.');
     			return;
     		}*/
     DB::table('userdetail')->insert(array('Email' => $Email, 'FirstName' => $FirstName, 'LastName' => $LastName, 'Password' => md5($password)));
     $dataEmail = array("email" => $Email, "password" => $password);
     Mail::send('email.createUser', $dataEmail, function ($message) {
         $data = \Input::all();
         $Email = $data['Email'];
         $message->from('*****@*****.**', 'SAS');
         $message->to($Email, 'sas')->subject('New user account created in SAS');
         $message->replyTo('*****@*****.**', 'noreply');
     });
 }
 /**
  * Reset the given user's password.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function postReset(Request $request)
 {
     $this->validate($request, ['token' => 'required', 'email' => 'required|email', 'password' => 'required|confirmed']);
     $credentials = $request->only('email', 'password', 'password_confirmation', 'token');
     $response = Password::reset($credentials, function ($user, $password) {
         $this->resetPassword($user, $password);
     });
     switch ($response) {
         case Password::PASSWORD_RESET:
             return redirect($this->redirectPath());
         default:
             return redirect()->back()->withInput($request->only('email'))->withErrors(['email' => trans($response)]);
     }
 }
예제 #3
0
 public function index()
 {
     //if(Request::ajax()) {
     $data = \Input::all();
     //print_r($data);die;
     //}
     $FirstName = $data['FirstName'];
     $LastName = $data['LastName'];
     $Email = $data['Email'];
     $password = Password::generatePassword(9);
     DB::table('userdetail')->insert(array('Email' => $Email, 'FirstName' => $FirstName, 'LastName' => $LastName, 'Password' => md5($password)));
     $dataEmail = array("email" => $Email, "password" => $password);
     Mail::send('email.createUser', $dataEmail, function ($message) {
         $data = \Input::all();
         $Email = $data['Email'];
         $message->from('*****@*****.**', 'SAS');
         $message->to($Email, 'sas')->subject('New user account created in SAS');
         $message->replyTo('*****@*****.**', 'noreply');
     });
 }
예제 #4
0
 public function activateAccount(\Illuminate\Http\Request $request)
 {
     //Log::info($request);
     $inputs = Request::all();
     foreach ($inputs as $input => $value) {
         Log::info($input . ' - ' . $value);
     }
     $this->validate($request, ['email' => 'required|email', 'password' => 'required|confirmed|min:2']);
     $credentials = $request->only('email', 'password', 'password_confirmation', 'token');
     $response = \Password::reset($credentials, function ($user, $password) {
         $this->resetPassword($user, $password);
     });
     switch ($response) {
         case \Password::PASSWORD_RESET:
             return redirect($this->redirectPath())->with('status', trans($response));
         default:
             return redirect()->back()->withInput($request->only('email'))->withErrors(['email' => trans($response)]);
     }
 }
예제 #5
0
 public function postRegistrationForm(SignUpRequest $request)
 {
     $data = $request->all();
     //Demographic Insert
     /*
         Demographic details captured below are 
         the only values that are nessary for 
         users, customer demographics will use
         the same table however more details 
         will be required on the post array.
     */
     $demo = new Demographic();
     $demo->email = $data['email'];
     $demo->first_name = $data['name'];
     $demo->last_name = $data['usr_surname'];
     $demo->title_id = $data['usr_title'];
     $demo->d_active = 1;
     $demo->date = Carbon::now();
     $demo->save();
     //Password Insert
     /*
         Password input in Database must be salted
         there after the password must be stored in
         a separate password table so the password
         history can be maintained.
     */
     $pass = new Password();
     $random_salt = hash('sha512', uniqid(mt_rand(1, mt_getrandmax()), true));
     $password = hash('sha512', $data['p'] . $random_salt);
     $pass->password = $password;
     $pass->p_active = '1';
     $pass->p_date = Carbon::now();
     $pass->save();
     //Salt Insert
     /*
         Random Salt must be saved in database so that
         the password can be un-salted and compared to
         the user's password captured upon login.
     */
     $salt = new Salt();
     $salt->salt = $random_salt;
     $salt->save();
     //Creat Login and Associate to Demo/Pass/Salt
     /*
         Only once the required associated data is 
         captured can a login be created. It is 
         important to maintain an environment that 
         can be scaled out, we're doing this by 
         maintaining high levels of normalization.
     */
     $login = new Login();
     $login->login = $data['email'];
     $login->p_id = $pass->p_id;
     $login->s_id = $salt->s_id;
     $login->r_id = $data['usr_role'];
     $login->d_id = $demo->d_id;
     $login->usr_active = 0;
     $successfull = $login->save();
     //Get Security Control Key
     /*
         This function always certain security keys
         to be retireved from the database and used 
         in functions/arguments here.
     */
     //Set Email verification key
     /*
         To ensure that we are not spammed, we will
         need to only allow users/customer whom have
         a verified email address to login, therefore
         until the user verifies their email address 
         their login will not be active.
     */
     $email = new verify_emailaddress();
     $email->key = md5('3m@!l01' . time());
     $email->key_active = 1;
     $email->d_id = $demo->d_id;
     $email->save();
     //Open Route upon success/fail
     /*
         The below opens the route depending on the 
         outcome of the registration login model save.
     */
     if (!$successfull) {
         return redirect('signup_failed');
     } else {
         return redirect('signup_success');
     }
 }