/**
  * Create user information
  * @param  array  $data
  * @return
  */
 public function createUser(array $data)
 {
     try {
         // Create the user
         $user = \Sentinel::register(['email' => $data['email'], 'last_name' => $data['last_name'], 'first_name' => $data['first_name'], 'password' => bcrypt($data['password'])]);
         // if(isset($data['image']))
         // {
         //     $file      = $data['image'];
         //     $filename  = str_random(30);
         //     $filename .= "." . $file->getClientOriginalExtension();
         //     $file->move('public/img', $filename);
         // }
         return $user;
     } catch (\Cartalyst\Sentry\Users\LoginRequiredException $e) {
         echo 'Login field is required.';
     } catch (\Cartalyst\Sentry\Users\PasswordRequiredException $e) {
         echo 'Password field is required.';
     } catch (\Cartalyst\Sentry\Users\UserExistsException $e) {
         echo 'User with this login already exists.';
     }
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::table('users')->truncate();
     // Register a new user
     Sentinel::register(['email' => '*****@*****.**', 'last_name' => 'Naguit', 'first_name' => 'Chester', 'password' => 'P@ssw0rd']);
     Sentinel::register(['email' => '*****@*****.**', 'last_name' => 'Miranda', 'first_name' => 'Jefferson', 'password' => 'P@ssw0rd']);
 }
 public function signUp()
 {
     if ($this->app->request()->isPost()) {
         $v = $this->validator($this->post());
         $v->rule('required', array('email', 'password'));
         $v->rule('email', 'email');
         $v->rule('length', 'password', 3, 11);
         if ($v->validate()) {
             try {
                 $credentials = array('email' => $this->post('email'), 'password' => $this->post('password'));
                 $user = Sentinel::register($credentials, true);
                 if ($user) {
                     /* Login right after signup */
                     Sentinel::authenticate($credentials);
                     $this->successFlash('Your registration was successful.');
                     $this->redirect('home');
                 } else {
                     $this->errorFlash('User information was not updated successfully.');
                 }
             } catch (UserExistsException $e) {
                 $this->errorFlash('User with this login already exists.');
             } catch (UserNotFoundException $e) {
                 $this->errorFlash('User was not found.');
             }
         }
         $this->app->flashNow('error', $this->errorOutput($v->errors()));
     }
     $this->render('login/signup');
 }
Esempio n. 4
0
 public function _before(FunctionalTester $I)
 {
     // we create a user
     $this->_credentials = ['gender' => config('user.gender_key.male'), 'last_name' => 'Test', 'first_name' => 'test', 'birth_date' => '1985-03-24', 'phone_number' => '+33 6 66 66 66 66', 'email' => '*****@*****.**', 'address' => '7 impasse du Taureau Ailé', 'zip_code' => 44300, 'city' => 'Nantes', 'country' => 'France', 'status_id' => config('user.status_key.communication_commission'), 'board_id' => config('user.board_key.leading_board'), 'password' => 'test'];
     $this->_user = \Sentinel::register($this->_credentials, true);
     $this->_slide_repo = app(SlideRepositoryInterface::class);
     // we log this user
     \Sentinel::authenticate($this->_credentials);
 }
Esempio n. 5
0
 public function _before(FunctionalTester $I)
 {
     // we set the credentials
     $this->_credentials = ['last_name' => 'Test', 'first_name' => 'test', 'email' => '*****@*****.**', 'status' => config('user.status_key.communication_commission'), 'board' => config('user.board_key.leading_board'), 'password' => 'test'];
     // we create the user
     $this->_user = \Sentinel::register($this->_credentials, true);
     // we log the user
     \Sentinel::authenticate($this->_credentials);
 }
