本文整理汇总了PHP中Illuminate\Contracts\Auth\Guard::login方法的典型用法代码示例。如果您正苦于以下问题:PHP Guard::login方法的具体用法?PHP Guard::login怎么用?PHP Guard::login使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Contracts\Auth\Guard
的用法示例。
在下文中一共展示了Guard::login方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: postRegister
/**
* Handle a registration request for the application.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function postRegister(Request $request)
{
$me = $request->all();
$validator = $this->registrar->validator($request->all());
$confirmation_code = str_random(30);
if ($validator->fails()) {
//dd($validator);
$this->throwValidationException($request, $validator);
}
// $this->auth->login($this->registrar->create($me));
$user = User::find(Input::get('email'));
if ($user) {
$this->auth->login($this->registrar->create($me));
}
$confirm = new Confirm();
$confirm->name = Input::get('name');
$confirm->email = Input::get('email');
$confirm->password = Hash::make(Input::get('password'));
$confirm->confirmation_code = $confirmation_code;
$confirm->save();
if (Mail::send('emailverify', array('confirmation_code' => $confirmation_code, 'username' => Input::get("name")), function ($message) {
$message->to(Input::get('email'), Input::get('username'))->subject('Verify your email address');
})) {
return view('doverification')->with(["message" => 'please verify the email address (' . Input::get("email") . ') through verification code we sent to you on the registerd email-address!!!<br>
plz also check you sapn folder', 'button_message' => 'Verify', 'button_url' => 'http://www' . Input::get("email") . '/']);
}
return "error";
}
示例2: handle
/**
* Execute the command.
*
* @return void
*/
public function handle()
{
if (in_array($this->provider, $this->allowedProviders)) {
$user = User::findByUserNameOrCreate(Socialite::with($this->provider)->user());
$this->auth->login($user);
}
}
示例3: create
/**
* Handle a registration request for the application.
*
* @param \Apolune\Account\Http\Requests\Account\CreateRequest $request
* @return \Illuminate\Http\Response
*/
public function create(CreateRequest $request)
{
$account = $this->dispatch(new CreateAccount());
$player = $this->dispatch(new CreatePlayer($account));
$this->auth->login($account);
return redirect('/account');
}
示例4: postRegister
/**
* @param UserRegisterRequest $request
* @param UserService $user
* @return \Illuminate\Http\RedirectResponse
*/
public function postRegister(UserRegisterRequest $request, UserService $user)
{
$input = $request->only(['name', 'email', 'password']);
$result = $user->registerUser($input);
$this->auth->login($result);
return redirect()->route('admin.entry.index');
}
示例5: postRegister
/**
* Handle a registration request for the application.
*
* @param \Illuminate\Foundation\Http\FormRequest $request
* @return \Illuminate\Http\Response
*/
public function postRegister(Request $request)
{
$validator = $this->registrar->validator($request->all());
if ($validator->fails()) {
$this->throwValidationException($request, $validator);
}
if (config('socialAuthenticator.activation')) {
$activation_code = str_random(60) . $request->input('email');
$user = new User();
$user->name = $request->input('name');
$user->email = $request->input('email');
$user->password = bcrypt($request->input('password'));
$user->activation_code = $activation_code;
if ($user->save()) {
$data = array('name' => $user->name, 'code' => $activation_code);
Mail::queue('socialAuthenticator::activateAccount', $data, function ($message) use($user) {
$message->to($user->email, $user->name)->subject(config('socialAuthenticator.email_subject'));
});
return view('user.activateAccount');
} else {
Session::flash('message', 'Your account couldn\'t be create please try again');
return redirect()->back()->withInput();
}
}
$user = new User();
$user->name = $request->input('name');
$user->email = $request->input('email');
$user->password = bcrypt($request->input('password'));
$user->save();
$this->auth->login($user);
return redirect($this->redirectPath());
}
示例6: authenticate
/**
* Autneticat
*
* @param $provider
* @return bool
*/
public function authenticate($provider)
{
$socialUser = $this->social->with($provider)->stateless()->user();
if (!$socialUser) {
return false;
}
$identity = $this->oauth->findByProviderNameAndId($socialUser->id, $provider);
if ($identity) {
$this->oauth->update($identity, ['token' => $socialUser->token]);
$this->auth->loginUsingId($identity->user_id, true);
return true;
}
$user = $this->user->findByEmail($socialUser->email);
if (!is_null($user)) {
$this->oauth->create(['provider_id' => $socialUser->id, 'provider' => $provider, 'user_id' => $user->id, 'token' => $socialUser->token]);
$this->user->update($user, ['status' => 1]);
$this->auth->login($user, true);
return true;
}
if (!setting('registration', true)) {
return false;
}
// Just create the user
$newUser = $this->user->create(['name' => $this->emailToName($socialUser->email), 'email' => $socialUser->email, 'password' => '', 'status' => 1, 'avatar' => $socialUser->avatar]);
event(new UserCreatedThroughOAuth($newUser));
$this->oauth->create(['provider_id' => $socialUser->id, 'provider' => $provider, 'user_id' => $newUser->id, 'token' => $socialUser->token]);
$this->auth->login($newUser, true);
return true;
}
示例7: postRegister
/**
* 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());
if ($validator->fails()) {
$this->throwValidationException($request, $validator);
}
if (config('opciones.seguridad.Email')) {
//Añadimos a la request nuevos parámetros a incluir en el usuario a crear
$codigoConfirmacion = str_random(30);
$request->request->add(['activo' => "1", 'confirmado' => "0", "codigo_confirmacion" => $codigoConfirmacion]);
try {
$envio = Mail::send('emails.verificacion', ["codigoConfirmacion" => $codigoConfirmacion], function ($message) use($request) {
$message->from($request->get('email'));
$message->to($request->get('email'))->subject('Verifica tu dirección de correos.');
});
} catch (\Exception $ex) {
$envio = 0;
}
if ($envio == 0) {
return Redirect('/')->with('mensaje', 'No se ha podido enviar el email de confirmación a tu cuenta de correos.Comprueba cortafuegos y/o antivirus.');
}
$this->registrar->create($request->all());
return Redirect('/')->with('mensaje', 'Gracias por darte de alta, Por favor verifica tu cuenta de correos.');
} else {
$request->request->add(['activo' => "1", 'confirmado' => "1", "codigo_confirmacion" => null]);
$this->auth->login($this->registrar->create($request->all()));
return redirect($this->redirectPath());
}
}
示例8: postChange
/**
* Reset the given user's password.
*
* @param Request $request
* @return Response
*/
public function postChange(Request $request)
{
$validator = Validator::make($request->all(), ['token' => 'required', 'old_passwd' => 'required', 'password' => 'required|confirmed'], [], ['old_passwd' => '原密码', 'password' => '新密码']);
if ($validator->fails()) {
return Redirect::back()->withInput()->withErrors($validator);
}
$auth_array = array('email' => Auth::user()->email, 'password' => Input::get('old_passwd'));
if (Auth::validate($auth_array)) {
} else {
return redirect()->back()->withErrors("请输入正确的密码!");
}
$credentials = array('email' => Auth::user()->email, 'password' => Input::get('password'), 'password_confirmation' => Input::get('password_confirmation'), 'token' => Input::get('token'));
$response = $this->passwords->reset($credentials, function ($user, $password) {
$user->password = bcrypt($password);
$user->save();
$this->auth->login($user);
});
switch ($response) {
case PasswordBroker::PASSWORD_RESET:
$array = array('email' => Auth::user()->email);
$token = $this->passwords->getToken($array);
UserManageLog::insertLog("修改密码", Auth::user()->id, Auth::user()->name, Auth::user()->email, Auth::user()->name . '(' . Auth::user()->email . ')', null, null, $request->ip());
return view('auth.change_password')->withTips("密码修改成功!")->withToken($token);
default:
return redirect()->back()->withErrors(['email' => trans($response)]);
}
}
示例9: handle
/**
* Handle an incoming request.
*
* @param Request $request
* @param Closure $next
*
* @return mixed
*/
public function handle(Request $request, Closure $next)
{
// If the user is already logged in, we don't need to reauthenticate.
if (!$this->auth->check()) {
// Retrieve the SSO login attribute.
$auth = $this->getWindowsAuthAttribute();
// Retrieve the SSO input key.
$key = key($auth);
// Handle Windows Authentication.
if ($account = $request->server($auth[$key])) {
// Usernames may be prefixed with their domain,
// we just need their account name.
$username = explode('\\', $account);
if (count($username) === 2) {
list($domain, $username) = $username;
} else {
$username = $username[key($username)];
}
// Create a new user LDAP user query.
$query = $this->newAdldapUserQuery();
// Filter the query by the username attribute
$query->whereEquals($key, $username);
// Retrieve the first user result
$user = $query->first();
if ($user instanceof User) {
$model = $this->getModelFromAdldap($user, str_random());
if ($model instanceof Model) {
// Double check user instance before logging them in.
$this->auth->login($model);
}
}
}
}
return $this->returnNextRequest($request, $next);
}
示例10: login
private function login(YoutubeUser $youtubeUser, User $user)
{
// Log user in
$this->auth->login($user);
// Populate users session
$this->populateSession($youtubeUser);
}
示例11: handle
/**
* Handle the event.
*
* @param UserWasCreated $event
* @return void
*/
public function handle(UserWasCreated $event)
{
if (!canContact()) {
$this->auth->login($event->user);
return;
}
$user = $this->userService->generateConfirmation($event->user);
$this->mailer->confirm($user);
}
示例12: loginVendorProviders
/**
* @param $request
* @param $provider
* @return \Illuminate\Http\RedirectResponse|\Symfony\Component\HttpFoundation\RedirectResponse
*/
public function loginVendorProviders($request, $provider)
{
if (!$request) {
return $this->getAuthorizationFirst($provider);
}
$user = $this->users->findByUserNameOrCreate($this->getSocialUser($provider), $provider);
$this->auth->login($user, true);
return redirect('/');
}
示例13: execute
/**
* If code is available, create or update the user, then log in.
*
* @param boolean $hasCode
* @param AuthenticateUserListener $listener
* @return \Symfony\Component\HttpFoundation\RedirectResponse
*/
public function execute($hasCode, AuthenticateUserListener $listener)
{
if (!$hasCode) {
return $this->getAuthorizationFirst();
}
$user = $this->users->findByUsernameOrCreate($this->getGithubUser());
$this->auth->login($user, true);
return $listener->userHasLoggedIn($user);
}
示例14: execute
public function execute($hasCode, $listener, $provider)
{
if (!$hasCode) {
return $this->getAuthorization($provider);
}
$user = $this->users->findByUsernameOrCreate($this->getUser($provider));
$this->auth->login($user, true);
return $listener->userAuthenticated($user);
}
示例15: postRegister
/**
* 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());
if ($validator->fails()) {
$this->throwValidationException($request, $validator);
}
$this->auth->login($this->registrar->create($request->all()));
return redirect($this->redirectPath());
}