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. 2
0
 /**
  * Handle posting of the form for logging the user in.
  *
  * @return \Illuminate\Http\RedirectResponse
  */
 public function processLogin()
 {
     try {
         $input = Input::all();
         $rules = ['email' => 'required|email', 'password' => 'required'];
         $validator = Validator::make($input, $rules);
         if ($validator->fails()) {
             return Redirect::back()->withInput()->withErrors($validator);
         }
         $remember = (bool) Input::get('remember', false);
         if ($user = \Sentinel::authenticate($input, $remember)) {
             if (\Sentinel::login($user, $remember)) {
                 $this->redirectWhenLoggedIn();
             }
         }
         $errors = 'Invalid login or password.';
     } catch (NotActivatedException $e) {
         $errors = 'Account is not activated!';
         return Redirect::to('reactivate')->with('user', $e->getUser());
     } catch (ThrottlingException $e) {
         $delay = $e->getDelay();
         $errors = "Your account is blocked for {$delay} second(s).";
     }
     return Redirect::back()->withInput()->withErrors($errors);
 }
Esempio n. 3
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);
     // we log this user
     \Sentinel::authenticate($this->_credentials);
 }
Esempio n. 4
0
 /**
  * Handle the event.
  *
  * @param  Login $event
  * @return boolean
  */
 public function handle(Login $event)
 {
     try {
         \Sentinel::authenticate((array) $event->credentials);
         return true;
     } catch (\Exception $e) {
         return false;
     }
 }
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
 /**
  * Login User
  *
  * @param AccountLogin $request
  *
  * @return $this|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
  */
 public function Login(AccountLogin $request)
 {
     $credentials = array('email' => \Input::get('email'), 'password' => \Input::get('password'));
     try {
         $user = \Sentinel::authenticate($credentials, \Input::get('remember_me'));
         \Sentinel::getUserRepository()->recordLogin($user);
         if (\Sentinel::check()) {
             return redirect('/');
         }
     } catch (\Exception $e) {
         return redirect('auth/login')->withErrors(array('login' => trans('auth.errors.login')));
     }
 }
 /**
  * Handle posting of the form for logging the user in.
  *
  * @return \Illuminate\Http\RedirectResponse
  */
 public function login()
 {
     try {
         $input = Input::all();
         $remember = (bool) array_pull($input, 'remember', false);
         $rules = ['email' => 'required|email', 'password' => 'required'];
         $validator = Validator::make($input, $rules);
         if ($validator->fails()) {
             return Redirect::back()->withInput()->withErrors($validator);
         }
         if ($auth = Sentinel::authenticate($input, $remember)) {
             return Redirect::intended('account')->withSuccess('Successfully logged in.');
         }
         $errors = 'Invalid login or password.';
     } catch (NotActivatedException $e) {
         $errors = 'Account is not activated!';
     } catch (ThrottlingException $e) {
         $delay = $e->getDelay();
         $errors = "Your account is blocked for {$delay} second(s).";
     }
     return Redirect::back()->withInput()->withErrors($errors);
 }
Esempio n. 8
0
 /**
  * process the login submit.
  *
  * @return Response
  */
 public function login()
 {
     $potential_user = \Pinom\Models\User::where('email', 'LIKE', \Input::has('email') ? \Input::get('email') : '')->first();
     if (!is_null($potential_user) && trim($potential_user->password) == '') {
         //echo "isnull password!";
         $user = \Sentinel::findById($potential_user->id);
         $password = ['password' => $potential_user->id . '.' . $potential_user->email];
         $user = \Sentinel::update($user, $password);
         $activation = \Activation::create($user);
         $activation = \Activation::complete($user, $activation->code);
     }
     $credentials = ['email' => \Input::has('email') ? \Input::get('email') : '', 'password' => \Input::has('passw') ? \Input::get('passw') : ''];
     //echo '<pre>';
     //return redirect('/');
     $user = \Sentinel::authenticate($credentials);
     //print_R($user);
     if ($user = \Sentinel::check()) {
         return redirect('/login');
     } else {
         return redirect('/login');
     }
 }
 public function postLogin()
 {
     $rules = config('admin.auth.rules');
     $data = \Input::only(array_keys($rules));
     $lang = trans('admin::validation');
     if ($lang == 'admin::validation') {
         $lang = [];
     }
     $validator = \Validator::make($data, $rules, $lang);
     if ($validator->fails()) {
         return \Redirect::back()->withInput()->withErrors($validator);
     }
     if (\Sentinel::authenticate($data)) {
         if (\Sentinel::hasAnyAccess(['superadmin', 'controlpanel'])) {
             return \Redirect::intended(route('admin.wildcard', '/'));
         } else {
             return $this->getLogout();
         }
     }
     $message = new MessageBag(['email' => trans('sentinel::lang.auth.wrong-email'), 'password' => trans('sentinel::lang.auth.wrong-password')]);
     return \Redirect::back()->withInput()->withErrors($message);
 }
Esempio n. 10
0
 public function access_to_forgotten_password_page_while_logged_in(FunctionalTester $I)
 {
     $I->am('Unlogged user');
     $I->wantTo('access to the forgotten password page while logged in');
     $I->expectTo('be redirected to the home page');
     /***************************************************************************************************************
      * run test
      **************************************************************************************************************/
     \Sentinel::authenticate($this->_credentials);
     $I->amOnPage('/');
     $I->amOnRoute('password.index');
     $I->amOnRoute('home');
 }
Esempio n. 11
0
 /**
  * Handles the post of the show_login() page
  */
 public function do_login()
 {
     try {
         $remember_me = false;
         if (Input::get('remember_me') == "on") {
             $remember_me = true;
         }
         // Login credentials
         $credentials = array('email' => Input::get('email'), 'password' => Input::get('password'));
         // Authenticate the user
         $user = Sentinel::authenticate($credentials, false);
         //print_r($user);
     } catch (Exception $e) {
         redirect::to('/user/login')->with('message', 'There has been a problem with your login: '******'/user/login')->with('message', 'There has been a problem with your login');
         exit(0);
     }
     //Check if User has setup his profile
     $setup = SDUserinfo::where('user_id', $user->id)->where('type', 'setup')->first();
     if ($setup != NULL) {
         return Redirect::to('/user/dashboard');
     } else {
         return Redirect::to('/user/profile');
     }
 }
Esempio n. 12
0
    Route::get('destroy', 'CartController@destroy');
    Route::get('count', 'CartController@countAjax');
});
Route::group(['prefix' => 'wishlist'], function () {
    Route::get('/', 'WishlistController@index');
    Route::post('/', 'WishlistController@update');
    Route::get('{id}/add', 'WishlistController@add');
    Route::get('{id}/move', 'WishlistController@move');
    Route::get('{id}/addAjax', 'WishlistController@addAjax');
    Route::get('{id}/remove', 'WishlistController@delete');
    Route::get('{id}/removeAjax', 'WishlistController@deleteAjax');
    Route::get('destroy', 'WishlistController@destroy');
    Route::get('count', 'WishlistController@countAjax');
});
Route::group(['prefix' => 'coupon'], function () {
    Route::post('/', ['as' => 'applyCoupon', 'uses' => 'CartController@applyCoupon']);
    Route::get('remove/{name}', 'CartController@removeCoupon');
});
Route::get('login', function () {
    return View::make('cart.login');
});
Route::post('login', function () {
    if (Sentinel::authenticate(Input::all())) {
        return Redirect::to('/');
    }
    return Redirect::to('login');
});
Route::get('logout', function () {
    Sentinel::logout();
    return Redirect::to('/');
});
Esempio n. 13
0
 public function _authenticate()
 {
     $Sentinel = new Sentinel();
     $Sentinel->init($this);
     return $Sentinel->authenticate();
 }