Laravel + rocketchat

Hi,
I want to log in from laravel app into rocket chat. As I have no idea what I am doing came here to ask.

So far I use noisim/rocket-chat package for laravel to play with rocketchat rest api.

Result is this, but I am stuck for now. Help please :slight_smile:

Edit: Can this be used with laravel?

Btw, I enabled Iframe option so my login now does not show.

Update:
Looking into example iframe auth I made some little progress. That is, I have this code and result.

Routes:

Route::get('loginrc', 'LoginController@loginrc');
Route::post('sso', 'UserController@sso');

loginrc View:

@extends('layouts.app')
@section('content')
@if(!empty($rcuser_id))

<script>
			window.parent.postMessage({
				event: 'login-with-token',
				loginToken: '{{ $rcuser_authToken }}'
			}, 'http://localhost:3000'); // rocket.chat's URL
</script>
@endif
<form method="post" action="sso">
@csrf
<input type="text" name="username" />
<input type="password" name="password" />
<input type="submit" value="submit" />
</form>
@endsection 

Controller

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

class LoginController extends Controller
{
    public function loginrc()
    {
	    return view('loginrc');
    }
}

User Controller

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Noisim\RocketChat\Facades\User as RCUser;

class UserController extends Controller
{
    public function sso(Request $request)
    {
	    $rcuser = new RCUser;
	    $rcuser = RCUser::setUsername($request->username);
	    $rcuser = RCUser::setPassword($request->password);
	    $rcuser->login();
   	    $rcuser_id = $rcuser->id();
    $rcuser_authToken = $rcuser->authToken();

    return view('loginrc')->with('rcuser_id', $rcuser_id)->with('rcuser_authToken', $rcuser_authToken);
	
	
    }
}

If you still need assistance with this change JS to:
window.parent.postMessage({
externalCommand: โ€˜login-with-tokenโ€™,
token: โ€˜{{ $rcuser_authToken }}โ€™
}, โ€˜*โ€™);
and test if it works (works for me at least!).
If it does not log you try to wrap it into a window.setTimeout() withl ike 3 seconds as the chat needs firstly to load. You can try to add preloading etc for it in head.