Jump to content

Invision Community & Laravel


Go to solution Solved by Askancy,

Recommended Posts

Hello everyone,

I come to you because I have a question concerning my integration.

I have User Control Panel made with Laravel (mydomain.com)
And Invision Community as Forum (forum.mydomain.com).

What I would like to accomplish :

  • If the user is not logged in, he's redirected to the default Invision Community login handler.
  • If the user is logged in, he's also logged in on Laravel (mydomain.com) and Forum (forum.mydomain.com)
  • Have the ability to retrieve user informations (core_members) from the Laravel (username, avatar .. etc)

How can I accomplish this? (and in a secure way)

Thank you ! :)

Link to comment
Share on other sites

I for my project with Laravel 9 decided to use the user management of IP.Board, the user logs in from the forum and has full access also to the portal in Laravel, like commenting articles.

To make Laravel communicate with IP.Board just call the file init.php in AppServiceProvider.php

class AppServiceProvider extends ServiceProvider
{

    public function register() {
        //
    }

    public function boot()
    {
 
        $path	= base_path('../forum.***.ext/');
        require_once $path . 'init.php';

        view()->composer('*', function ($view) {
          \IPS\Session\Front::i();
        });

To get user data on a laravel blade I use:

{{\IPS\Member::loggedIn()->name}}

I hope this can be a starting point to help you develop what you want.

Link to comment
Share on other sites

12 hours ago, Askancy said:

I for my project with Laravel 9 decided to use the user management of IP.Board, the user logs in from the forum and has full access also to the portal in Laravel, like commenting articles.

To make Laravel communicate with IP.Board just call the file init.php in AppServiceProvider.php

class AppServiceProvider extends ServiceProvider
{

    public function register() {
        //
    }

    public function boot()
    {
 
        $path	= base_path('../forum.***.ext/');
        require_once $path . 'init.php';

        view()->composer('*', function ($view) {
          \IPS\Session\Front::i();
        });

To get user data on a laravel blade I use:

{{\IPS\Member::loggedIn()->name}}

I hope this can be a starting point to help you develop what you want.

Hi, thank you for your reply.

I have already tested this solution :

public function boot()
{
    $path = base_path('../forum.vice/');
    require_once $path . 'init.php';

    view()->composer('*', function ($view) {
      \IPS\Session\Front::i();
    });
}

I'm logged in the forum but in Laravel blade I got token like "4d99edd69d5019629c6a37e13382fd0e" when I call :

{{\IPS\Member::loggedIn()->name}}

Do I have to do anything else ? About session or cookie domain ?

Thank you 🙂

Link to comment
Share on other sites

6 minutes ago, Daniel F said:

1. Keep in mind that Laravel won't take care of the proper output, so language string keys will be returned as hashes.

4d99edd69d5019629c6a37e13382fd0e is probably the hash for "Guest".

 

Yeah but it's the same in the AppServiceProvider like :

dd(\IPS\Member::loggedIn()->name);
Link to comment
Share on other sites

  • Solution
2 hours ago, Salim Trouve said:

I'm logged in the forum but in Laravel blade I got token like "4d99edd69d5019629c6a37e13382fd0e" when I call

As Daniel said, that hash indicates that the user is not logged in. Check cookies if the cookie is saved correctly.

I did the integration years ago so I don't remember precisely, but you will see on the IP.Board constants.php file you have to indicate the Cookie Domain and the path, here is my configuration:

\define( 'COOKIE_DOMAIN', 'MainDomin.ext' );
\define( 'COOKIE_PATH', '/' );

Because otherwise IP.Board cookies will be only for the subdomain

Link to comment
Share on other sites

  • 1 year later...

Just a quick note, all these years later. I've just tried the above on our servers with PHP 8.3 & Laravel 10 and it works perfectly, the only real difference is I used a Facade and also typed the $view variable passed to the view composer, not that it's used.

 

<?php

namespace App\Providers;

use Illuminate\Support\Facades;
use Illuminate\Support\ServiceProvider;
use Illuminate\View\View;

class AppServiceProvider extends ServiceProvider
{
    /**
     * Register any application services.
     */
    public function register(): void
    {
        //
    }

    /**
     * Bootstrap any application services.
     */
    public function boot(): void
    {
        require_once(base_path('../') . '/init.php');

        Facades\View::Composer('*', function (View $view) {
            \IPS\Session\Front::i();
        });
    }
}

 

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...