![]() ![]() Then we need to add provider and provider_id since we are using multiple providers. Hence, as a prevention to get any rogue errors, what one can do is make fields like ‘email’ (which some providers may not give) and things like ‘password’ (which we are not passing) nullable during the migration itself. One note of caution though over here, since we are dealing with how to get multiple social network sign-ups, there might be a possibility of necessary data not getting returned as that might not be a compulsory field for that particular social network or due to some other reason. However, if you plan to go about your own, here is a sneak peak!įirst you need to get your database ready! So you should set up a ‘users’ and a ‘password’ reset table. The best way would be to contact us and Hire the best Laravel PHP Developers in India from one of the Top Laravel PHP Development Company in India! What if I tell you that you don’t need to go to each and every famous social networking website, integrate individually and then troubleshoot and configure? What if I tell you that there is a simple and effective way to authenticate with OAuth providers? No More What ifs, there is a way and that is Laravel Socialite.Ĭurrently supporting Facebook, Twitter, Google, GitHub and Bitbucket, Laravel Socialite is the lean way of integrating social sign-up on your website, one more reason to use Laravel! How to do that? Not that it’s impossible, but it’s time-consuming and as a developer the most important thing you have is time! (that is why you have an ‘hourly’ rate). If you are logged into Facebook in your browser then the sign-up is literally two clicks away!īut to do that you have to go and read documentation of each social networking website, follow the instructions, stick to specified format, etc. This way you are saved the hassle of entering all information again for each website. ![]() ![]() Social Sign-up basically uses the data that you have provided to social networks like Facebook or Twitter in order to make you sign-up on some other website. Customers want to go to the next steps with as less effort as possible and that is how Social Sign-up came into the picture. Typical form based authentication is now a thing of the past. So onboarding a customer for the first time on the website should be seamless and smooth. In my database migration, I have users and social_accounts and user have one to many relationship with social_accounts.Ease for the customer is one principle that everyone strives towards. $user = User::where('email', $socialUser->getEmail())->first() $account = SocialAccount::where('provider_name', $provider)->where('provider_id',$socialUser->getId())->first() Public function findOrCreateUser($socialUser, $provider) This is a normal protected function that you can add in your users table to redirect a user wherever redirectTo, so that way we use the same redirect location that the rest of our authentication uses. $authUser = $this->findOrCreateUser($user, $provider) $user = Socialite::driver($provider)->user() In my SocialAccountControll, I have the following method public function handleProviderCallback($provider) Can anyone provide me solution that where I am wrong. When I try to authenticate the user with using facebook so I am able to store data into the user table but the failure to create data into the soical_accounts.So after that errors with come up "call to a member funtion create() on null". ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |