Exemplo n.º 1
2
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $trainer = ['first_name' => 'Michael', 'last_name' => 'Favila', 'email' => '*****@*****.**', 'password' => 'password'];
     try {
         $trainerUser = Sentinel::registerAndActivate($trainer);
         $trainerUser->roles()->attach(Sentinel::findRoleBySlug('customer_trainer'));
     } catch (\Exception $e) {
         // nothing to do
     }
 }
Exemplo n.º 2
1
 /**
  * {@inheritDoc}
  */
 public function registerAndActivate(array $data)
 {
     // Setup validation rules.
     $this->rules = ['email' => 'required|email|unique:users', 'password' => 'required|confirmed', 'password_confirmation' => 'required'];
     // Run validation.
     $this->validate($data);
     $user = Sentinel::registerAndActivate($data);
     if (!isset($data['role'])) {
         $data['role'] = config('laraflock.dashboard.defaultRole');
     }
     if (!($role = Sentinel::findRoleBySlug($data['role']))) {
         throw new RolesException(trans('dashboard::dashboard.errors.role.found'));
     }
     $role->users()->attach($user);
     return;
 }
Exemplo n.º 3
0
 /**
  * Registers and authenticates a user by the specified credentials.
  *
  * @param array $credentials
  *
  * @return \Illuminate\Http\RedirectResponse
  */
 private function registerAndAuthenticateUser(array $credentials)
 {
     $model = Sentinel::createModel();
     // See if the LDAP user already has an account first
     $user = $model->where('email', $credentials['email'])->first();
     if ($user) {
         // Update the user
         Sentinel::update($user, $credentials);
         // Log them in
         Sentinel::login($user);
         $message = 'Successfully logged in.';
         return redirect()->intended('/')->withSuccess($message);
     } else {
         $user = Sentinel::registerAndActivate($credentials);
         if ($user) {
             $user->username = $credentials['username'];
             $user->save();
             Sentinel::login($user);
             $message = 'Successfully logged in.';
             return redirect()->intended('/')->withSuccess($message);
         }
     }
     $message = 'There was an issue creating your active directory account. Please try again.';
     return redirect()->route('maintenance.login.index')->withErrors($message);
 }
Exemplo n.º 4
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request $request
  *
  * @return \Illuminate\Http\Response
  */
 public function postStore()
 {
     if (!empty($request['email'] = Input::get('email')) && !empty($request['password'] = Input::get('password'))) {
         if (!Sentinel::findByCredentials($request)) {
             if (mb_strlen(Input::get('password')) < 8) {
                 $response['status'] = 'warning';
                 $response['message'] = trans('user_notifications.password_length');
             } else {
                 if (Sentinel::registerAndActivate($request)) {
                     $response['status'] = 'success';
                     $response['message'] = trans('user_notifications.user_created');
                 } else {
                     $response['status'] = 'error';
                     $response['message'] = trans('user_notifications.user_not_created');
                 }
             }
         } else {
             $response['status'] = 'error';
             $response['message'] = trans('user_notifications.user_exists');
         }
     } else {
         $response['status'] = 'warning';
         $response['message'] = trans('global.all_fields_required');
     }
     return response()->json($response);
 }
 protected function create(SentinelPostRequest $request)
 {
     $user = $request->only(["first_name", "last_name", "email", "password", "password_confirmation"]);
     // Registre, ative e faça login do usuário local
     $eloquent_user = Sentinel::registerAndActivate($user);
     Sentinel::login($eloquent_user);
     // Mande um e-mail
     Event::fire(new PostUserRegister($eloquent_user));
     return redirect()->route("user.dashboard");
 }
Exemplo n.º 6
0
 public function doRegister()
 {
     if (!empty($request['email'] = Input::get('email')) && !empty($request['password'] = Input::get('password'))) {
         if (!Sentinel::findByCredentials($request)) {
             if (!filter_var($request['email'], FILTER_VALIDATE_EMAIL)) {
                 $response['status'] = 'warning';
                 $response['message'] = trans('user_notifications.invalid_email');
             } else {
                 if (mb_strlen(Input::get('password')) < 8) {
                     $response['status'] = 'warning';
                     $response['message'] = trans('user_notifications.password_length');
                 } else {
                     if (Sentinel::registerAndActivate($request)) {
                         $user = Sentinel::authenticate($request);
                         //If Authentication was successful
                         if (!empty($user)) {
                             Sentinel::loginAndRemember($user);
                         }
                         $data = ['sys_title' => $this->system['title'], 'sys_email' => $this->system['email'], 'user' => $user];
                         Mail::send('dressplace::emails.register', $data, function ($m) use($data) {
                             $m->from($data['sys_email'], $data['sys_title']);
                             $m->replyTo($data['sys_email'], $data['sys_title']);
                             $m->to($data['user']['email'], $data['user']['email'])->subject(trans('client.register_mail'));
                         });
                         $response['status'] = 'success';
                         $response['message'] = trans('user_notifications.user_created');
                     } else {
                         $response['status'] = 'error';
                         $response['message'] = trans('user_notifications.user_not_created');
                     }
                 }
             }
         } else {
             $response['status'] = 'error';
             $response['message'] = trans('user_notifications.user_exists');
         }
     } else {
         $response['status'] = 'warning';
         $response['message'] = trans('global.all_fields_required');
     }
     echo json_encode($response);
 }