Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/App/Adapters/ConsoleAppAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* @author Arman Ag. <arman.ag@softberg.org>
* @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org)
* @link http://quantum.softberg.org/
* @since 2.9.7
* @since 2.9.9
*/

namespace Quantum\App\Adapters;
Expand Down Expand Up @@ -64,7 +64,7 @@ public function __construct()

if ($commandName !== 'core:env') {
$this->loadEnvironment();
$this->loadConfig();
$this->loadAppConfig();
}
}

Expand All @@ -81,8 +81,8 @@ public function start(): ?int
{
try {
$this->application = $this->createApplication(
config()->get('app_name', 'UNKNOWN'),
config()->get('app_version', 'UNKNOWN')
config()->get('app.name', 'UNKNOWN'),
config()->get('app.version', 'UNKNOWN')
);

$this->registerCoreCommands();
Expand Down
4 changes: 2 additions & 2 deletions src/App/Adapters/WebAppAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* @author Arman Ag. <arman.ag@softberg.org>
* @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org)
* @link http://quantum.softberg.org/
* @since 2.9.8
* @since 2.9.9
*/

namespace Quantum\App\Adapters;
Expand Down Expand Up @@ -69,7 +69,7 @@ public function __construct()
parent::__construct();

$this->loadEnvironment();
$this->loadConfig();
$this->loadAppConfig();

$this->request = Di::get(Request::class);
$this->response = Di::get(Response::class);
Expand Down
4 changes: 2 additions & 2 deletions src/App/Helpers/misc.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* @author Arman Ag. <arman.ag@softberg.org>
* @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org)
* @link http://quantum.softberg.org/
* @since 2.9.7
* @since 2.9.9
*/

