load some envs to config to prevent cache problems
This commit is contained in:
parent
3df7cbc0b6
commit
124b98f9d7
|
|
@ -66,7 +66,7 @@ class User
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$class_name = "App\Services\Cipher\\".$_ENV['PWD_METHOD'];
|
$class_name = "App\Services\Cipher\\".config('secure.cipher');
|
||||||
$this->cipher = new $class_name;
|
$this->cipher = new $class_name;
|
||||||
|
|
||||||
if (!is_null($this->model)) {
|
if (!is_null($this->model)) {
|
||||||
|
|
@ -74,7 +74,7 @@ class User
|
||||||
$this->uid = $this->model->uid;
|
$this->uid = $this->model->uid;
|
||||||
$this->email = $this->model->email;
|
$this->email = $this->model->email;
|
||||||
$this->password = $this->model->password;
|
$this->password = $this->model->password;
|
||||||
$this->token = md5($this->email . $this->password . $_ENV['SALT']);
|
$this->token = md5($this->email . $this->password . config('secure.salt'));
|
||||||
$this->closet = new Closet($this->uid);
|
$this->closet = new Closet($this->uid);
|
||||||
$this->is_admin = $this->model->permission == 1 || $this->model->permission == 2;
|
$this->is_admin = $this->model->permission == 1 || $this->model->permission == 2;
|
||||||
}
|
}
|
||||||
|
|
@ -82,12 +82,12 @@ class User
|
||||||
|
|
||||||
public function checkPasswd($raw_passwd)
|
public function checkPasswd($raw_passwd)
|
||||||
{
|
{
|
||||||
return ($this->cipher->encrypt($raw_passwd, $_ENV['SALT']) == $this->password);
|
return ($this->cipher->encrypt($raw_passwd, config('secure.salt')) == $this->password);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function changePasswd($new_passwd)
|
public function changePasswd($new_passwd)
|
||||||
{
|
{
|
||||||
$this->model->password = $this->cipher->encrypt($new_passwd, $_ENV['SALT']);
|
$this->model->password = $this->cipher->encrypt($new_passwd, config('secure.salt'));
|
||||||
return $this->model->save();
|
return $this->model->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -133,7 +133,7 @@ class User
|
||||||
public function getToken($refresh = false)
|
public function getToken($refresh = false)
|
||||||
{
|
{
|
||||||
if ($this->is_registered && ($this->token === "" || $refresh)) {
|
if ($this->is_registered && ($this->token === "" || $refresh)) {
|
||||||
$this->token = md5($this->model->email . $this->model->password . $_ENV['SALT']);
|
$this->token = md5($this->model->email . $this->model->password . config('secure.salt'));
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->token;
|
return $this->token;
|
||||||
|
|
@ -220,7 +220,7 @@ class User
|
||||||
$user = new UserModel();
|
$user = new UserModel();
|
||||||
|
|
||||||
$user->email = $this->email;
|
$user->email = $this->email;
|
||||||
$user->password = $this->cipher->encrypt($password, $_ENV['SALT']);
|
$user->password = $this->cipher->encrypt($password, config('secure.salt'));
|
||||||
$user->ip = $ip;
|
$user->ip = $ip;
|
||||||
$user->score = Option::get('user_initial_score');
|
$user->score = Option::get('user_initial_score');
|
||||||
$user->register_at = Utils::getTimeFormatted();
|
$user->register_at = Utils::getTimeFormatted();
|
||||||
|
|
|
||||||
|
|
@ -41,12 +41,7 @@ class Database
|
||||||
*/
|
*/
|
||||||
public function __construct($config = null)
|
public function __construct($config = null)
|
||||||
{
|
{
|
||||||
if (is_null($config)) {
|
$this->config = is_null($config) ? config('database.connections.mysql') : $config;
|
||||||
$db_config = require BASE_DIR.'/config/database.php';
|
|
||||||
$config = $db_config['connections']['mysql'];
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->config = $config;
|
|
||||||
|
|
||||||
@$this->connection = new \mysqli(
|
@$this->connection = new \mysqli(
|
||||||
$this->config['host'],
|
$this->config['host'],
|
||||||
|
|
|
||||||
14
config/secure.php
Normal file
14
config/secure.php
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
return [
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Configuration about security
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| Load them from env to config, preventing cache problems
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
'cipher' => env('PWD_METHOD', 'SALTED2MD5'),
|
||||||
|
'salt' => env('APP_KEY', '')
|
||||||
|
];
|
||||||
|
|
@ -27,7 +27,7 @@
|
||||||
|
|
||||||
@if (Session::has('msg'))
|
@if (Session::has('msg'))
|
||||||
<script>
|
<script>
|
||||||
toastr.info('{{ session('msg') }}');
|
toastr.info('{{ Session::pull('msg') }}');
|
||||||
</script>
|
</script>
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -63,7 +63,7 @@ switch ($step) {
|
||||||
$options['announcement'] = str_replace('{version}', $options['version'], $options['announcement']);
|
$options['announcement'] = str_replace('{version}', $options['version'], $options['announcement']);
|
||||||
|
|
||||||
foreach ($options as $key => $value) {
|
foreach ($options as $key => $value) {
|
||||||
Option::add($key, $value);
|
Option::set($key, $value);
|
||||||
}
|
}
|
||||||
|
|
||||||
// register super admin
|
// register super admin
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user