mirror of
https://github.com/grocy/grocy.git
synced 2025-04-28 17:23:56 +00:00
Handle demo mode via a setting instead of checking the existence of a file (closes #484)
This commit is contained in:
parent
539334f5ee
commit
a8cf5ae9ab
@ -90,7 +90,7 @@ If you don't use certain feature sets of grocy (for example if you don't need "C
|
||||
- When the file `data/custom_css.html` exists, the contents of the file will be added just before `</head>` (end of head) on every page
|
||||
|
||||
### Demo mode
|
||||
When the file `data/demo.txt` exists, the application will work in a demo mode which means authentication is disabled and some demo data will be generated during the database schema migration.
|
||||
When the `MODE` setting is set to `dev`, `demo` or `prerelease`, the application will work in a demo mode which means authentication is disabled and some demo data will be generated during the database schema migration.
|
||||
|
||||
### Embedded mode
|
||||
When the file `embedded.txt` exists, it must contain a valid and writable path which will be used as the data directory instead of `data` and authentication will be disabled (used in [grocy-desktop](https://github.com/grocy/grocy-desktop)).
|
||||
|
20
app.php
20
app.php
@ -19,20 +19,6 @@ else
|
||||
define('GROCY_DATAPATH', __DIR__ . '/data');
|
||||
}
|
||||
|
||||
// Definitions for demo mode
|
||||
if (file_exists(GROCY_DATAPATH . '/demo.txt'))
|
||||
{
|
||||
define('GROCY_IS_DEMO_INSTALL', true);
|
||||
if (!defined('GROCY_USER_ID'))
|
||||
{
|
||||
define('GROCY_USER_ID', 1);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
define('GROCY_IS_DEMO_INSTALL', false);
|
||||
}
|
||||
|
||||
// Load composer dependencies
|
||||
require_once __DIR__ . '/vendor/autoload.php';
|
||||
|
||||
@ -40,6 +26,12 @@ require_once __DIR__ . '/vendor/autoload.php';
|
||||
require_once GROCY_DATAPATH . '/config.php';
|
||||
require_once __DIR__ . '/config-dist.php'; // For not in own config defined values we use the default ones
|
||||
|
||||
// Definitions for dev/demo/prerelease mode
|
||||
if (GROCY_MODE === 'dev' || GROCY_MODE === 'demo' || GROCY_MODE === 'prerelease')
|
||||
{
|
||||
define('GROCY_USER_ID', 1);
|
||||
}
|
||||
|
||||
// Definitions for disabled authentication mode
|
||||
if (GROCY_DISABLE_AUTH === true)
|
||||
{
|
||||
|
@ -33,6 +33,7 @@
|
||||
- Fixed that the meal plan menu entry (sidebar) was not visible when the calendar was disabled (`FEATURE_FLAG_CALENDAR`) (thanks @lwis)
|
||||
- Slightly optimized table loading & search performance (thanks @lwis)
|
||||
- For integration: If a `GET` parameter `closeAfterCreation` is passed to the product edit page, the window will be closed on save (due to Browser restrictions, this only works when the window was opened from JavaScript) (thanks @Forceu)
|
||||
- The `update.sh` file had wrong line endings (DOS instead of Unix)
|
||||
- Fixed that the `update.sh` file had wrong line endings (DOS instead of Unix)
|
||||
- Internal change: Demo mode is now handled via the setting `MODE` instead of checking the existence of the file `data/demo.txt`
|
||||
- New translations: (thanks all the translators)
|
||||
- Portuguese (Brazil) (demo available at https://pt-br.demo.grocy.info)
|
||||
|
@ -15,7 +15,8 @@
|
||||
|
||||
|
||||
# Either "production", "dev", "demo" or "prerelease"
|
||||
# ("demo" and "prerelease" is reserved to be used only on the offical demo instances)
|
||||
# When not "production", authentication will be disabled and
|
||||
# demo data will be populated during database migrations
|
||||
Setting('MODE', 'production');
|
||||
|
||||
# Either "en" or "de" or the directory name of
|
||||
|
@ -22,7 +22,7 @@ class SystemController extends BaseController
|
||||
$databaseMigrationService = new DatabaseMigrationService();
|
||||
$databaseMigrationService->MigrateDatabase();
|
||||
|
||||
if (GROCY_IS_DEMO_INSTALL)
|
||||
if (GROCY_MODE === 'dev' || GROCY_MODE === 'demo' || GROCY_MODE === 'prerelease')
|
||||
{
|
||||
$demoDataGeneratorService = new DemoDataGeneratorService();
|
||||
$demoDataGeneratorService->PopulateDemoData();
|
||||
|
@ -22,7 +22,7 @@ class ApiKeyAuthMiddleware extends BaseMiddleware
|
||||
$route = $request->getAttribute('route');
|
||||
$routeName = $route->getName();
|
||||
|
||||
if (GROCY_IS_DEMO_INSTALL || GROCY_IS_EMBEDDED_INSTALL || GROCY_DISABLE_AUTH)
|
||||
if (GROCY_MODE === 'dev' || GROCY_MODE === 'demo' || GROCY_MODE === 'prerelease' || GROCY_IS_EMBEDDED_INSTALL || GROCY_DISABLE_AUTH)
|
||||
{
|
||||
define('GROCY_AUTHENTICATED', true);
|
||||
$response = $next($request, $response);
|
||||
|
@ -25,7 +25,7 @@ class SessionAuthMiddleware extends BaseMiddleware
|
||||
{
|
||||
$response = $next($request, $response);
|
||||
}
|
||||
elseif (GROCY_IS_DEMO_INSTALL || GROCY_IS_EMBEDDED_INSTALL || GROCY_DISABLE_AUTH)
|
||||
elseif (GROCY_MODE === 'dev' || GROCY_MODE === 'demo' || GROCY_MODE === 'prerelease' || GROCY_IS_EMBEDDED_INSTALL || GROCY_DISABLE_AUTH)
|
||||
{
|
||||
$user = $sessionService->GetDefaultUser();
|
||||
define('GROCY_AUTHENTICATED', true);
|
||||
|
Loading…
x
Reference in New Issue
Block a user