K
K
kupurim2018-09-11 13:30:06
Laravel
kupurim, 2018-09-11 13:30:06

How to correctly connect authorization with laravel to the forum?

Hello.
There is a site on laravel, a forum on XenForo 2 is uploaded to it in the public folder.
I decided to do authorization and registration through the forum, and then it started running.
The bottom line is that an authorized user on the forum can be obtained as follows, and I added what would authorize him on the site itself:

if( Auth::check() == null ) {
    require ( public_path() .'/forum/src/XF.php');
    \XF::start('/hc');
    $app = \XF::setupApp('XF\Pub\App');
    $s = $app->session();
    $uid = $s->get('userId');

    if ($uid){
        $finder = \XF::finder('XF:User');
        $user = $finder->where('user_id', $uid)->fetchOne();
        $find_user = User::find($user->user_id);
        if($find_user) {
            Auth::loginUsingId($find_user->user_id);
        }
    }
}

That there is a connection of the forum engine file through the request is sad, and how to make this code be on the entire site? Do it through middleware?
Please suggest how it will be better

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry, 2018-09-11
@kupurim

These things are usually called Auth Bridge
Try XenforoBridge

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question