Esempio n. 6
0
 /**
  * Register an account
  *
  * @param AccountRegister $request
  *
  * @return $this
  */
 public function Register(AccountRegister $request)
 {
     try {
         $credentials = array('username' => \Input::get('username'), 'email' => \Input::get('email'), 'password' => \Input::get('password'));
         \Sentinel::register($credentials);
         $activation_user = \Sentinel::getUserRepository()->findByCredentials($credentials);
         $activation = \Activation::create($activation_user);
         \Mail::queue('emails.account.activate_account', ['username' => \Input::get('username'), 'user_id' => $activation['user_id'], 'activation_code' => $activation['code'], 'activation_url' => env('URL') . '/auth/activate?' . http_build_query(array('ActivationCode' => $activation['code'], 'UserId' => $activation['user_id']))], function ($message) {
             $message->from('*****@*****.**', 'Modest Music | Account Services');
             $message->to(\Input::get('email'));
         });
         return redirect('auth/login')->withErrors(array('login' => 'We have sent your activation email. Please check the Spam Folder.'));
     } catch (\Exception $e) {
         return redirect('auth/register')->withErrors(array('register' => $e->getMessage()));
     }
 }
 /**
  * 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('sentinel.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.');
 }
Esempio n. 8
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $credentials = [];
     if (!$this->option('email') && !$this->option('password')) {
         $credentials['email'] = $this->ask('Whats the users email?', null);
         $credentials['password'] = $this->secret('Whats the users password? (it will not be displayed)', null);
     } else {
         $credentials['email'] = $this->option('email');
         $credentials['password'] = $this->option('password');
         $credentials['username'] = $this->option('username');
         $credentials['first_name'] = $this->option('first_name');
         $credentials['last_name'] = $this->option('last_name');
     }
     if (\Validator::make($credentials, ['email' => 'required|email', 'password' => 'required'])->passes()) {
         $user = \Sentinel::register($credentials);
         $activation = \Activation::create($user);
         \Activation::complete($user, $activation->code);
         $this->info('User created successfully and user activated.');
     } else {
         $this->error('You did not enter a valid email address!');
     }
 }
Esempio n. 9
0
 public function activate_account_from_email(FunctionalTester $I)
 {
     $I->am('Unlogged user with a not activated account');
     $I->wantTo('activate my account');
     $I->expectTo('see a success confirmation message explaining that my account is activated');
     /***************************************************************************************************************
      * settings
      **************************************************************************************************************/
     // we create a user
     $this->_credentials = ['last_name' => 'NOM', 'first_name' => 'Prénom', 'email' => '*****@*****.**', 'password' => 'password'];
     $user = \Sentinel::register($this->_credentials);
     // we create an activation
     $activation = \Activation::create($user);
     /***************************************************************************************************************
      * run test
      **************************************************************************************************************/
     $I->sendAjaxRequest('GET', route('account.activate', ['email' => $user->email, 'token' => $activation->code]));
     $I->see(trans('global.modal.alert.title.success'));
     $I->see(strip_tags(trans('auth.message.activation.success', ['name' => $user->first_name . ' ' . $user->last_name])));
 }
Esempio n. 10
0
 public function access_to_the_leading_team_page(FunctionalTester $I)
 {
     $I->am('Anybody');
     $I->wantTo('access to the leading team page');
     $I->expectTo('see that the user shown in the category they belong');
     /***************************************************************************************************************
      * settings
      **************************************************************************************************************/
     // we create a member of the student leading board
     $credentials = ['last_name' => 'Student', 'first_name' => 'President', 'email' => '*****@*****.**', 'status_id' => config('user.status_key.student_president'), 'board_id' => config('user.board_key.student_leading_board'), 'password' => 'test'];
     Sentinel::register($credentials, true);
     // we create a member of the student leading board
     $credentials = ['last_name' => 'Deactivated', 'first_name' => 'Student vice-president', 'email' => '*****@*****.**', 'status_id' => config('user.status_key.user'), 'board_id' => config('user.board_key.student_leading_board'), 'password' => 'test'];
     Sentinel::register($credentials);
     // we create a member of the leading board
     $credentials = ['last_name' => 'Regular', 'first_name' => 'President', 'email' => '*****@*****.**', 'status_id' => config('user.status_key.president'), 'board_id' => config('user.board_key.leading_board'), 'password' => 'test'];
     Sentinel::register($credentials, true);
     // we create a member of the executive committee
     $credentials = ['last_name' => 'Communication', 'first_name' => 'Responsible', 'email' => '*****@*****.**', 'status_id' => config('user.status_key.communication_commission'), 'board_id' => config('user.board_key.executive_committee'), 'password' => 'test'];
     Sentinel::register($credentials, true);
     // we create an employee
     $credentials = ['last_name' => 'Coach', 'first_name' => 'Employee', 'email' => '*****@*****.**', 'status_id' => config('user.status_key.employee'), 'password' => 'test'];
     Sentinel::register($credentials, true);
     /***************************************************************************************************************
      * run test
      **************************************************************************************************************/
     $I->amOnPage('/');
     $I->seeCurrentRouteIs('home');
     $I->click(trans('template.front.header.leading_team'));
     $I->see('Student', '.student_leading_board');
     $I->see('President', '.student_leading_board');
     $I->see(trans('users.config.status.student_president'), '.student_leading_board');
     $I->dontSee('Deactivated', '.student_leading_board');
     $I->dontSee('Student vice-president', '.student_leading_board');
     $I->dontSee(trans('users.config.status.user'), '.student_leading_board');
     $I->see('Regular', '.leading_board');
     $I->see('President', '.leading_board');
     $I->see(trans('users.config.status.president'), '.leading_board');
     $I->see('Communication', '.executive_committee');
     $I->see('Responsible', '.executive_committee');
     $I->see(trans('users.config.status.communication_commission'), '.executive_committee');
     $I->see('Coach', '.employee');
     $I->see('Employee', '.employee');
     $I->see(trans('users.config.status.employee'), '.employee');
 }
