• Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Register
  • Login
Bagisto Forum

Bagisto

  • Register
  • Login
  • Search
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups

How to add a login button(sign in with google) on Bagisto(velocity theme).

Knowledge Base
2
2
203
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P
    prashant2408 last edited by 22 Jun 2020, 13:42

    I had done these things

    1. Obtain these credentials form google and add these to .env.
    GOOGLE_CLIENT_ID 
    GOOGLE_CLIENT_SECRET 
    GOOGLE_REDIRECT 
    
    1. Add routes in web.php
    Route::get('/redirect','Auth\LoginController@google');
    Route::get('/callback','Auth\LoginController@googleRedirect');
    

    3.Add a controller in LoginController.php

    use Hash;
    use Laravel\Socialite\Facades\Socialite;
    use Illuminate\Support\Str;
    use App\User;
    
    //Send the user request to google
    public function google(){
            return Socialite::driver('google')->redirect();
    }
    
    //get the auth request from the google to authenticate 
    public function goo gleRedirect(){
        $user = Socialite::driver('google')->stateless()->user();
    
        $user = User::firstOrCreate([
            'email' => $user->email
        ], [
            'name' =>  $user->name,
            'password' => Hash::make(Str::random(24))
        ]);
        Auth::login($user, true);
        return redirect('/dashboard'); 
    }
    

    I cant able to understand how to add UI button(login with google) and redirect it to

    /redirect
    
    1 Reply Last reply Reply Quote 0
    • shubhwebkul
      shubhwebkul last edited by 24 Jun 2020, 12:56

      Hey Prashant,

      I really appreciate your efforts, you could add your options here.

      Let me know if you have any further query.

      Thanks!

      1 Reply Last reply Reply Quote 0
      1 out of 2
      • First post
        1/2
        Last post