/** * Store a newly created resource in storage. * * @return Response */ public function store(Request $request, UserCreateRequest $UserCreateRequest) { // $input = $request->all(); $slug = $request->input('roles'); $image = $request->file('image'); //find by slug the role $role = Sentinel::findRoleBySlug($slug); //create the user $time = Str::slug(\Carbon\Carbon::now()); if (isset($image)) { $ext = $image->getClientOriginalExtension(); $name = 'user_' . $time . '.' . $ext; $image->move(public_path('img/user_img'), $name); } $input = $request->except(['image']); $input['image'] = isset($image) ? $name : 'avatar-larus.jpeg'; $user = Sentinel::register($input); // we activate the user $activation = Activation::create($user); $code = $activation->code; //if the activation was success, we assignig the role to user if (Activation::complete($user, $code)) { $role->users()->attach($user); return \Redirect::to('users')->withSuccess('El usuario ha sido añadido.'); } }
/** * Создаем тестовых пользователей */ public function run() { $this->command->info('Создаем пользователя: Администратор'); $credentials = array('email' => '*****@*****.**', 'password' => 'admin1111', 'first_name' => 'Иван', 'last_name' => 'Петров', 'company' => 'Такси-сервис', 'city' => 'г. Вологда', 'phone' => '+7 (911) 501-55-55'); $user = Sentinel::register($credentials); $role = Sentinel::findRoleBySlug('admin'); $role->users()->attach($user); // Добавляем оператора Operator::create(array('user_id' => $user->id, 'name' => $user->first_name . ' ' . $user->last_name)); $this->command->info('Создаем пользователя: Тестовый'); $credentials = array('email' => '*****@*****.**', 'password' => 'admin1111', 'first_name' => 'Екатерина', 'last_name' => 'Климова', 'company' => 'Белка тур', 'city' => 'г. Вологда', 'phone' => '+7 (911) 233-33-33'); $user = Sentinel::register($credentials); $role = Sentinel::findRoleBySlug('user'); $role->users()->attach($user); // Добавляем оператора Operator::create(array('user_id' => $user->id, 'name' => $user->first_name . ' ' . $user->last_name)); }
/** * Handle posting of the form for the user registration. * * @return \Illuminate\Http\RedirectResponse */ public function processRegistration(Request $request) { $input = $request->all(); $rules = ['first_name' => 'required', 'last_name' => 'required', 'email' => 'required|email|unique:users', 'password' => 'required', 'retype_password' => 'required|same:password']; $validator = \Validator::make($input, $rules); if ($validator->fails()) { return \Redirect::back()->withInput()->withErrors($validator); } if ($user = Sentinel::register($input)) { $activation = Activation::create($user); $code = $activation->code; if (Activation::complete($user, $code)) { return \Redirect::to('login')->withSuccess('Your accout was successfully created. You might login now.')->with('userId', $user->getUserId()); } } return \Redirect::to('register')->withInput()->withErrors('Failed to register.'); }
/** * Handle a registration request for the application. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function postRegister(Request $request) { //$validator = $this->registrar->validator ( $request->all () ); dd($request->all()); $data = $request->all(); $rules = array('first_name' => 'required', 'last_name' => 'required', 'email' => 'required|email|unique:users,email', 'password' => 'required|min:6', 'password_confirmation' => 'required|min:6|same:password'); $validator = \Validator::make($data, $rules); if ($validator->fails()) { $this->throwValidationException($request, $validator); } //Sentinel::register($data); if (Sentinel::register($data)) { return redirect($this->loginPath()); } //return redirect ( $this->redirectPath () ); /*return redirect ( $this->loginPath () )->withInput ( $request->only ( 'email', 'remember' ) )->withErrors ( [ 'email' => $this->getFailedLoginMessage () ] );*/ }
/** * Handle posting of the form for the user registration. * * @return \Illuminate\Http\RedirectResponse */ public function processRegistration() { $input = Input::all(); $rules = ['email' => 'required|email|unique:users', 'password' => 'required', 'password_confirm' => 'required|same:password']; $validator = Validator::make($input, $rules); if ($validator->fails()) { return Redirect::back()->withInput()->withErrors($validator); } if ($user = Sentinel::register($input)) { $activation = Activation::create($user); $code = $activation->code; $sent = Mail::send('auth.emails.activate', compact('user', 'code'), function ($m) use($user) { $m->to($user->email)->subject('Activate Your Account'); }); if ($sent === 0) { return Redirect::to('register')->withErrors('Failed to send activation email.'); } return Redirect::to('login')->withSuccess('Your accout was successfully created. You might login now.')->with('userId', $user->getUserId()); } return Redirect::to('register')->withInput()->withErrors('Failed to register.'); }
<?php require_once "../includes.php"; use Cartalyst\Sentinel\Native\Facades\Sentinel; $_SESSION["flash"] = "Create your Mivtzoim.net Account"; if (!empty($_POST)) { $credentials = ['email' => $_POST["email"], 'password' => $_POST["password"], 'first name' => $_POST["first_name"], 'last name' => $_POST["last_name"], 'chabad_name' => $_POST["chabad_name"]]; if (register_valid()) { $user = Sentinel::register($credentials, true); Sentinel::login($user, true); $_SESSION["flash"] = "Welcome on Board!"; header('Location:' . $_SESSION["login_redirect"]); } else { $_SESSION["flash"] = "Email already taken. Please try again."; } } ?> <h1><?php echo $_SESSION["flash"]; ?> </h1> <form action="register.php" method="post"> <div> <label for="email"> Email </label> <input type="email" name="email" id="email" required> </div> <div> <label for="password"> Password </label>