shinhyungjune/social-login

1.0.0 2021-09-15 05:37 UTC

This package is auto-updated.

Last update: 2024-04-21 19:18:44 UTC


README

Latest Version on Packagist Total Downloads GitHub Actions

This is where your description should go. Try and limit it to a paragraph or two, and maybe throw in a mention of what PSRs you support to avoid any confusion with users and contributors.

Requirements

Installation

You can install the package via composer:

composer require shinhyungjune/social-login
php artisan vendor:publish

Usage

// Usage description here

@web.php

Route::get("/", function(){
    return \Inertia\Inertia::render("Home");
});
Route::get("/home", function(){
    return \Inertia\Inertia::render("Home");
});

Route::middleware("guest")->group(function(){
    Route::get("/openLoginPop/{social}", [\ShinHyungJune\SocialLogin\Http\UserController::class, "openSocialLoginPop"]);
    Route::get("/login", [\ShinHyungJune\SocialLogin\Http\UserController::class, "index"])->name("login");
    Route::get("/login/{social}", [\ShinHyungJune\SocialLogin\Http\UserController::class, "socialLogin"]);
    Route::post("/login", [\ShinHyungJune\SocialLogin\Http\UserController::class, "login"]);
    Route::resource("/users", \ShinHyungJune\SocialLogin\Http\UserController::class);
    Route::get("/passwordResets/{token}/edit", [\ShinHyungJune\SocialLogin\Http\PasswordResetController::class, "edit"]);
    Route::resource("/passwordResets", \ShinHyungJune\SocialLogin\Http\PasswordResetController::class);
});

Route::middleware("auth")->group(function(){
    Route::get("/logout", [\ShinHyungJune\SocialLogin\Http\UserController::class, "logout"]);
});

Route::get("/mailable", function(){
    return (new \App\Mail\PasswordResetCreated(new \App\Models\User(), new \App\Models\PasswordReset()));
});

@.env(카카오는 secret key가 따로 없어서 입력 안해도됨)

KAKAO_CLIENT_ID=
KAKAO_CLIENT_SECRET=
KAKAO_REDIRECT_URI={your_url}/login/kakao

NAVER_CLIENT_ID=
NAVER_CLIENT_SECRET=
NAVER_REDIRECT_URI={your_url}/login/naver

GOOGLE_CLIENT_ID=
GOOGLE_CLIENT_SECRET=
GOOGLE_REDIRECT_URI={your_url}/login/google

FACEBOOK_CLIENT_ID=
FACEBOOK_CLIENT_SECRET=
FACEBOOK_REDIRECT_URI={your_url}/login/facebook

@EventServiceProvider

protected $listen = [
    \SocialiteProviders\Manager\SocialiteWasCalled::class => [
        // ... other providers
        'SocialiteProviders\\Naver\\NaverExtendSocialite@handle',
        'SocialiteProviders\\Kakao\\KakaoExtendSocialite@handle',
        'SocialiteProviders\\Facebook\\FacebookExtendSocialite@handle',
        'SocialiteProviders\\Google\\GoogleExtendSocialite@handle',
    ],
];

@services.php

'naver' => [
  'client_id' => env('NAVER_CLIENT_ID'),  
  'client_secret' => env('NAVER_CLIENT_SECRET'),  
  'redirect' => env('NAVER_REDIRECT_URI') 
],

'kakao' => [    
  'client_id' => env('KAKAO_CLIENT_ID'),  
  'client_secret' => env('KAKAO_CLIENT_SECRET'),  
  'redirect' => env('KAKAO_REDIRECT_URI') 
],

'google' => [    
  'client_id' => env('GOOGLE_CLIENT_ID'),  
  'client_secret' => env('GOOGLE_CLIENT_SECRET'),  
  'redirect' => env('GOOGLE_REDIRECT_URI') 
],

'facebook' => [    
  'client_id' => env('FACEBOOK_CLIENT_ID'),  
  'client_secret' => env('FACEBOOK_CLIENT_SECRET'),  
  'redirect' => env('FACEBOOK_REDIRECT_URI') 
],

@User.php

protected $fillable = [
        ...
        "social_id",
        "social_platform"
    ];

Testing

composer test

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email ssa4141@naver.com instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

Laravel Package Boilerplate

This package was generated using the Laravel Package Boilerplate.