国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

? ??? ?? PHP ???? Laravel?? Socialite ?? ?? ? ???

Laravel?? Socialite ?? ?? ? ???

Jan 03, 2025 am 11:17 AM

Implementing & testing Socialite authentication in Laravel

Laravel Socialite? ???? ???????? OAuth ? OAuth2 ?? ??? ???? ? ??? ?? ?? Laravel ??????. Facebook, Twitter, Google, LinkedIn, GitHub, GitLab ? Bitbucket? ????? ?????. Socialite? ???? ???? ?? ?? ????? ??? ? ????.

? ???? ??? ??? ????.

  • ?????? ?? ?? ?? ?? ?? ?????.
  • Socialite? ?? Google ??? ??? Laravel ????? ???? ??? ?????.
  • ????? ??? ??? ?????.

TLDR: ? GitHub?? ??? ????? ? ? ????. ??? ??? ?? ??? ? ? ?????.

Laravel Socialite? ??? ?? ??? ?? ?????

Socialite? ?? API? ?? ? ?? ?? ???? ??? ?? ??????.

  • Socialite::driver($authProvider)->redirect()? ???? ??? ?? ????? ?????? URL ????? ?? ??? ??? ????? ?????.
  • Socialite::driver($authProvider)->user()? ?? ?????? ?? ??? ??? ???? ???? ??????? ??? ? ??? ???.

?? ?? ? ??? ????? ?? ?? ?? ??? ????. ?? ?? ??? Socialite ???? ???? ? ????.

Socialite? ??? ???? ???? ??? ??? ??? ????? ????.

  • ? ?? ?? ???? ???? ? ??? ?????? ????? ?? ????.
  • ? ?? ???? ???? ?? ???? ?????.
  • ? OAuth ??? ??? ? ???? ?????.
  • ? OAuth ??? ?? ????.

?? ??: Google Cloud ???? ???

???? Google? ?? ??? ? ?? ??? Socialite ????? ???????. ??? ???? ?? ?? ???? ???.

?? ? Google Cloud ????? ?? ?? ????? ?? OAuth ?? ??? ?????. ??? ??? ??? ??? ? ?? ??? ??????.

  • .../auth/userinfo.email
  • .../auth/userinfo.profile

?? ??? ??? ? Google Cloud ?? ?? ???? ???? OAuth 2.0 ????? ID? ?????. ????? ID? ????? ????? ?????. ??? ?????? ??? ????.

Socialite? ???? ?? Laravel ???? ??

? Laravel ???? ???:

laravel new socialite-tests

?? ?????? ?? ??? ?????.

 ┌ Would you like to install a starter kit? ────────────────────┐
 │ No starter kit                                               │
 └──────────────────────────────────────────────────────────────┘

 ┌ Which testing framework do you prefer? ──────────────────────┐
 │ Pest                                                         │
 └──────────────────────────────────────────────────────────────┘

 ┌ Which database will your application use? ───────────────────┐
 │ SQLite                                                       │
 └──────────────────────────────────────────────────────────────┘

 ┌ Would you like to run the default database migrations? ──────┐
 │ Yes                                                          │
 └──────────────────────────────────────────────────────────────┘

???? ????? ???? Socialite? ?????.

laravel new socialite-tests

? ??????? ?????.

 ┌ Would you like to install a starter kit? ────────────────────┐
 │ No starter kit                                               │
 └──────────────────────────────────────────────────────────────┘

 ┌ Which testing framework do you prefer? ──────────────────────┐
 │ Pest                                                         │
 └──────────────────────────────────────────────────────────────┘

 ┌ Which database will your application use? ───────────────────┐
 │ SQLite                                                       │
 └──────────────────────────────────────────────────────────────┘

 ┌ Would you like to run the default database migrations? ──────┐
 │ Yes                                                          │
 └──────────────────────────────────────────────────────────────┘

database/migrations? ?? ??? ?????? ??? ?? ??? ?????.

cd socialite-tests
composer require laravel/socialite

? ???????? ???? ????? ???? Socialite?? ??? ??? ?????. ????? ???? ?? ??? ??? ??? ???? ?? ?????. Google?? ? ?? ???? ????? ???? ?? ???? ??? ? ?? ??? ???? ??? ?? ????.

???? Google? ???? ???? ?? ????? ???? ???? ????? null ???? ?????. ??? ?? ??? ???? ??? ???? ?? ???? ????? ?? ???? ??? ? ????? ?? ??? null? ??? ??? ???? ???.

