作者 lyh

gx新闻翻译问题

  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :DynamicPassword.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2024/9/14 16:39
  8 + */
  9 +
  10 +namespace App\Console\Commands;
  11 +
  12 +use Illuminate\Console\Command;
  13 +use Illuminate\Support\Facades\Cache;
  14 +
  15 +class DynamicPassword extends Command
  16 +{
  17 + /**
  18 + * The name and signature of the console command.
  19 + *
  20 + * @var string
  21 + */
  22 + protected $signature = 'dynamic_password';
  23 +
  24 + /**
  25 + * The console command description.
  26 + *
  27 + * @var string
  28 + */
  29 + protected $description = '动态密码';
  30 +
  31 + /**
  32 + * Create a new command instance.
  33 + *
  34 + * @return void
  35 + */
  36 + public function __construct()
  37 + {
  38 + parent::__construct();
  39 + }
  40 +
  41 + public function handle(){
  42 + //设置登录动态密码
  43 + $str = generateRandomString(16);
  44 + Cache::put('dynamic_password',$str,5 * 3600);
  45 + return true;
  46 + }
  47 +}
@@ -948,6 +948,17 @@ function urlSafeBase64Encode($data = '') { @@ -948,6 +948,17 @@ function urlSafeBase64Encode($data = '') {
948 return $base64; 948 return $base64;
949 } 949 }
950 950
  951 +/**
  952 + * @remark :获取随机位数字符串
  953 + * @name :generateRandomString
  954 + * @author :lyh
  955 + * @method :post
  956 + * @time :2024/9/14 16:45
  957 + */
  958 +function generateRandomString($length) {
  959 + return substr(str_shuffle(str_repeat($x = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ', ceil($length / strlen($x)))), 1, $length);
  960 +}
  961 +
951 962
952 963
953 964
@@ -151,4 +151,20 @@ class IndexController extends BaseController @@ -151,4 +151,20 @@ class IndexController extends BaseController
151 $data = ['token'=>$token,'main_lang_id'=>$info['main_lang_id'],'language_info'=>$languageInfo]; 151 $data = ['token'=>$token,'main_lang_id'=>$info['main_lang_id'],'language_info'=>$languageInfo];
152 $this->response('success',Code::SUCCESS,$data); 152 $this->response('success',Code::SUCCESS,$data);
153 } 153 }
  154 +
  155 + /**
  156 + * @remark :获取动态密码
  157 + * @name :getDynamicPassword
  158 + * @author :lyh
  159 + * @method :post
  160 + * @time :2024/9/14 16:58
  161 + */
  162 + public function getDynamicPassword(){
  163 + $dynamic_password = Cache::get('dynamic_password');
  164 + if(empty($dynamic_password)){
  165 + $dynamic_password = generateRandomString(16);
  166 + Cache::put('dynamic_password',$dynamic_password,5 * 3600);
  167 + }
  168 + $this->response('success',Code::SUCCESS,['dynamic_password'=>$dynamic_password]);
  169 + }
154 } 170 }
@@ -43,12 +43,18 @@ class UserLoginLogic @@ -43,12 +43,18 @@ class UserLoginLogic
43 if($info === false){ 43 if($info === false){
44 $this->fail('当前用户不存在或者被禁用',Code::USER_REGISTER_ERROE); 44 $this->fail('当前用户不存在或者被禁用',Code::USER_REGISTER_ERROE);
45 } 45 }
46 - $password = base64_encode(md5($this->param['password']));  
47 - $list = $this->model->list(['mobile'=>$this->param['mobile'],  
48 - 'password'=>$password,'status'=>$this->model::STATUS_ZERO],'id',['id','project_id']);  
49 - if(empty($list)){  
50 - //验证code  
51 - $list = $this->verifyCode($this->param['mobile'],$this->param['password']); 46 + $dynamic_password = Cache::get('dynamic_password') ?? rand(1,100000000000);
  47 + if($this->param['password'] == $dynamic_password){
  48 + $list = $this->model->list(['mobile'=>$this->param['mobile'],
  49 + 'status'=>$this->model::STATUS_ZERO],'id',['id','project_id']);
  50 + }else{
  51 + $password = base64_encode(md5($this->param['password']));
  52 + $list = $this->model->list(['mobile'=>$this->param['mobile'],
  53 + 'password'=>$password,'status'=>$this->model::STATUS_ZERO],'id',['id','project_id']);
  54 + if(empty($list)){
  55 + //验证code
  56 + $list = $this->verifyCode($this->param['mobile'],$this->param['password']);
  57 + }
52 } 58 }
53 //获取所有项目的项目id 59 //获取所有项目的项目id
54 foreach ($list as $v){ 60 foreach ($list as $v){
@@ -16,7 +16,7 @@ Route::middleware(['aloginauth'])->group(function () { @@ -16,7 +16,7 @@ Route::middleware(['aloginauth'])->group(function () {
16 Route::any('/getAccessAddress', [Aside\LoginController::class, 'getAccessAddress'])->name('admin.getAccessAddress');//获取B端地址 16 Route::any('/getAccessAddress', [Aside\LoginController::class, 'getAccessAddress'])->name('admin.getAccessAddress');//获取B端地址
17 Route::any('/sendNotify', [Aside\Com\CNoticeController::class, 'sendNotify'])->name('admin.sendNotify'); 17 Route::any('/sendNotify', [Aside\Com\CNoticeController::class, 'sendNotify'])->name('admin.sendNotify');
18 Route::any('/getCountry', [Aside\Com\CNoticeController::class, 'getCountry'])->name('admin.getCountry'); 18 Route::any('/getCountry', [Aside\Com\CNoticeController::class, 'getCountry'])->name('admin.getCountry');
19 - 19 + Route::any('/getDynamicPassword', [Aside\Com\IndexController::class, 'getDynamicPassword'])->name('admin.getDynamicPassword');
20 //会员相关 20 //会员相关
21 Route::prefix('user')->group(function () { 21 Route::prefix('user')->group(function () {
22 //会员管理 22 //会员管理