use Symfony\Component\VarExporter\Exception\ExceptionInterface;
Expand Down Expand Up @@ -88,7 +88,7 @@ function slugify(string $text): string
*/
function is_debug_mode(): bool
{
return filter_var(config()->get('debug'), FILTER_VALIDATE_BOOLEAN);
return filter_var(config()->get('app.debug'), FILTER_VALIDATE_BOOLEAN);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/App/Traits/AppTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,9 @@ protected function loadEnvironment()
* @throws ReflectionException
* @throws ConfigException
*/
protected function loadConfig()
protected function loadAppConfig()
{
Config::getInstance()->load(new Setup('config', 'config'));
Config::getInstance()->import(new Setup('config', 'app'));
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/Debugger/Debugger.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* @author Arman Ag. <arman.ag@softberg.org>
* @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org)
* @link http://quantum.softberg.org/
* @since 2.9.5
* @since 2.9.9
*/

namespace Quantum\Debugger;
Expand Down Expand Up @@ -128,7 +128,7 @@ public static function getInstance(DebuggerStore $store = null, DebugBar $debugB
*/
public function isEnabled(): bool
{
return filter_var(config()->get('debug'), FILTER_VALIDATE_BOOLEAN);
return filter_var(config()->get('app.debug'), FILTER_VALIDATE_BOOLEAN);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/Http/Request/HttpRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* @author Arman Ag. <arman.ag@softberg.org>
* @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org)
* @link http://quantum.softberg.org/
* @since 2.9.8
* @since 2.9.9
*/

namespace Quantum\Http\Request;
Expand Down Expand Up @@ -210,7 +210,7 @@ public static function getCsrfToken(): ?string
*/
public static function getBaseUrl(bool $withModulePrefix = false): string
{
$baseUrl = config()->get('base_url');
$baseUrl = config()->get('app.base_url');

$prefix = route_prefix();
$modulePrefix = ($withModulePrefix && !empty($prefix)) ? '/' . $prefix : '';
Expand Down
12 changes: 6 additions & 6 deletions src/Libraries/Auth/Traits/AuthTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* @author Arman Ag. <arman.ag@softberg.org>
* @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org)
* @link http://quantum.softberg.org/
* @since 2.9.7
* @since 2.9.9
*/

namespace Quantum\Libraries\Auth\Traits;
Expand Down Expand Up @@ -249,7 +249,7 @@ protected function twoStepVerification(User $user): string

$time = new DateTime();

$time->add(new DateInterval('PT' . config()->get('otp_expires') . 'M'));
$time->add(new DateInterval('PT' . config()->get('auth.otp_expires') . 'M'));

$this->authService->update(
$this->keyFields[AuthKeys::USERNAME],
Expand Down Expand Up @@ -344,7 +344,7 @@ protected function isActivated(User $user): bool
*/
protected function generateToken(string $val = null): string
{
return base64_encode($this->hasher->hash($val ?: config()->get('app_key')));
return base64_encode($this->hasher->hash($val ?: config()->get('app.key')));
}

/**
Expand All @@ -356,8 +356,8 @@ protected function sendMail(User $user, array $body)
{
$fullName = ($user->hasField('firstname') && $user->hasField('lastname')) ? $user->getFieldValue('firstname') . ' ' . $user->getFieldValue('lastname') : '';

$appEmail = config()->get('app_email') ?: '';
$appName = config()->get('app_name') ?: '';
$appEmail = config()->get('app.email') ?: '';
$appName = config()->get('app.name') ?: '';

$this->mailer->setFrom($appEmail, $appName)
->setAddress($user->getFieldValue($this->keyFields[AuthKeys::USERNAME]), $fullName)
Expand Down Expand Up @@ -394,6 +394,6 @@ protected function verifySchema(array $schema)
*/
protected function isTwoFactorEnabled(): bool
{
return filter_var(config()->get('TWO_FA'), FILTER_VALIDATE_BOOLEAN);
return filter_var(config()->get('auth.two_fa'), FILTER_VALIDATE_BOOLEAN);
}
}
4 changes: 2 additions & 2 deletions src/Libraries/Database/Adapters/Idiorm/IdiormDbal.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* @author Arman Ag. <arman.ag@softberg.org>
* @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org)
* @link http://quantum.softberg.org/
* @since 2.9.8
* @since 2.9.9
*/

namespace Quantum\Libraries\Database\Adapters\Idiorm;
Expand Down Expand Up @@ -252,7 +252,7 @@ protected static function getBaseConfig(string $driver, array $config): array
{
return [
'connection_string' => self::buildConnectionString($driver, $config),
'logging' => config()->get('debug', false),
'logging' => config()->get('app.debug', false),
'error_mode' => PDO::ERRMODE_EXCEPTION,
];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* @author Arman Ag. <arman.ag@softberg.org>
* @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org)
* @link http://quantum.softberg.org/
* @since 2.9.7
* @since 2.9.9
*/

namespace Quantum\Libraries\Encryption\Adapters;
Expand Down Expand Up @@ -41,7 +41,7 @@ class SymmetricEncryptionAdapter implements EncryptionInterface
*/
public function __construct()
{
$appKey = config()->get('app_key');
$appKey = config()->get('app.key');

if (!$appKey) {
throw AppException::missingAppKey();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* @author Arman Ag. <arman.ag@softberg.org>
* @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org)
* @link http://quantum.softberg.org/
* @since 2.9.8
* @since 2.9.9
*/

namespace {{MODULE_NAMESPACE}}\Controllers;
Expand Down Expand Up @@ -51,7 +51,7 @@ class MainController extends RouteController
public function index(Response $response, ViewFactory $view)
{
$view->setParams([
'title' => config()->get('app_name'),
'title' => config()->get('app.name'),
]);
$response->html($view->render('index'));
Expand Down
2 changes: 1 addition & 1 deletion src/Module/Templates/DefaultWeb/src/Views/index.php.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<div class="container wrapper">
<div class="center-align white-text">
<div class="logo-block">
<img src="<?php echo base_url() ?>/assets/shared/images/quantum-logo-white.png" alt="<?php echo config()->get('app_name') ?>" />
<img src="<?php echo base_url() ?>/assets/shared/images/quantum-logo-white.png" alt="<?php echo config()->get('app.name') ?>" />
</div>
<h1> <?php echo strtoupper("{{MODULE_NAME}}") ?> HOME PAGE</h1>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* @author Arman Ag. <arman.ag@softberg.org>
* @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org)
* @link http://quantum.softberg.org/
* @since 2.9.8
* @since 2.9.9
*/

namespace {{MODULE_NAMESPACE}}\Controllers;
Expand All @@ -36,7 +36,7 @@ class AuthController extends BaseController
try {
$code = auth()->signin($request->get('email'), $request->get('password'));

if (filter_var(config()->get('TWO_FA'), FILTER_VALIDATE_BOOLEAN)) {
if (filter_var(config()->get('auth.two_fa'), FILTER_VALIDATE_BOOLEAN)) {
$response->set('code', $code);
}

Expand Down
20 changes: 19 additions & 1 deletion src/Module/Templates/DemoApi/src/config/auth.php.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,23 @@ return [
'nbf' => time() + 1,
'exp' => time() + 3600,
]
]
],

/**
* ---------------------------------------------------------
* Two-factor authentication
* ---------------------------------------------------------
*
* Enables or disables 2-factor authentication
*/
'two_fa' => env('TWO_FA', true),

/**
* ---------------------------------------------------------
* OTP expiration
* ---------------------------------------------------------
*
* OTP expires after minutes defined
*/
'otp_expires' => 2,
];
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class AccountController extends BaseController
public function form(Response $response)
{
$this->view->setParams([
'title' => t('common.account_settings') . ' | ' . config()->get('app_name'),
'title' => t('common.account_settings') . ' | ' . config()->get('app.name'),
]);

$response->html($this->view->render('account/form'));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class AuthController extends BaseController
try {
$code = auth()->signin($request->get('email'), $request->get('password'), !!$request->get('remember'));

if (filter_var(config()->get('TWO_FA'), FILTER_VALIDATE_BOOLEAN)) {
if (filter_var(config()->get('auth.two_fa'), FILTER_VALIDATE_BOOLEAN)) {
redirect(base_url(true) . '/' . current_lang() . '/verify/' . $code);
} else {
redirect(base_url(true) . '/' . current_lang());
Expand All @@ -77,7 +77,7 @@ class AuthController extends BaseController
}
} else {
$this->view->setParams([
'title' => t('common.signin') . ' | ' . config()->get('app_name'),
'title' => t('common.signin') . ' | ' . config()->get('app.name'),
]);

$response->html($this->view->render(self::VIEW_SIGNIN));
Expand Down Expand Up @@ -107,7 +107,7 @@ class AuthController extends BaseController
} else {
$this->view->setParams([
// 'captcha' => captcha(),
'title' => t('common.signup') . ' | ' . config()->get('app_name'),
'title' => t('common.signup') . ' | ' . config()->get('app.name'),
]);

$response->html($this->view->render(self::VIEW_SIGNUP));
Expand Down Expand Up @@ -137,7 +137,7 @@ class AuthController extends BaseController
redirect(base_url(true) . '/' . current_lang() . '/forget');
} else {
$this->view->setParams([
'title' => t('common.forget_password') . ' | ' . config()->get('app_name'),
'title' => t('common.forget_password') . ' | ' . config()->get('app.name'),
]);

$response->html($this->view->render(self::VIEW_FORGET));
Expand All @@ -156,7 +156,7 @@ class AuthController extends BaseController
redirect(base_url(true) . '/' . current_lang() . '/signin');
} else {
$this->view->setParams([
'title' => t('common.reset_password') . ' | ' . config()->get('app_name'),
'title' => t('common.reset_password') . ' | ' . config()->get('app.name'),
'reset_token' => $request->get('reset_token')
]);

Expand All @@ -181,7 +181,7 @@ class AuthController extends BaseController
}
} else {
$this->view->setParams([
'title' => t('common.two_fa') . ' | ' . config()->get('app_name'),
'title' => t('common.two_fa') . ' | ' . config()->get('app.name'),
'code' => route_param('code')
]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class PageController extends BaseController
public function home(Response $response)
{
$this->view->setParams([
'title' => config()->get('app_name'),
'title' => config()->get('app.name'),
]);

$response->html($this->view->render('pages/index'));
Expand All @@ -48,7 +48,7 @@ class PageController extends BaseController
public function about(Response $response)
{
$this->view->setParams([
'title' => t('common.about') . ' | ' . config()->get('app_name'),
'title' => t('common.about') . ' | ' . config()->get('app.name'),
]);

$response->html($this->view->render('pages/about'));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class PostController extends BaseController
$paginatedPosts = $this->postService->getPosts($perPage, $currentPage, $search);

$this->view->setParams([
'title' => t('common.posts') . ' | ' . config()->get('app_name'),
'title' => t('common.posts') . ' | ' . config()->get('app.name'),
'posts' => $this->postService->transformData($paginatedPosts->data()->all()),
'pagination' => $paginatedPosts
]);
Expand All @@ -96,7 +96,7 @@ class PostController extends BaseController
}

$this->view->setParams([
'title' => $post->title . ' | ' . config()->get('app_name'),
'title' => $post->title . ' | ' . config()->get('app.name'),
'post' => new RawParam(current($this->postService->transformData([$post]))),
'referer' => $ref,
]);
Expand All @@ -114,7 +114,7 @@ class PostController extends BaseController
$myPosts = $this->postService->getMyPosts(auth()->user()->uuid);

$this->view->setParams([
'title' => t('common.my_posts') . ' | ' . config()->get('app_name'),
'title' => t('common.my_posts') . ' | ' . config()->get('app.name'),
'posts' => $this->postService->transformData($myPosts->all())
]);

Expand All @@ -131,7 +131,7 @@ class PostController extends BaseController
$ref = $request->get('ref', 'posts');

$this->view->setParams([
'title' => t('common.new_post') . ' | ' . config()->get('app_name'),
'title' => t('common.new_post') . ' | ' . config()->get('app.name'),
'referer' => $ref
]);

Expand Down Expand Up @@ -181,7 +181,7 @@ class PostController extends BaseController
$post = $this->postService->getPost($postUuid);

$this->view->setParams([
'title' => $post->title . ' | ' . config()->get('app_name'),
'title' => $post->title . ' | ' . config()->get('app.name'),
'post' => $post->asArray(),
'referer' => $ref
]);
Expand Down
Loading