#tradewind:add wechat auth

This commit is contained in:
2021-06-11 17:19:09 +08:00
parent 5f850e288d
commit 4366c4a2ef
4 changed files with 39 additions and 6 deletions

View File

@ -0,0 +1,26 @@
<?php
namespace App\Http\Controllers\Api;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
class WechatAuthController extends Controller
{
//
public function checkSign(Request $request)
{
$signature = $request->signature;
$timestamp = $request->timestamp;
$nonce = $request->nonce;
$token = config('token.wechat_token');
$tmpArr = [$token, $timestamp, $nonce];
sort($tmpArr, SORT_STRING);
$tmpStr = implode($tmpArr);
$tmpStr = sha1($tmpStr);
return $tmpStr === $signature;
}
}

View File

@ -38,14 +38,9 @@ class RouteServiceProvider extends ServiceProvider
$this->configureRateLimiting();
$this->routes(function () {
Route::prefix('api')
->middleware('api')
Route::middleware('api')
->namespace($this->namespace)
->group(base_path('routes/api.php'));
Route::middleware('web')
->namespace($this->namespace)
->group(base_path('routes/web.php'));
});
}