本文整理汇总了PHP中Sentinel::authenticate方法的典型用法代码示例。如果您正苦于以下问题:PHP Sentinel::authenticate方法的具体用法?PHP Sentinel::authenticate怎么用?PHP Sentinel::authenticate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sentinel
的用法示例。
在下文中一共展示了Sentinel::authenticate方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: signUp
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');
}
示例2: _before
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' => 'test@test.fr', '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);
}
示例3: handle
/**
* 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;
}
}
示例4: _before
public function _before(FunctionalTester $I)
{
// we set the credentials
$this->_credentials = ['last_name' => 'Test', 'first_name' => 'test', 'email' => 'test@test.fr', '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);
}
示例5: Login
/**
* 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')));
}
}
示例6: 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);
}
示例7: login
/**
* 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');
}
}
示例8: postLogin
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);
}
示例9: access_to_forgotten_password_page_while_logged_in
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');
}
示例10: do_login
/**
* 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: ' . $e->getMessage());
exit(0);
}
if (!isset($user) | $user == "") {
redirect::to('/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');
}
}
示例11: function
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('/');
});
示例12: _authenticate
public function _authenticate()
{
$Sentinel = new Sentinel();
$Sentinel->init($this);
return $Sentinel->authenticate();
}