本文整理汇总了PHP中Illuminate\Support\Facades\Auth::once方法的典型用法代码示例。如果您正苦于以下问题:PHP Auth::once方法的具体用法?PHP Auth::once怎么用?PHP Auth::once使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Support\Facades\Auth
的用法示例。
在下文中一共展示了Auth::once方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: verify
public function verify($username, $password)
{
$credentials = ['email' => $username, 'password' => $password];
if (Auth::once($credentials)) {
return Auth::user()->id;
}
return false;
}
示例2: verify
public function verify($username, $password)
{
$credentials = ['usuario' => $username, 'password' => $password];
if (Auth::once($credentials)) {
return Auth::user()->IdUsuario;
}
return false;
}
示例3: authenticate
/**
* Authenticate with json response, use for external auth
*
* @param Request $request
*
* @return \Illuminate\Contracts\Routing\ResponseFactory|\Symfony\Component\HttpFoundation\Response
*/
public function authenticate(Request $request)
{
$params = $request->only('email', 'password');
if (Auth::once($params)) {
return Auth::user();
}
return response(['error' => 'Invalid user.']);
}
示例4: verifyAdmin
public function verifyAdmin($username, $password)
{
$credentials = ['username' => $username, 'password' => $password];
if (Auth::once($credentials)) {
return Auth::user()->type == "admin" ? Auth::user()->id : false;
} else {
return false;
}
}
示例5: verify
public function verify($username, $password)
{
$telephoneCredentials = ['telephone' => $username, 'password' => $password];
$usernameCredentials = ['username' => $username, 'password' => $password];
$emailCredentials = ['email' => $username, 'password' => $password];
if (Auth::once($telephoneCredentials) || Auth::once($usernameCredentials) || Auth::once($emailCredentials)) {
return Auth::user()->id;
}
return false;
}
示例6: verify
public function verify($username, $password)
{
$credentials = ['email' => $username, 'password' => $password];
if (Auth::once($credentials)) {
return Auth::user()->id;
}
/*if(Auth::validate($credentials)){
$user = \CodeProject\Entities\User::where('email',$username)->first();
return $user->id;
}*/
return false;
}
示例7: auth
public function auth(Request $request)
{
$data = $this->validateRequest($request, ['username', 'password'], true);
$result = Auth::once(['username' => $data->username, 'password' => $data->password]);
if ($result !== true || !Auth::user()->isDriver()) {
throw new LoginException("Logging in user: {$data->username}");
}
// Generate session key
$key = Str::random(32);
$this->cache->put("shuttle.{$this->shuttle->name}.key", $key, 60 * 8);
$this->cache->put("shuttle.{$this->shuttle->name}.user", Auth::user(), 60 * 8);
return $this->encryptJson(['key' => $key]);
}
示例8: postLogin
/**
* Logs the user in.
*
* @return \Illuminate\Http\RedirectResponse
*/
public function postLogin()
{
$loginData = Binput::only(['email', 'password']);
// Validate login credentials.
if (Auth::validate($loginData)) {
// Log the user in for one request.
Auth::once($loginData);
// We probably want to add support for "Remember me" here.
Auth::attempt($loginData);
return Redirect::intended('dashboard');
}
return Redirect::route('auth.login')->withInput(Binput::except('password'))->withError(trans('forms.login.invalid'));
}
示例9: verify
public function verify($username, $password)
{
$credentials = ['email' => $username, 'password' => $password];
// Check for FB login
if ($this->request->has('token_facebook')) {
$user = $this->userRepo->createUser($this->request->all());
return $user->id;
}
// For normal users
if (Auth::once($credentials)) {
return Auth::user()->id;
}
return false;
}
示例10: loginPost
/**
* Logs the user in.
*
* @return \Illuminate\Http\RedirectResponse
*/
public function loginPost()
{
$loginData = Request::only(['login', 'password']);
// Login with username or email.
$loginKey = Str::contains($loginData['login'], '@') ? 'email' : 'username';
$loginData[$loginKey] = array_pull($loginData, 'login');
// Validate login credentials.
if (Auth::validate($loginData)) {
// Log the user in for one request.
Auth::once($loginData);
// We probably want to add support for "Remember me" here.
Auth::attempt($loginData);
//return Redirect::intended('/')
return Redirect::home()->withSuccess(trans('gitamin.signin.success'));
}
return Redirect::route('auth.login')->withInput(Request::except('password'))->withError(trans('gitamin.signin.invalid'));
}
示例11: verify
public function verify($username, $password)
{
$hash = Request::input('hash');
$credentials = ['username' => $username, 'password' => $password];
if (presence($hash) && $hash === 'md5') {
// prehashed, we want to skip the md5 step of OsuHasher
$user = User::where('username', $username)->first();
if (password_verify($password, $user->getAuthPassword())) {
return $user->user_id;
}
} else {
if (Auth::once($credentials)) {
return Auth::user()->user_id;
}
}
return false;
}
示例12: postLogin
/**
* Logs the user in.
*
* @return \Illuminate\Http\RedirectResponse
*/
public function postLogin()
{
$loginData = Binput::only(['email', 'password']);
// Validate login credentials.
if (Auth::validate($loginData)) {
// Log the user in for one request.
Auth::once($loginData);
// Do we have Two Factor Auth enabled?
if (Auth::user()->hasTwoFactor) {
// Temporarily store the user.
Session::put('2fa_id', Auth::user()->id);
return Redirect::route('auth.two-factor');
}
// We probably want to add support for "Remember me" here.
Auth::attempt($loginData);
return Redirect::intended('dashboard');
}
return Redirect::route('auth.login')->withInput(Binput::except('password'))->withError(trans('forms.login.invalid'));
}
示例13: login
/**
* @param $data
* @return \Alfredoem\Ragnarok\Soul\RagnarokResponse
*/
public function login($data)
{
if (!key_exists('remember', $data)) {
$data['remember'] = false;
}
// login attempt
if (Auth::once(['email' => $data['email'], 'password' => $data['password']], $data['remember'])) {
$auth = Auth::user();
// Store session user
$session = SecUserSessions::create(['userId' => $auth->userId, 'sessionCode' => Make::uniqueString(), 'ipAddress' => $data['ipAddress'], 'status' => 1, 'dateIns' => date('Y-m-d'), 'datetimeIns' => date('Y-m-d H:m:s')]);
$auth->ipAddress = $data['ipAddress'];
$auth->sessionCode = $session->sessionCode;
$auth->userSessionId = $session->userSessionId;
$auth->environment = Session::get('environment');
// Make ragnarok user
$this->userRagnarok->make($auth);
$this->success = true;
}
return $this->responseRagnarok->make($this->success, $this->userRagnarok);
}
示例14: postLogin
/**
* Handle a login request to the application.
*
* @param LoginRequest $request
* @return Response
*/
protected function postLogin(Request $request)
{
$throttles = $this->isUsingThrottlesLoginsTrait();
$credentials = $this->getCredentials($request);
$validator = Validator::make($credentials, ['email' => 'required|email', 'password' => 'required']);
if ($validator->fails()) {
if (!$this->api) {
return redirect(route('login'))->withErrors($validator);
} else {
return response()->json(['data' => ['errors' => $validator->errors()->getMessages()]], 400);
}
}
$result = $this->api ? Auth::once($credentials, $request->has('remember')) : Auth::attempt($credentials, $request->has('remember'));
if (!$result) {
if (!$this->api) {
return redirect(route('register'));
} else {
return response()->json(['data' => ['message' => 'Error authorization']], 401);
}
}
if (!$this->api) {
return redirect(route('home'));
} else {
$token = Auth::user()->generationToken();
return response()->json(['data' => ['token' => $token]], 200);
}
}
示例15: authenticate
/**
* @param $username
* @param $password
* @return bool or user id
*/
public function authenticate($username, $password)
{
$credentials = ['email' => $username, 'password' => $password];
if (Auth::once($credentials)) {
return Auth::user()->id;
}
Log::info("Tentativa de login falhou. Usuário: {$username}, Senha: {$password}");
return false;
}