Esempio n. 11
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Model::unguard();
     Sentinel::register(['email' => '*****@*****.**', 'username' => 'fake', 'password' => 'test'], true);
     Model::reguard();
 }
Esempio n. 12
0
 public function run()
 {
     // we remove all the files in the storage user folder
     $files = glob(storage_path('app/users/*'));
     foreach ($files as $file) {
         if (is_file($file)) {
             unlink($file);
         }
     }
     // we create the folder if it doesn't exist
     if (!is_dir($storage_path = storage_path('app/users'))) {
         if (!is_dir($path = storage_path('app'))) {
             mkdir($path);
         }
         mkdir($path . '/users');
     }
     /**
      * LEADING BOARD
      */
     $moderator_role = Sentinel::findRoleBySlug('moderator');
     // we create a user
     $user = Sentinel::register(['last_name' => 'GIRARD', 'first_name' => 'Lionel', 'email' => '*****@*****.**', 'status_id' => config('user.status_key.president'), 'board_id' => config('user.board_key.leading_board'), 'password' => str_random()], true);
     // we attach the user to the user role
     $moderator_role->users()->attach($user);
     // we set the una logo as the user image
     $file_name = ImageManager::optimizeAndResize(database_path('seeds/files/users/girard.jpg'), $user->imageName('photo'), 'jpg', $user->storagePath(), $user->availableSizes('photo'), false);
     $user->photo = $file_name;
     $user->save();
     // we create a user
     $user = Sentinel::register(['last_name' => 'VARAINE', 'first_name' => 'David', 'email' => '*****@*****.**', 'status_id' => config('user.status_key.vice_president'), 'board_id' => config('user.board_key.leading_board'), 'password' => str_random()], true);
     // we attach the user to the user role
     $moderator_role->users()->attach($user);
     // we set the una logo as the user image
     $file_name = ImageManager::optimizeAndResize(database_path('seeds/files/users/varaine.jpg'), $user->imageName('photo'), 'jpg', $user->storagePath(), $user->availableSizes('photo'), false);
     $user->photo = $file_name;
     $user->save();
     // we create a user
     $user = Sentinel::register(['last_name' => 'DISCAZEAU', 'first_name' => 'Gérard', 'email' => '*****@*****.**', 'status_id' => config('user.status_key.treasurer'), 'board_id' => config('user.board_key.leading_board'), 'password' => str_random()], true);
     $moderator_role->users()->attach($user);
     // we set the una logo as the user image
     $file_name = ImageManager::optimizeAndResize(database_path('seeds/files/users/users-default-avatar.png'), $user->imageName('photo'), 'png', $user->storagePath(), $user->availableSizes('photo'), false);
     $user->photo = $file_name;
     $user->save();
     // we create a user
     $user = Sentinel::register(['last_name' => 'THERIOT', 'first_name' => 'David', 'email' => '*****@*****.**', 'status_id' => config('user.status_key.secretary_general'), 'board_id' => config('user.board_key.leading_board'), 'password' => str_random()], true);
     $moderator_role->users()->attach($user);
     // we set the una logo as the user image
     $file_name = ImageManager::optimizeAndResize(database_path('seeds/files/users/theriot.png'), $user->imageName('photo'), 'png', $user->storagePath(), $user->availableSizes('photo'), false);
     $user->photo = $file_name;
     $user->save();
     /**
      * STUDENT LEADING BOARD
      */
     // we create a user
     $user = Sentinel::register(['last_name' => 'PLANCHENAULT', 'first_name' => 'Thomas', 'email' => '*****@*****.**', 'status_id' => config('user.status_key.student_president'), 'board_id' => config('user.board_key.student_leading_board'), 'password' => str_random()], true);
     $moderator_role->users()->attach($user);
     // we set the una logo as the user image
     $file_name = ImageManager::optimizeAndResize(database_path('seeds/files/users/planchenault.jpg'), $user->imageName('photo'), 'jpg', $user->storagePath(), $user->availableSizes('photo'), false);
     $user->photo = $file_name;
     $user->save();
     // we create a user
     $user = Sentinel::register(['last_name' => 'DIETER', 'first_name' => 'Lara', 'email' => '*****@*****.**', 'status_id' => config('user.status_key.student_secretary'), 'board_id' => config('user.board_key.student_leading_board'), 'password' => str_random()], true);
     $moderator_role->users()->attach($user);
     // we set the una logo as the user image
     $file_name = ImageManager::optimizeAndResize(database_path('seeds/files/users/dieter.jpg'), $user->imageName('photo'), 'jpg', $user->storagePath(), $user->availableSizes('photo'), false);
     $user->photo = $file_name;
     $user->save();
     // we create a user
     $user = Sentinel::register(['last_name' => 'ETIENVRE', 'first_name' => 'Marianne', 'email' => '*****@*****.**', 'status_id' => config('user.status_key.student_treasurer'), 'board_id' => config('user.board_key.student_leading_board'), 'password' => str_random()], true);
     $moderator_role->users()->attach($user);
     // we set the una logo as the user image
     $file_name = ImageManager::optimizeAndResize(database_path('seeds/files/users/etienvre.jpg'), $user->imageName('photo'), 'jpg', $user->storagePath(), $user->availableSizes('photo'), false);
     $user->photo = $file_name;
     $user->save();
     // we create a user
     $user = Sentinel::register(['last_name' => 'LEGOFF', 'first_name' => 'Benoit', 'email' => '*****@*****.**', 'status_id' => config('user.status_key.student_vice_president'), 'board_id' => config('user.board_key.student_leading_board'), 'password' => str_random()], true);
     $moderator_role->users()->attach($user);
     // we set the una logo as the user image
     $file_name = ImageManager::optimizeAndResize(database_path('seeds/files/users/legoff.jpg'), $user->imageName('photo'), 'jpg', $user->storagePath(), $user->availableSizes('photo'), false);
     $user->photo = $file_name;
     $user->save();
     /**
      * EXECUTIVE COMMITTEE
      */
     // we create a user
     $user = Sentinel::register(['last_name' => 'LORENT', 'first_name' => 'Arthur', 'email' => '*****@*****.**', 'status_id' => config('user.status_key.communication_commission'), 'board_id' => config('user.board_key.executive_committee'), 'password' => 'password'], true);
     // we attach the user to the admin role
     $admin = \Sentinel::findRoleBySlug('admin');
     $admin->users()->attach($user);
     // we set the una logo as the user image
     $file_name = ImageManager::optimizeAndResize(database_path('seeds/files/users/lorent.jpg'), $user->imageName('photo'), 'jpg', $user->storagePath(), $user->availableSizes('photo'), false);
     $user->photo = $file_name;
     $user->save();
     // we create a user
     $user = Sentinel::register(['last_name' => 'PROTT', 'first_name' => 'Thierry', 'email' => '*****@*****.**', 'status_id' => config('user.status_key.sportive_commission'), 'board_id' => config('user.board_key.executive_committee'), 'password' => str_random()], true);
     $moderator_role->users()->attach($user);
     // we set the una logo as the user image
     $file_name = ImageManager::optimizeAndResize(database_path('seeds/files/users/prott.jpg'), $user->imageName('photo'), 'jpg', $user->storagePath(), $user->availableSizes('photo'), false);
     $user->photo = $file_name;
     $user->save();
     // we create a user
     $user = Sentinel::register(['last_name' => 'ROUSSEAU', 'first_name' => 'Benjamin', 'email' => '*****@*****.**', 'status_id' => config('user.status_key.sportive_commission'), 'board_id' => config('user.board_key.executive_committee'), 'password' => str_random()], true);
     $moderator_role->users()->attach($user);
     // we set the una logo as the user image
     $file_name = ImageManager::optimizeAndResize(database_path('seeds/files/users/rousseau.jpg'), $user->imageName('photo'), 'jpg', $user->storagePath(), $user->availableSizes('photo'), false);
     $user->photo = $file_name;
     $user->save();
     // we create a user
     $user = Sentinel::register(['last_name' => 'LECIEUX', 'first_name' => 'Yann', 'email' => '*****@*****.**', 'board_id' => config('user.board_key.executive_committee'), 'password' => str_random()], true);
     $moderator_role->users()->attach($user);
     // we set the una logo as the user image
     $file_name = ImageManager::optimizeAndResize(database_path('seeds/files/users/lecieux.jpg'), $user->imageName('photo'), 'jpg', $user->storagePath(), $user->availableSizes('photo'), false);
     $user->photo = $file_name;
     $user->save();
     // we create a user
     $user = Sentinel::register(['last_name' => 'BOUZIDI', 'first_name' => 'Rabah', 'email' => '*****@*****.**', 'board_id' => config('user.board_key.executive_committee'), 'password' => str_random()], true);
     $moderator_role->users()->attach($user);
     // we set the una logo as the user image
     $file_name = ImageManager::optimizeAndResize(database_path('seeds/files/users/users-default-avatar.png'), $user->imageName('photo'), 'png', $user->storagePath(), $user->availableSizes('photo'), false);
     $user->photo = $file_name;
     $user->save();
     // we create a user
     $user = Sentinel::register(['last_name' => 'ROBIN', 'first_name' => 'Pauline', 'email' => '*****@*****.**', 'board_id' => config('user.board_key.executive_committee'), 'password' => str_random()], true);
     $moderator_role->users()->attach($user);
     // we set the una logo as the user image
     $file_name = ImageManager::optimizeAndResize(database_path('seeds/files/users/robin.png'), $user->imageName('photo'), 'png', $user->storagePath(), $user->availableSizes('photo'), false);
     $user->photo = $file_name;
     $user->save();
     // we create a user
     $user = Sentinel::register(['last_name' => 'ROBIN DIOT', 'first_name' => 'Ainhoa', 'email' => '*****@*****.**', 'board_id' => config('user.board_key.executive_committee'), 'password' => str_random()], true);
     $moderator_role->users()->attach($user);
     // we set the una logo as the user image
     $file_name = ImageManager::optimizeAndResize(database_path('seeds/files/users/robin-diot.jpg'), $user->imageName('photo'), 'jpg', $user->storagePath(), $user->availableSizes('photo'), false);
     $user->photo = $file_name;
     $user->save();
     // we create a user
     $user = Sentinel::register(['last_name' => 'VERNAY', 'first_name' => 'Solenn', 'email' => '*****@*****.**', 'board_id' => config('user.board_key.executive_committee'), 'password' => str_random()], true);
     $moderator_role->users()->attach($user);
     // we set the una logo as the user image
     $file_name = ImageManager::optimizeAndResize(database_path('seeds/files/users/vernay.jpg'), $user->imageName('photo'), 'jpg', $user->storagePath(), $user->availableSizes('photo'), false);
     $user->photo = $file_name;
     $user->save();
     /**
      * EMPLOYEES
      */
     // we create a user
     $user = Sentinel::register(['last_name' => 'VESPERINI', 'first_name' => 'Laurent', 'email' => '*****@*****.**', 'status_id' => config('user.status_key.employee'), 'password' => str_random()], true);
     $coach_role = Sentinel::findRoleBySlug('coach');
     $coach_role->users()->attach($user);
     // we set the una logo as the user image
     $file_name = ImageManager::optimizeAndResize(database_path('seeds/files/users/users-default-avatar.png'), $user->imageName('photo'), 'png', $user->storagePath(), $user->availableSizes('photo'), false);
     $user->photo = $file_name;
     $user->save();
 }
Esempio n. 13
0
 public function run()
 {
     $_user = Sentinel::register(['email' => '*****@*****.**', 'password' => 'abc123'], true);
     $group = Sentinel::findRoleByName('Admin');
     $group->users()->attach($_user);
 }