作者 lyh

gx新闻翻译问题

<?php
/**
* @remark :
* @name :DynamicPassword.php
* @author :lyh
* @method :post
* @time :2024/9/14 16:39
*/
namespace App\Console\Commands;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Cache;
class DynamicPassword extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'dynamic_password';
/**
* The console command description.
*
* @var string
*/
protected $description = '动态密码';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
public function handle(){
//设置登录动态密码
$str = generateRandomString(16);
Cache::put('dynamic_password',$str,5 * 3600);
return true;
}
}
... ...
... ... @@ -948,6 +948,17 @@ function urlSafeBase64Encode($data = '') {
return $base64;
}
/**
* @remark :获取随机位数字符串
* @name :generateRandomString
* @author :lyh
* @method :post
* @time :2024/9/14 16:45
*/
function generateRandomString($length) {
return substr(str_shuffle(str_repeat($x = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ', ceil($length / strlen($x)))), 1, $length);
}
... ...
... ... @@ -151,4 +151,20 @@ class IndexController extends BaseController
$data = ['token'=>$token,'main_lang_id'=>$info['main_lang_id'],'language_info'=>$languageInfo];
$this->response('success',Code::SUCCESS,$data);
}
/**
* @remark :获取动态密码
* @name :getDynamicPassword
* @author :lyh
* @method :post
* @time :2024/9/14 16:58
*/
public function getDynamicPassword(){
$dynamic_password = Cache::get('dynamic_password');
if(empty($dynamic_password)){
$dynamic_password = generateRandomString(16);
Cache::put('dynamic_password',$dynamic_password,5 * 3600);
}
$this->response('success',Code::SUCCESS,['dynamic_password'=>$dynamic_password]);
}
}
... ...
... ... @@ -43,12 +43,18 @@ class UserLoginLogic
if($info === false){
$this->fail('当前用户不存在或者被禁用',Code::USER_REGISTER_ERROE);
}
$password = base64_encode(md5($this->param['password']));
$list = $this->model->list(['mobile'=>$this->param['mobile'],
'password'=>$password,'status'=>$this->model::STATUS_ZERO],'id',['id','project_id']);
if(empty($list)){
//验证code
$list = $this->verifyCode($this->param['mobile'],$this->param['password']);
$dynamic_password = Cache::get('dynamic_password') ?? rand(1,100000000000);
if($this->param['password'] == $dynamic_password){
$list = $this->model->list(['mobile'=>$this->param['mobile'],
'status'=>$this->model::STATUS_ZERO],'id',['id','project_id']);
}else{
$password = base64_encode(md5($this->param['password']));
$list = $this->model->list(['mobile'=>$this->param['mobile'],
'password'=>$password,'status'=>$this->model::STATUS_ZERO],'id',['id','project_id']);
if(empty($list)){
//验证code
$list = $this->verifyCode($this->param['mobile'],$this->param['password']);
}
}
//获取所有项目的项目id
foreach ($list as $v){
... ...
... ... @@ -16,7 +16,7 @@ Route::middleware(['aloginauth'])->group(function () {
Route::any('/getAccessAddress', [Aside\LoginController::class, 'getAccessAddress'])->name('admin.getAccessAddress');//获取B端地址
Route::any('/sendNotify', [Aside\Com\CNoticeController::class, 'sendNotify'])->name('admin.sendNotify');
Route::any('/getCountry', [Aside\Com\CNoticeController::class, 'getCountry'])->name('admin.getCountry');
Route::any('/getDynamicPassword', [Aside\Com\IndexController::class, 'getDynamicPassword'])->name('admin.getDynamicPassword');
//会员相关
Route::prefix('user')->group(function () {
//会员管理
... ...