修正
This commit is contained in:
@@ -113,7 +113,7 @@ function str_rand($length = 16, $char = '0123456789abcdefghijklmnopqrstuvwxyzABC
|
||||
*/
|
||||
function make_token()
|
||||
{
|
||||
return md5('LSKY PRO' . time());
|
||||
return md5('LSKY PRO' . uniqid() . time());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -17,7 +17,7 @@ class Users extends Model
|
||||
{
|
||||
use SoftDelete;
|
||||
|
||||
protected $insert = ['reg_ip', 'quota'];
|
||||
protected $insert = ['reg_ip', 'quota', 'token'];
|
||||
|
||||
public function setPassWordAttr($password)
|
||||
{
|
||||
@@ -34,6 +34,11 @@ class Users extends Model
|
||||
return Config::where('name', 'user_initial_quota')->value('value');
|
||||
}
|
||||
|
||||
public function setTokenAttr()
|
||||
{
|
||||
return make_token();
|
||||
}
|
||||
|
||||
public function getUseQuotaAttr()
|
||||
{
|
||||
return $this->hasMany('Images', 'user_id', 'id')->sum('size');
|
||||
@@ -58,11 +63,7 @@ class Users extends Model
|
||||
if ($user->password !== md5($password)) {
|
||||
throw new Exception('密码不正确');
|
||||
}
|
||||
$token = make_token();
|
||||
Session::set('uid', $user->id);
|
||||
Session::set('token', $token);
|
||||
$user->token = $token;
|
||||
$user->save();
|
||||
} else {
|
||||
throw new Exception('用户不存在');
|
||||
}
|
||||
@@ -72,4 +73,4 @@ class Users extends Model
|
||||
{
|
||||
return $this->hasMany('Images', 'user_id', 'id');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user