??????? ?????.

php artisan make:migration add_socialite_fields_to_users

config/services.php?? ??? ?? ?? ?? ?? ??? ?????. ?? ???? ??? Socialite ??? ??? ?? ??? ?? ? ????.

<?php
// database/migrations/2024_12_31_075619_add_socialite_fields_to_users.php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::table('users', function (Blueprint $table) {
            $table->string('google_id')->default('');
            $table->string('google_token')->default('');
            $table->string('google_refresh_token')->default('');

            // If your app allows both password and social logins, you
            // MUST validate that the password is not blank during login.
            // If you do not, an attacker could gain access to an account
            // that uses social login by only knowing the email.
            $table->string('password')->nullable()->change();
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::table('users', function (Blueprint $table) {
            $table->dropColumn('google_id');
            $table->dropColumn('google_token');
            $table->dropColumn('google_refresh_token');
            $table->string('password')->nullable(false)->change();
        });
    }
};

'?? ??' ???? ??? Google ?? ?? ??? ???? .env? ??? ?????.

php artisan migrate

routes/web.php? ??? ?? ??? ????.

// config/services.php

'google' => [
    'client_id' => env('GOOGLE_CLIENT_ID'),
    'client_secret' => env('GOOGLE_CLIENT_SECRET'),
    'redirect' => '/auth/google/callback',
],

? ??? ? ??? ?? ??? ?????.

  • ??? ??? ???? ?? ???? ?? Google? ???????.
  • Google? ??? ?????. ? ??? ??? ? ???? ????? ????? ? ???? ????? ???????.
  • ??? ???? ???????.

????? resources/views/welcome.php? ??? ?? ????? ????.

# .env

GOOGLE_CLIENT_ID="your-google-client-id"
GOOGLE_CLIENT_SECRET="your-google-client-secret"

? ??? ???? ?? ??? ???? ?? ???? ???? ? ????.

<?php
// routes/web.php

use App\Models\User;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Route;
use Laravel\Socialite\Facades\Socialite;
use Laravel\Socialite\Two\InvalidStateException;
use Laravel\Socialite\Two\User as OAuth2User;

Route::get('/', function () {
    return view('welcome');
});

Route::get('/auth/google/redirect', function () {
    return Socialite::driver('google')->redirect();
});

Route::get('/auth/google/callback', function () {
    try {
        /** @var OAuth2User $google_user */
        $google_user = Socialite::driver('google')->user();
    } catch (InvalidStateException $exception) {
        abort(400, $exception->getMessage());
    }

    $user = User::updateOrCreate([
        'email' => $google_user->email,
    ], [
        'google_id' => $google_user->id,
        'name' => $google_user->name,
        'google_token' => $google_user->token,
        'google_refresh_token' => $google_user->refreshToken,
    ]);

    Auth::login($user);
    return redirect('/');
});

Route::get('/auth/logout', function () {
    Auth::logout();
    return redirect('/');
});

Google? ??? ??? ???? OAuth2 ??? ?? Google?? ?? ??? ???? ?? ??? ? ? ?? ????? ???????.

???? ??? ?? ?????

?? ???? ????? ???? ??? ? ??? ???? ??? ???? ?? ???? ???? ????.

?? ???? ??? ??? ??? ??? ? ????.

<!-- resources/views/welcome.php -->
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Laravel Socialite Testing Example</title>
</head>
<body>
    <h1>Laravel Socialite Testing Example</h1>
    @if (auth()->check())
        <p>User is authenticated.</p>
        <p>Name: {{ auth()->user()->name }}</p>
        <p>Email: {{ auth()->user()->email }}</p>
        <p><a href="/auth/logout">Logout</a></p>
    @else
        <p>User is not authenticated.</p>
        <p>
            <a href="/auth/google/redirect">Login with Google</a>
        </p>
    @endif
</body>
</html>

?? ??? ???/Feature/AuthRoutesTest.php? ??? ???? ????.

php artisan serve

??? ?? ??

???? ??? ???? ? Socialite? ??? URL? ?????? ??? URL ????? ????? ??????.

?? ??? ???? ? Socialite? ?????. ??? ?? ?? ???? ??? ????. ???? ????? Socialite? ?? OAuth2 ???? ??? ? ??? ???? ??? ??? ????. ??? Socialite? ??? ??? ???? ?? ??? ?? ?? ??? ???? ??? ??? ????. ??? ??? ??? ?????? ????? ?? ???? ?? ?????.

