Jump to content

Featured Replies

Posted

I have code sso.php in the following folder structure
/forum/applications/core/modules/front/custom

https://localhost:8890/forum/index.php?app=core&module=custom&controller=sso

Friendly urls are not enabled, but when I go to this page, it says "The page you requested does not exist". Basically what am I doing wrong, why can't I get to this page. I am using MAMP Pro locally. I have cleared cache, dev mode is on (also tried with it off), restarted MAMP many times. What am I missing? Any help would be appreciated. I am a beginner level PHP dev, so wouldn't be surprised that I am messing this up.

Using : Version 4.7.20
PHP: 8.1.31
MySQL 8.0.40

<?php

namespace IPS\core\modules\front\custom;

class _sso extends \IPS\Dispatcher\Controller

{

public $secretKey = 'XXX';

public function execute()

{

\IPS\Output::i()->json(['debug' => 'SSO module reached']);

return;

// Comment out the rest for now

/*

$request = \IPS\Request::i();

if (!$request || !isset($request->key) || $request->key !== $this->secretKey) {

\IPS\Output::i()->json(['error' => 'Invalid access'], 403);

return;

}

parent::execute();

*/

}

protected function manage()

{

$member = \IPS\Member::loggedIn();

if (!$member->member_id) {

\IPS\Output::i()->json(['logged_in' => false]);

return;

}

$data = [

'logged_in' => true,

'member_id' => $member->member_id,

'username' => $member->name,

'email' => $member->email,

'first_name' => $member->real_name ? explode(' ', $member->real_name)[0] : '',

'last_name' => $member->real_name ? end(explode(' ', $member->real_name)) : '',

'avatar' => (string)$member->get_photo(),

'joined' => $member->joined->getTimestamp(),

'group_id' => $member->member_group_id,

'posts' => $member->member_posts

];

\IPS\Output::i()->json($data);

}

protected function logout()

{

$member = \IPS\Member::loggedIn();

if ($member->member_id) {

\IPS\Session\Front::i()->logOut();

\IPS\Output::i()->json(['success' => true, 'message' => 'Logged out from IPB']);

} else {

\IPS\Output::i()->json(['success' => true, 'message' => 'No active session']);

}

}

public function __call($method, $args)

{

if ($method === 'logout') {

$this->logout();

} else {

$this->manage();

}

}

}

Edited by JEFF MACK

  • Community Expert

I guess because the module doesn’t exist, that said, you really shouldn’t put your custom code into the core application , why aren’t you creating your own application with its own modules and controllers ?

Recently Browsing 0

  • No registered users viewing this page.