How do I verify if someone is a facebook user - laravel

I'm building a laravel app that is using a admin user registration approval system. Once an admin approves the registration, I'd like the users to verify on their profile page that they are members of facebook and linkedin. I see a bunch of stuff about user creation and login, but not about verification. Can someone please point me in the right direction?

If you are familiar with Laravel Socialite, this can be achieved...
Once your users are logged in and approved by admin, you could add a facebook button to use the Socialite login functionality, but with some custom work.
In SocialAuthController.php
Find the handleFacebookCallback method
In my example i have the method named as handleProvider, but it works just the same
public function handleProviderCallback($provider)
{
// First we are going to get the user data from facebook
$social_user = Socialite::driver($provider)->fields([
'name', 'email'
])->user();
//Now we make the logic
if (Auth::check()) { //if the user is logged in
$userID = Auth::user()->id; //then we get the user ID
$user = User::where('id', $userID)->first(); //Prepare the model for update
//And finally we just start to update each field in DB (you need to create this fields)
$user->fb_email = $social_user->email;
$user->avatar = $social_user->avatar;
$user->fb_id = $social_user->id;
$user->save();
return $this->authAndRedirect($user); // This is to redirect the user
}
}
With this you can make the users link their accounts in your app with facebook...
But keep in mind that also you'll need to handle with the else, the rest of the code for creating a new account if you are going to allow users to register with facebook. Otherwise, you only need to add the facebook button in the profile page of your users to link with their respective fb account.
The button can be like this:
<i class="fa fa-facebook-square"></i>
also you would need to configure socialite as and be familiar with this first.

Related

Cannot get user to select account before login using facebook socialite

I'm using socialite for facebook login but the issue is if i'm already login in facebook account then before login it should force user to select pop up this code is working for google login but i want it in facebook login also which is not working.
public function facebookRedirect()
{
return Socialite::driver('facebook')->with(["prompt" => "select_account"])->redirect();
}
Any suggestions. Thanks

Laravel's Authentication

I have an account called users. When a user logs in they view information specific to them. When another user logs in they view the other users information. What do I need to do to ensure logged in users only view their information only?
You can use $user = $request->user(); to get the user and return it as a variable with the view for the profile page. Then you can use the user variable to get the rest of the user's data.

check if user likes a page with Laravel Socialite

I'm using Laravel Socialite to make users log in to my site. I've managed to do that and store the user's data.
But now i want to find out how i can check if that particular user (when logged in) has liked my facebook page.
Thank you so much!
Socialite is a package that handles authentication using Facebook, Twitter, LinkedIn, Google, GitHub and Bitbucket. It does not have the ability to retrieve information regarding user likes.
You can use the facebook-php-sdk inorder to get the pages that user has liked. The code below is from the facebook graph api documentation on how to get the pages that the user has liked.
/* PHP SDK v5.0.0 */
/* make the API call */
$request = new FacebookRequest(
$session,
'GET',
'/{user-id}/likes'
);
$response = $request->execute();
$graphObject = $response->getGraphObject();
/* handle the result */

Joomla login component with JFactory::getUser

I have component that have his own table with users and when user login, JFactory::getUser didn't work. How Joomla can understand that user is login? in my model it is $this->setStatus('loggedIn',true); Can someone just help me with direction, what I need to write when user login
You should be able to do this
$user =& JFactory::getUser();
if($user->id){
//User is logged in
}
else{
//User not logged in
}
If that is what you are asking. If not, please provide more info

Joomla 2.5 password reset user sync

We have a Joomla 2.5 website and a second site (non-Joomla) that needs to have user information synchronized. We already have implemented a user registration that syncs to the other system after the email verification link is clicked.
The issue I have now is password reset. Joomla has a nice system to allow a user to reset the password. What I need to know is once the user clicks on the email to start the reset process (reset.php), how can I grab the user information within the confirm() method? All I need is the user (email or id) so that I can pass the new encrypted password to the other system.
Any suggestions would be VERY helpful.
In file components\com_users\models\reset.php, within function processResetConfirm() around line 227, the userid is available in $user->id.
// Get the user id.
$db->setQuery((string) $query);
$user = $db->loadObject();
The userid should now be found int $user->id

Resources