The issue
Trying to integrate Flarum SSO with an installation of Devdojo Wave which uses Devdojo Auth for all authentication functions. I'm not sure exactly where to run the flarum commands that the sso extension (by maicol07) requires. My initial attempt used the even listeners to run the login/registration commands when users either login/register but i can't seem to get it to work. I'm not getting the flarum_token that is supposed to be created when this happens. this is the listener i have with the functions i believe are required:
<?php
namespace App\Listeners;
use Illuminate\Auth\Events\Registered;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Queue\InteractsWithQueue;
use Maicol07\SSO\Flarum;
use App\Models\User;
class UserRegistered
{
/**
* Create the event listener.
*/
public function __construct()
{
//
}
/**
* Handle the event.
*/
public function handle(Registered $event): void
{
$user = $event->user;
$options = [
'url' => env('FLARUM_URL'),
'api_key' => env('FLARUM_API_KEY'),
'password_token' => env('FLARUM_PASSWORD_TOKEN'),
];
$flarum = new Flarum($options);
$flarum_user = $flarum->user($user->username);
$flarum_user->attributes->email = $user->email;
$flarum_user->attributes->password = $user->password;
$flarum_user->register();
catch (\Exception $e) {
// Handle any registration errors
report($e);
}
}
}