Joomla login component with JFactory::getUser - joomla

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

Related

Access ForgotPasswordController when authorized

I am not very good at English so not sure if I can explain my status correctly.
Currently, I am building admin panel which allow users to reset their password. So in the admin panel, I select user and click 'reset password' button. Then, resetPassword notification email will be sent to specific users(by email).
I am trying to do this with ForgorPasswordController's sendResetLinkEmail function but it seems I can't access their once authorized.
How can I solve this problem?
Thanks
You don't (and probably shouldn't) use that controller.
It will be easier to create new controller for your admin panel page and use the built in helper:
https://laravel.com/api/5.8/Illuminate/Auth/Passwords/PasswordBroker.html#method_sendResetLink
That should be available through Password facade
use use Illuminate\Support\Facades\Password;
(...)
Password::sendResetLink($emailAddress, function (Message $message) {
$message->subject('Password Reset');
});

How do I verify if someone is a facebook user

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.

jrean/laravel-user-verification not working on authenticated user

I am using jrean/laravel-user-verification on Laravel 5.6, one issue is that it doesn't verify users if the user is logged in. Only if the user is logged out does the link actually verify the user.
I can't see anything mentioned about this in the docs, and seems backwards as you can't resend verification email if the user isn't logged in either.
Any advice?
$this->middleware('guest', ['except' => ['getVerification', 'getVerificationError']]);
In construct

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.

Redirect user from login page based on the option they selected

I have an application in Laravel where I have a common login page. From this login page users will have an option to get redirected to the Admin page or App page.
How do I implement this??
Do I have to make a new login page for the admin redirect?
You can assign roles to your users and then on login check the role. And on the base of role redirect them to whatever page you want. Entrust is great plugin which really helps in role management.
After authenticating the user
if ($user->roles()->first() == 'Admin')
//redirect to your Admin page
else
//redirect to app page
There are multiple ways to redirect. Read docs

Resources