<?php
/**
 * @brief		SSO Extension
 * @author		<a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
 * @copyright	(c) Invision Power Services, Inc.
 * @license		https://www.invisioncommunity.com/legal/standards/
{subpackage}
 * @since		{date}
 */

namespace IPS\{app}\extensions\core\SSO;

/* To prevent PHP errors (extending class does not exist) revealing path */

use IPS\Extensions\SSOAbstract;
use IPS\Session\Front;
use IPS\Http\Url;
use function defined;

if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
	header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
	exit;
}

/**
 * SSO Extension
 */
class {class} extends SSOAbstract
{	
	/**
	 * Determine if the extension is currently enabled
	 *
	 * @return bool
	 */
	public function isEnabled(): bool
	{
		return true;
	}

	/**
	 * Returns an array of setting keys that will be overridden by this extension
	 * Example: post_before_registering might always return a value of 0
	 * Would return an array like [ 'post_before_registering' => 0 ]
	 *
	 * @return array
	 */
	public function overrideSettings(): array
	{
		return [];
	}

	/**
	 * Return URL guest should be redirected to for login
	 *
	 * @return Url|null
	 */
	public function loginUrl(): Url|null
	{
		return NULL;
	}

	/**
	 * Return URL guest should be redirect to for login
	 *
	 * @param Url $redirectUrl
	 * @return Url|null
	 */
	public function logoutUrl( Url $redirectUrl ): Url|null
	{
		return NULL;
	}

	/**
	 * Return URL user should visit to change display name
	 *
	 * @return Url|null
	 */
	public function displayNameChange(): Url|null
	{
		return NULL;
	}

	/**
	 * Custom logic executed on session init
	 *
	 * @param Front $session
	 * @return void
	 */
	public function onSessionInit( Front $session ): void
	{

	}

	/**
	 * Custom logic executed on session read
	 *
	 * @param Front $session
	 * @param string $result 	Initial result from the Session::read method
	 * @return string
	 */
	public function onSessionRead( Front $session, string $result ): string
	{
	    return '';
	}

	/**
	 * Does SSO support login as?
	 *
	 * @return bool
	 */
	public function supportsLoginAs(): bool
	{
		return FALSE;
	}
}