Fluent API? Mockery? ?? ????? ?????. ?? ???? ???? ??? ???? ???.

?? ?????? ???? Socialite ???? ??? ????.

laravel new socialite-tests

Mockery? ?? ?? ???? ??? ??? ????.

 ┌ Would you like to install a starter kit? ────────────────────┐
 │ No starter kit                                               │
 └──────────────────────────────────────────────────────────────┘

 ┌ Which testing framework do you prefer? ──────────────────────┐
 │ Pest                                                         │
 └──────────────────────────────────────────────────────────────┘

 ┌ Which database will your application use? ───────────────────┐
 │ SQLite                                                       │
 └──────────────────────────────────────────────────────────────┘

 ┌ Would you like to run the default database migrations? ──────┐
 │ Yes                                                          │
 └──────────────────────────────────────────────────────────────┘

????? OAuth ?? ??? ?? URL? ?? ???? 400 ?? ??? ????? ???? ???? ????. try/catch ?? ?? ?? ??????? Socialite::driver('google')->user()? ?? ??? ??????. Socialite ??? try/catch ???? ???? ??? ??? ????? ?? URL? ??? ?? ?????? HTTP 500 ?? ??? ?? ??? ??????. ??? 500?? ?? ??? ?? ????? ??? ?? ??? ???? ??? ?? ? ????.

???

??? ???? ???? ??? ? ?? ?? ?? ? ????. ???? ???? ??? ? ?? ?? ????? ??? ???? ?? ? ??? ??? ??? ????? ???? ????. ???? ? ??? ??? ??? ??? ? ?? ???? ?? ??? ? ??? ???? ????. ??? ?? Socialite? ????? ??? ??????? ??? ????? ?? ???? ???? ?? ??? ???? ??? ? ????.

?? Socialite? ?? ?? ??? ??? ?? ???? ?? ?? ?? ??? ???? ??, ????? ??, ???? ? ??? ??????. ???? ? ? ??? ???? ????.

  • Stefan Zweifel? Laravel Socialite ?? ?? ?? ?? ??? ?? ??
  • ServerSideUp ??: Socialite ?? ??, ??
  • ?? ????: Laravel Socialite ??? ??
  • ?? ??: ?? ???? ???? ???? ????? ???? ????
  • Stack Exchange: ??? ?? ?? ? ???? ?? ??

? ??? ???? ??? ?????. ??, ?? ?? ??? ??, ???? ??? ?? ?? ?? ?? ?? ?? ?? ??? ?? ??? ???? ? ???? 2??? ??? ???? ????? ????.

? ??? Laravel?? Socialite ?? ?? ? ???? ?? ?????. ??? ??? PHP ??? ????? ?? ?? ??? ?????!

? ????? ??
? ?? ??? ????? ???? ??? ??????, ???? ?????? ????. ? ???? ?? ???? ?? ??? ?? ????. ???? ??? ???? ???? ??? ?? admin@php.cn?? ?????.

? AI ??

Undresser.AI Undress

Undresser.AI Undress

???? ?? ??? ??? ?? AI ?? ?

AI Clothes Remover

AI Clothes Remover

???? ?? ???? ??? AI ?????.

Video Face Swap

Video Face Swap

??? ??? AI ?? ?? ??? ???? ?? ???? ??? ?? ????!

???

??? ??

???++7.3.1

???++7.3.1

???? ?? ?? ?? ???

SublimeText3 ??? ??

SublimeText3 ??? ??

??? ??, ???? ?? ????.

???? 13.0.1 ???

???? 13.0.1 ???

??? PHP ?? ?? ??

???? CS6

???? CS6

??? ? ?? ??

SublimeText3 Mac ??

SublimeText3 Mac ??

? ??? ?? ?? ?????(SublimeText3)

???

??? ??

?? ????
1784
16
Cakephp ????
1729
56
??? ????
1580
28
PHP ????
1445
31
???
PHP?? ?? ? ??? ????? ????????? PHP?? ?? ? ??? ????? ????????? Jun 20, 2025 am 01:03 AM

TOSECURELYHANDLEAUSTENCENDACTIONANDACTERIZINGINPHP, FORCUCTSESTEPS : 1. ALWAYSHASHPASSWORTHPASSWORD_HASH () ? VERVERIFYUSINGPANSWORD_VERIFY (), usePREPAREDSTATEMENTSTOPREVENTSQLINGERGED, andSTOREUSERSESSEATAIN $ _SESSIONSAFTERLOGIN.2.impleplempletrole ?? ACCESSC

PHP?? ?? ???? ??? ??? ?? ? ? ??????? PHP?? ?? ???? ??? ??? ?? ? ? ??????? Jun 19, 2025 am 01:05 AM

PHP?? ?? ???? ???? ????? ??? ?? ??? ???? ?? ??? ??? ??? ???? ????. 1. finfo_file ()? ???? ?? ?? ??? ???? ???/jpeg? ?? ?? ?? ? ?????. 2. uniqid ()? ???? ??? ?? ??? ???? ? Web ?? ????? ??????. 3. php.ini ? html ??? ?? ?? ??? ???? ???? ??? 0755? ?????. 4. Clamav? ???? ???? ???? ??? ??????. ??? ??? ?? ???? ????? ???? ?? ??? ????? ???? ??? ? ??? ?????.

PHP?? == (??? ??)? === (??? ??)? ???? ?????? PHP?? == (??? ??)? === (??? ??)? ???? ?????? Jun 19, 2025 am 01:07 AM

PHP?? ==? ==? ?? ???? ?? ??? ??????. == ?? ??? ?? ?? ?????. ?? ??, 5 == "5"? true? ????, ?? ??? ???? ?? ?? ??? ????? ????? (? : 5 === "5"? false? ?????. ?? ?????? ===? ? ???? ?? ?????? == ?? ??? ??? ???? ?????.

php (, -, *, /, %)?? ?? ??? ??? ?????? php (, -, *, /, %)?? ?? ??? ??? ?????? Jun 19, 2025 pm 05:13 PM

PHP?? ?? ??? ??? ???? ??? ??? ????. 1. ?? ??? ?? ? ?? ??? ??? ???? ???? ??? ? ????. ??? ??? ???? ????? ????? ???? ????. 2. ?? ?? ?? - ??, ??? ???? ?? ??? ?????. 3. ?? ???? ??? ??? ???? ??? ??? ?????. 4. Division? / ??? ???? 0?? ??? ?? ????? ??? ?? ??? ?? ? ? ????. 5. ???? ??? ???? ?? ?? ? ?? ??? ???? ? ??? ? ???, ??? ?? ? ? ??? ??? ???? ?????. ? ???? ???? ???? ??? ??? ??? ???? ?? ??? ? ??????? ????.

PHP? NOSQL ?????? (? : MongoDB, Redis)? ??? ?? ??? ? ????? PHP? NOSQL ?????? (? : MongoDB, Redis)? ??? ?? ??? ? ????? Jun 19, 2025 am 01:07 AM

?, PHP? ?? ?? ?? ?????? ?? MongoDB ? Redis? ?? NOSQL ??????? ?? ??? ? ????. ?? MongoDBPHP ???? (PECL ?? Composer? ?? ??)? ???? ????? ????? ??? ?????? ? ???? ????? ??, ??, ?? ? ?? ??? ?????. ??, Predis ????? ?? Phpredis ??? ???? Redis? ???? ?? ? ?? ? ??? ???? ??? ????? Phpredis? ???? ?? Predis? ?? ??? ?????. ? ? ?? ??? ???? ? ????? ????.

?? PHP ?? ? ?? ??? ??? ?? ??? ?????? ?? PHP ?? ? ?? ??? ??? ?? ??? ?????? Jun 23, 2025 am 12:56 AM

tostaycurrentwithphpdevelopments ? bestpractices, followkeynewssources lifephp.netandphpweekly, adgytwithcommunitiesonforumsandconferences, readlingupdated andgrad indewfeatures, andreadorcontributetoopensourceproceprosts.first

PHP ? ???? ? ??? ? ?????? PHP ? ???? ? ??? ? ?????? Jun 23, 2025 am 12:55 AM

phpbecamepupularforwebdevelopmentduetoiteofleneflening, whithhtml, wididepreadhostingsupport, andalargeecosystemincludingframeworkslikelaravelandcmsplatformsformslikewordpress.itexcelsinhandlingformsubmissions, managingussess, interptisussivers, ?? ???

PHP ???? ???? ??? PHP ???? ???? ??? Jun 25, 2025 am 01:00 AM

TOSETTHERIGHTTIMEZONEINPHP, usedate_default_timezone_set () functionattStartOfyourscriptwitHavalidInlifiersuchas'America/new_york'.1.edate_default_timezone_set () beforeanydate/timeFunctions.2

See all articles