Load site settings from dotenv and store OAuth credentials
This commit is contained in:
@@ -4,6 +4,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace App\Content;
|
||||
|
||||
use App\Config\Environment;
|
||||
use App\Http\VisitorSession;
|
||||
use support\Response;
|
||||
|
||||
@@ -19,13 +20,14 @@ final class View
|
||||
$data['header'] = DesignLibrary::layout('header', $data['site'], $page);
|
||||
$data['footer'] = DesignLibrary::layout('footer', $data['site'], $page);
|
||||
$data['visitor'] = null;
|
||||
$provider = $data['header']['payload']['provider'];
|
||||
$personalized = $provider !== [] && in_array('account', $data['header']['payload']['components'], true)
|
||||
$identity = DesignLibrary::identity($data['header']);
|
||||
$data['member'] = $identity !== null;
|
||||
$personalized = $data['member']
|
||||
&& ($page['visibility']['header'] ?? true) && empty($data['previewMode']);
|
||||
if ($personalized) {
|
||||
$profile = VisitorSession::profile(request());
|
||||
if (($profile['layout'] ?? null) === $data['header']['id']
|
||||
&& ($profile['config'] ?? null) === hash('sha256', json_encode($provider, JSON_THROW_ON_ERROR))) {
|
||||
&& ($profile['config'] ?? null) === $identity) {
|
||||
$data['visitor'] = $profile;
|
||||
}
|
||||
}
|
||||
@@ -79,7 +81,7 @@ final class View
|
||||
|
||||
public static function absolute(string $path): string
|
||||
{
|
||||
return rtrim(getenv('LAYSITE_SITE_URL') ?: 'http://127.0.0.1:8787', '/') . $path;
|
||||
return rtrim(Environment::get('LAYSITE_SITE_URL') ?: 'http://127.0.0.1:8787', '/') . $path;
|
||||
}
|
||||
|
||||
public static function date(?string $value, string $format = 'Y年n月j日'): string
|
||||
|
||||
Reference in New Issue
Block a user