public function doSignUp(SignUpRequest $request) { $username = $request->get('username'); $email = $request->get('email'); $phone = $request->get('phone'); $password = $request->get('password'); $nickname = $request->has('nickname') ? $request->get('nickname') : ''; $verificationCodeForUsername = $request->get('verification_code_for_username'); $verificationCodeForPhone = $request->get('verification_code_for_phone'); $verificationCodeForEmail = $request->get('verification_code_for_email'); if ($username) { throw new NotSupportedException(NotSupportedException::FeatureOnTheWay); } if ($email) { throw new NotSupportedException(NotSupportedException::FeatureOnTheWay); } if ($phone) { throw new NotSupportedException(NotSupportedException::FeatureOnTheWay); } $user = UserManager::signUp($username, $email, $phone, $password); $user->roles()->attach(System::getDefaultRole()); $user->save(); $userInfo = new UserInfo(); $userInfo->user()->associate($user); $userInfo->save(); return $this->buildResponse(trans('api.auth.sign_up.success'), $user); }
/** * Store a newly created resource in storage. * * @param Request $request * @return Response */ public function store(Requests\SignUpRequest $request) { // $usermodel = new User(); $all = $request->all(); try { $password = $all["password"]; $payload = \Crypt::encrypt($password); $all["password"] = $payload; $all['role'] = 5; if (isset($all['_token'])) { unset($all['_token']); } $user = $usermodel->newUser($all); if ($user) { $login = $this->login($all); return $login; } dd("signup failed!"); } catch (Exception $e) { $message = $e->getMessage(); $code = $e->getCode(); dd(["message" => $message, "code" => $code]); } }
public function create(SignUpRequest $request) { $data['name'] = $request->get('name'); $data['email'] = $request->get('email'); $data['password'] = bcrypt($request->get('password')); $user = User::create($data); Auth::login($user, true); return redirect('/list'); }
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'); } }