fix determining tables exist without prefix
This commit is contained in:
parent
7f79a654bd
commit
84e4d97f00
|
|
@ -84,6 +84,8 @@ $app->instance('request', $request);
|
||||||
|
|
||||||
$app->singleton('database', App\Services\Database\Database::class);
|
$app->singleton('database', App\Services\Database\Database::class);
|
||||||
$app->singleton('option', App\Services\Repositories\OptionRepository::class);
|
$app->singleton('option', App\Services\Repositories\OptionRepository::class);
|
||||||
|
$app->singleton('cipher', "App\Services\Cipher\\".config('secure.cipher'));
|
||||||
|
$app->singleton('users', App\Services\Repositories\UserRepository::class);
|
||||||
|
|
||||||
View::addExtension('tpl', 'blade');
|
View::addExtension('tpl', 'blade');
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
* @Author: printempw
|
* @Author: printempw
|
||||||
* @Date: 2016-09-14 16:57:37
|
* @Date: 2016-09-14 16:57:37
|
||||||
* @Last Modified by: printempw
|
* @Last Modified by: printempw
|
||||||
* @Last Modified time: 2016-09-30 23:18:56
|
* @Last Modified time: 2016-10-23 13:23:24
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function check_table_exists() {
|
function check_table_exists() {
|
||||||
|
|
@ -11,7 +11,7 @@ function check_table_exists() {
|
||||||
|
|
||||||
foreach ($tables as $table_name) {
|
foreach ($tables as $table_name) {
|
||||||
// prefix will be added automatically
|
// prefix will be added automatically
|
||||||
if (!Database::hasTable($table_name)) {
|
if (!Database::hasTable(config('database.connections.mysql.prefix').$table_name)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -67,9 +67,13 @@ switch ($step) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// register super admin
|
// register super admin
|
||||||
$user = new App\Models\User(null, ['email' => $_POST['email']]);
|
$user = App\Models\User::register($_POST['email'], $_POST['password'], function($user) {
|
||||||
$user->register($_POST['password'], get_real_ip());
|
$user->ip = get_real_ip();
|
||||||
$user->setPermission('2');
|
$user->score = option('user_initial_score');
|
||||||
|
$user->register_at = Utils::getTimeFormatted();
|
||||||
|
$user->last_sign_at = Utils::getTimeFormatted(time() - 86400);
|
||||||
|
$user->permission = App\Models\User::SUPER_ADMIN;
|
||||||
|
});
|
||||||
|
|
||||||
if (!is_dir(BASE_DIR.'/storage/textures/')) {
|
if (!is_dir(BASE_DIR.'/storage/textures/')) {
|
||||||
if (!mkdir(BASE_DIR.'/storage/textures/'))
|
if (!mkdir(BASE_DIR.'/storage/textures/'))
|
||||||
|
|
|
||||||
|
|
@ -10,19 +10,20 @@ if (!check_table_exists()) {
|
||||||
redirect_to('../index.php');
|
redirect_to('../index.php');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// load session from cookie
|
||||||
if (isset($_COOKIE['uid']) && isset($_COOKIE['token'])) {
|
if (isset($_COOKIE['uid']) && isset($_COOKIE['token'])) {
|
||||||
$_SESSION['uid'] = $_COOKIE['uid'];
|
$_SESSION['uid'] = $_COOKIE['uid'];
|
||||||
$_SESSION['token'] = $_COOKIE['token'];
|
$_SESSION['token'] = $_COOKIE['token'];
|
||||||
}
|
}
|
||||||
|
|
||||||
// check permission
|
// check permission
|
||||||
if (isset($_SESSION['uid'])) {
|
if (isset($_SESSION['uid'])) {
|
||||||
$user = new App\Models\User($_SESSION['uid']);
|
$user = $app['users']->get($encrypter->decrypt($_COOKIE['uid']));
|
||||||
|
|
||||||
if ($_SESSION['token'] != $user->getToken())
|
if ($_SESSION['token'] != $user->getToken())
|
||||||
redirect_to('../../auth/login', '无效的 token,请重新登录~');
|
redirect_to('../../auth/login', '无效的 token,请重新登录~');
|
||||||
|
|
||||||
if ($user->getPermission() != "2")
|
if ($user->getPermission() != App\Models\User::SUPER_ADMIN)
|
||||||
abort(403, '此页面仅超级管理员可访问');
|
abort(403, '此页面仅超级管理员可访问');
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user