diff --git a/app/Http/Controllers/Admin/AuthController.php b/app/Http/Controllers/Admin/AuthController.php index dd62373..f7b2208 100644 --- a/app/Http/Controllers/Admin/AuthController.php +++ b/app/Http/Controllers/Admin/AuthController.php @@ -15,6 +15,7 @@ use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Hash; use Illuminate\Support\Facades\Validator; use Illuminate\Validation\ValidationException; +use Tymon\JWTAuth\Facades\JWTAuth; class AuthController extends Controller { @@ -49,6 +50,7 @@ class AuthController extends Controller */ public function login(Request $request): JsonResponse { + $credentials = $request->only('username', 'password'); try { $validator = Validator::make($request->all(), [ 'username' => 'required', @@ -71,11 +73,10 @@ class AuthController extends Controller throw new CustomException(__('validation.auth.u_disabled'), 400); } - // 删除旧token - $user->tokens()->delete(); - // 创建新token - $token = $user->createToken('auth-token')->plainTextToken; + if (!$token = JWTAuth::attempt($credentials)) { + throw new CustomException(__validation('auth.invalid'), 401); + } // 记录最后登录时间 AdminUsers::query()->where('id', $user->id)->update(['last_login_time' => get_datetime()]); @@ -106,11 +107,11 @@ class AuthController extends Controller public function logout(): JsonResponse { try { - $user = Auth::guard('sanctum')->user(); + $user = Auth::guard()->user(); if ($user) { // 删除所有token - $user->tokens()->delete(); + JWTAuth::invalidate(JWTAuth::getToken()); // 清除所有会话数据 session()->flush(); @@ -124,6 +125,19 @@ class AuthController extends Controller } } + /** + * 刷新 Token + */ + public function refresh() + { + // 刷新当前 token,旧 token 会进入黑名单 + $token = JWTAuth::refresh(JWTAuth::getToken()); + return $this->responseService->success( + compact('token'), + __('admin.operation_successful') + ); + } + /** * 获取当前登录用户信息 * @return JsonResponse @@ -132,11 +146,7 @@ class AuthController extends Controller public function me(): JsonResponse { try { - $user = Auth::guard('sanctum')->user(); - - if (!$user) { - throw new CustomException('未登录', 401); - } + $user = Auth::guard()->user(); // 查询用户角色和权限 $roles = $user->roles()->pluck('name')->toArray(); @@ -180,9 +190,9 @@ class AuthController extends Controller throw new ValidationException($validator); } $language = $data['language']; - $user = Auth::guard('sanctum')->user(); + $user = Auth::guard()->user(); $service = new AdminUsersService(new OperationLogService()); - $service->updateLocale($user->id, $language); + $service->updateLocale($user['id'], $language); App::setLocale($language); return $this->responseService->success([], __('admin.operation_successful')); } catch (\Exception $e) { diff --git a/app/Http/Middleware/AdminAuthMiddleware.php b/app/Http/Middleware/AdminAuthMiddleware.php index 54e5f9f..c088655 100644 --- a/app/Http/Middleware/AdminAuthMiddleware.php +++ b/app/Http/Middleware/AdminAuthMiddleware.php @@ -33,19 +33,19 @@ class AdminAuthMiddleware public function handle(Request $request, Closure $next): mixed { // 检查请求头中是否有 auth - if (!$request->hasHeader('auth')) { + if (!$request->hasHeader('Authorization')) { return $this->responseService->unauthorized( __('middleware.auth.token_exists') ); } - $token = $request->header('auth'); + $token = $request->header('Authorization'); // 检查 token 是否有效 - if (!Auth::guard('sanctum')->check()) { + if (!Auth::guard()->check()) { // 尝试通过 token 认证 - $request->headers->set('Authorization', 'Bearer ' . $token); - if (!Auth::guard('sanctum')->check()) { + $request->headers->set('Authorization', $token); + if (!Auth::guard()->check()) { return $this->responseService->unauthorized( __('middleware.auth.token_invalid') ); @@ -53,8 +53,8 @@ class AdminAuthMiddleware } // 检查用户状态 - $user = Auth::guard('sanctum')->user(); - if (!$user || $user->status !== 1) { + $user = Auth::guard()->user(); + if (!$user || $user['status'] !== 1) { return $this->responseService->error( __('middleware.auth.user_disabled'), 400 diff --git a/app/Http/Middleware/LanguageSwitcher.php b/app/Http/Middleware/LanguageSwitcher.php index 0970b01..ae36188 100644 --- a/app/Http/Middleware/LanguageSwitcher.php +++ b/app/Http/Middleware/LanguageSwitcher.php @@ -18,10 +18,10 @@ class LanguageSwitcher $request->headers->set('Authorization', 'Bearer ' . $token); } // 优先使用用户设置的语言 - if (Auth::guard('sanctum')->check() - && Auth::guard('sanctum')->user()->locale + if (Auth::guard()->check() + && Auth::guard()->user()['locale'] ) { - App::setLocale(auth('sanctum')->user()->locale); + App::setLocale(auth()->user()['locale']); } // 其次使用会话中的语言设置 elseif (Session::has('locale')) { App::setLocale(Session::get('locale')); diff --git a/app/Imports/ParkingVipListImport.php b/app/Imports/ParkingVipListImport.php index 374c4e2..65f9d7b 100644 --- a/app/Imports/ParkingVipListImport.php +++ b/app/Imports/ParkingVipListImport.php @@ -50,7 +50,7 @@ class ParkingVipListImport implements ToModel } $model = ParkingVipList::query()->create([ 'license_id' => $license_id, - 'user_id' => Auth::guard('sanctum')->user()['id'], + 'user_id' => Auth::guard()->user()['id'], 'created_at' => get_datetime() ]); $this->logService->logCreated($model, 'vip_list.create'); diff --git a/app/Models/AdminUsers.php b/app/Models/AdminUsers.php index c272cf7..84cf843 100644 --- a/app/Models/AdminUsers.php +++ b/app/Models/AdminUsers.php @@ -3,17 +3,34 @@ namespace App\Models; use Illuminate\Database\Eloquent\Factories\HasFactory; -use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\BelongsToMany; use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Notifications\Notifiable; use Illuminate\Support\Collection; use Laravel\Sanctum\HasApiTokens; +use Tymon\JWTAuth\Contracts\JWTSubject; +use Illuminate\Foundation\Auth\User as Authenticatable; -class AdminUsers extends Model +class AdminUsers extends Authenticatable implements JWTSubject { use HasApiTokens, HasFactory, Notifiable, SoftDeletes; + /** + * 获取会存入 JWT 的标识符,一般就是用户表的主键 + */ + public function getJWTIdentifier() + { + return $this->getKey(); + } + + /** + * 返回一个键值数组,用于添加自定义 claims 到 JWT + */ + public function getJWTCustomClaims() + { + return []; + } + /** * The attributes that are mass assignable. * @var array diff --git a/app/Services/OperationLogService.php b/app/Services/OperationLogService.php index 70e2b13..38b0b35 100644 --- a/app/Services/OperationLogService.php +++ b/app/Services/OperationLogService.php @@ -35,7 +35,7 @@ final class OperationLogService ?array $oldValues = null, ?array $newValues = null ): AdminOperationLog { - $user_id = Auth::guard('sanctum')->user()['id'] ?? 0; + $user_id = Auth::guard()->user()['id'] ?? 0; if (!$user_id) { $user_id = DB::table('admin_users')->where('username', 'Admin') ->value('id'); diff --git a/app/Services/ParkingVipListService.php b/app/Services/ParkingVipListService.php index dd0cde8..1f756cc 100644 --- a/app/Services/ParkingVipListService.php +++ b/app/Services/ParkingVipListService.php @@ -49,7 +49,7 @@ class ParkingVipListService $model = ParkingVipList::query()->create([ 'license_id' => $license_id, - 'user_id' => Auth::guard('sanctum')->user()['id'], + 'user_id' => Auth::guard()->user()['id'], 'created_at' => get_datetime() ]); @@ -94,7 +94,7 @@ class ParkingVipListService $model->update([ 'license_id' => $license_id, - 'user_id' => Auth::guard('sanctum')->user()['id'], + 'user_id' => Auth::guard()->user()['id'], 'updated_at' => get_datetime() ]); diff --git a/composer.json b/composer.json index 2f1e930..8ba4e6e 100644 --- a/composer.json +++ b/composer.json @@ -11,7 +11,8 @@ "laravel/sanctum": "^3.2", "laravel/tinker": "^2.8", "maatwebsite/excel": "^3.1", - "predis/predis": "^3.5" + "predis/predis": "^3.5", + "tymon/jwt-auth": "^2.3" }, "require-dev": { "fakerphp/faker": "^1.9.1", diff --git a/composer.lock b/composer.lock index b963b0e..711a94d 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "40af0347060cc0895f808ae3e42ce327", + "content-hash": "8609503e9205605a397777ef511f787a", "packages": [ { "name": "brick/math", @@ -1731,6 +1731,146 @@ }, "time": "2026-02-06T14:12:35+00:00" }, + { + "name": "lcobucci/clock", + "version": "2.3.0", + "source": { + "type": "git", + "url": "https://github.com/lcobucci/clock.git", + "reference": "c7aadcd6fd97ed9e199114269c0be3f335e38876" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/lcobucci/clock/zipball/c7aadcd6fd97ed9e199114269c0be3f335e38876", + "reference": "c7aadcd6fd97ed9e199114269c0be3f335e38876", + "shasum": "" + }, + "require": { + "php": "~8.1.0 || ~8.2.0", + "stella-maris/clock": "^0.1.7" + }, + "provide": { + "psr/clock-implementation": "1.0" + }, + "require-dev": { + "infection/infection": "^0.26", + "lcobucci/coding-standard": "^9.0", + "phpstan/extension-installer": "^1.2", + "phpstan/phpstan": "^1.9.4", + "phpstan/phpstan-deprecation-rules": "^1.1.1", + "phpstan/phpstan-phpunit": "^1.3.2", + "phpstan/phpstan-strict-rules": "^1.4.4", + "phpunit/phpunit": "^9.5.27" + }, + "type": "library", + "autoload": { + "psr-4": { + "Lcobucci\\Clock\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Luís Cobucci", + "email": "lcobucci@gmail.com" + } + ], + "description": "Yet another clock abstraction", + "support": { + "issues": "https://github.com/lcobucci/clock/issues", + "source": "https://github.com/lcobucci/clock/tree/2.3.0" + }, + "funding": [ + { + "url": "https://github.com/lcobucci", + "type": "github" + }, + { + "url": "https://www.patreon.com/lcobucci", + "type": "patreon" + } + ], + "time": "2022-12-19T14:38:11+00:00" + }, + { + "name": "lcobucci/jwt", + "version": "4.0.4", + "source": { + "type": "git", + "url": "https://github.com/lcobucci/jwt.git", + "reference": "55564265fddf810504110bd68ca311932324b0e9" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/lcobucci/jwt/zipball/55564265fddf810504110bd68ca311932324b0e9", + "reference": "55564265fddf810504110bd68ca311932324b0e9", + "shasum": "" + }, + "require": { + "ext-mbstring": "*", + "ext-openssl": "*", + "lcobucci/clock": "^2.0", + "php": "^7.4 || ^8.0" + }, + "require-dev": { + "infection/infection": "^0.20", + "lcobucci/coding-standard": "^6.0", + "mikey179/vfsstream": "^1.6", + "phpbench/phpbench": "^0.17", + "phpstan/extension-installer": "^1.0", + "phpstan/phpstan": "^0.12", + "phpstan/phpstan-deprecation-rules": "^0.12", + "phpstan/phpstan-phpunit": "^0.12", + "phpstan/phpstan-strict-rules": "^0.12", + "phpunit/php-invoker": "^3.1", + "phpunit/phpunit": "^9.4" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.0-dev" + } + }, + "autoload": { + "psr-4": { + "Lcobucci\\JWT\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Luís Cobucci", + "email": "lcobucci@gmail.com", + "role": "Developer" + } + ], + "description": "A simple library to work with JSON Web Token and JSON Web Signature", + "keywords": [ + "JWS", + "jwt" + ], + "support": { + "issues": "https://github.com/lcobucci/jwt/issues", + "source": "https://github.com/lcobucci/jwt/tree/4.0.4" + }, + "funding": [ + { + "url": "https://github.com/lcobucci", + "type": "github" + }, + { + "url": "https://www.patreon.com/lcobucci", + "type": "patreon" + } + ], + "time": "2021-09-28T19:18:28+00:00" + }, { "name": "league/commonmark", "version": "2.8.2", @@ -3820,6 +3960,53 @@ }, "time": "2026-06-18T03:57:49+00:00" }, + { + "name": "stella-maris/clock", + "version": "0.1.7", + "source": { + "type": "git", + "url": "https://github.com/stella-maris-solutions/clock.git", + "reference": "fa23ce16019289a18bb3446fdecd45befcdd94f8" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/stella-maris-solutions/clock/zipball/fa23ce16019289a18bb3446fdecd45befcdd94f8", + "reference": "fa23ce16019289a18bb3446fdecd45befcdd94f8", + "shasum": "" + }, + "require": { + "php": "^7.0|^8.0", + "psr/clock": "^1.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "StellaMaris\\Clock\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Andreas Heigl", + "role": "Maintainer" + } + ], + "description": "A pre-release of the proposed PSR-20 Clock-Interface", + "homepage": "https://gitlab.com/stella-maris/clock", + "keywords": [ + "clock", + "datetime", + "point in time", + "psr20" + ], + "support": { + "source": "https://github.com/stella-maris-solutions/clock/tree/0.1.7" + }, + "time": "2022-11-25T16:15:06+00:00" + }, { "name": "symfony/console", "version": "v6.4.42", @@ -6143,6 +6330,84 @@ }, "time": "2025-12-02T11:56:42+00:00" }, + { + "name": "tymon/jwt-auth", + "version": "2.3.0", + "source": { + "type": "git", + "url": "https://github.com/tymondesigns/jwt-auth.git", + "reference": "6c70930a92710d97e8e52b182fca2176097f33be" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/tymondesigns/jwt-auth/zipball/6c70930a92710d97e8e52b182fca2176097f33be", + "reference": "6c70930a92710d97e8e52b182fca2176097f33be", + "shasum": "" + }, + "require": { + "illuminate/auth": "^9.0|^10.0|^11.0|^12.0|^13.0", + "illuminate/contracts": "^9.0|^10.0|^11.0|^12.0|^13.0", + "illuminate/http": "^9.0|^10.0|^11.0|^12.0|^13.0", + "illuminate/support": "^9.0|^10.0|^11.0|^12.0|^13.0", + "lcobucci/jwt": "^4.0|^5.0", + "nesbot/carbon": "^2.69|^3.0", + "php": "^8.0" + }, + "require-dev": { + "illuminate/console": "^9.0|^10.0|^11.0|^12.0|^13.0", + "illuminate/database": "^9.0|^10.0|^11.0|^12.0|^13.0", + "illuminate/routing": "^9.0|^10.0|^11.0|^12.0|^13.0", + "mockery/mockery": "^1.6", + "phpunit/phpunit": "^9.4" + }, + "type": "library", + "extra": { + "laravel": { + "aliases": { + "JWTAuth": "Tymon\\JWTAuth\\Facades\\JWTAuth", + "JWTFactory": "Tymon\\JWTAuth\\Facades\\JWTFactory" + }, + "providers": [ + "Tymon\\JWTAuth\\Providers\\LaravelServiceProvider" + ] + }, + "branch-alias": { + "dev-2.x": "2.0-dev", + "dev-develop": "1.0-dev" + } + }, + "autoload": { + "psr-4": { + "Tymon\\JWTAuth\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Sean Tymon", + "email": "tymon148@gmail.com", + "homepage": "https://tymon.xyz", + "role": "Developer" + } + ], + "description": "JSON Web Token Authentication for Laravel and Lumen", + "homepage": "https://github.com/tymondesigns/jwt-auth", + "keywords": [ + "Authentication", + "JSON Web Token", + "auth", + "jwt", + "laravel" + ], + "support": { + "issues": "https://github.com/tymondesigns/jwt-auth/issues", + "source": "https://github.com/tymondesigns/jwt-auth" + }, + "time": "2026-03-06T09:50:45+00:00" + }, { "name": "vlucas/phpdotenv", "version": "v5.6.3", diff --git a/config/auth.php b/config/auth.php index fab0fa7..f92d4f0 100644 --- a/config/auth.php +++ b/config/auth.php @@ -14,7 +14,7 @@ return [ */ 'defaults' => [ - 'guard' => 'web', + 'guard' => 'api', 'passwords' => 'users', ], @@ -41,7 +41,7 @@ return [ 'provider' => 'users', ], 'api' => [ - 'driver' => 'sanctum', + 'driver' => 'jwt', 'provider' => 'users', ], ], @@ -66,7 +66,7 @@ return [ 'providers' => [ 'users' => [ 'driver' => 'eloquent', - 'model' => App\Models\User::class, + 'model' => App\Models\AdminUsers::class, ], // 'users' => [ diff --git a/config/jwt.php b/config/jwt.php new file mode 100644 index 0000000..f83234d --- /dev/null +++ b/config/jwt.php @@ -0,0 +1,301 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +return [ + + /* + |-------------------------------------------------------------------------- + | JWT Authentication Secret + |-------------------------------------------------------------------------- + | + | Don't forget to set this in your .env file, as it will be used to sign + | your tokens. A helper command is provided for this: + | `php artisan jwt:secret` + | + | Note: This will be used for Symmetric algorithms only (HMAC), + | since RSA and ECDSA use a private/public key combo (See below). + | + */ + + 'secret' => env('JWT_SECRET'), + + /* + |-------------------------------------------------------------------------- + | JWT Authentication Keys + |-------------------------------------------------------------------------- + | + | The algorithm you are using, will determine whether your tokens are + | signed with a random string (defined in `JWT_SECRET`) or using the + | following public & private keys. + | + | Symmetric Algorithms: + | HS256, HS384 & HS512 will use `JWT_SECRET`. + | + | Asymmetric Algorithms: + | RS256, RS384 & RS512 / ES256, ES384 & ES512 will use the keys below. + | + */ + + 'keys' => [ + + /* + |-------------------------------------------------------------------------- + | Public Key + |-------------------------------------------------------------------------- + | + | A path or resource to your public key. + | + | E.g. 'file://path/to/public/key' + | + */ + + 'public' => env('JWT_PUBLIC_KEY'), + + /* + |-------------------------------------------------------------------------- + | Private Key + |-------------------------------------------------------------------------- + | + | A path or resource to your private key. + | + | E.g. 'file://path/to/private/key' + | + */ + + 'private' => env('JWT_PRIVATE_KEY'), + + /* + |-------------------------------------------------------------------------- + | Passphrase + |-------------------------------------------------------------------------- + | + | The passphrase for your private key. Can be null if none set. + | + */ + + 'passphrase' => env('JWT_PASSPHRASE'), + + ], + + /* + |-------------------------------------------------------------------------- + | JWT time to live + |-------------------------------------------------------------------------- + | + | Specify the length of time (in minutes) that the token will be valid for. + | Defaults to 1 hour. + | + | You can also set this to null, to yield a never expiring token. + | Some people may want this behaviour for e.g. a mobile app. + | This is not particularly recommended, so make sure you have appropriate + | systems in place to revoke the token if necessary. + | Notice: If you set this to null you should remove 'exp' element from 'required_claims' list. + | + */ + + 'ttl' => env('JWT_TTL', 60), + + /* + |-------------------------------------------------------------------------- + | Refresh time to live + |-------------------------------------------------------------------------- + | + | Specify the length of time (in minutes) that the token can be refreshed + | within. I.E. The user can refresh their token within a 2 week window of + | the original token being created until they must re-authenticate. + | Defaults to 2 weeks. + | + | You can also set this to null, to yield an infinite refresh time. + | Some may want this instead of never expiring tokens for e.g. a mobile app. + | This is not particularly recommended, so make sure you have appropriate + | systems in place to revoke the token if necessary. + | + */ + + 'refresh_ttl' => env('JWT_REFRESH_TTL', 20160), + + /* + |-------------------------------------------------------------------------- + | JWT hashing algorithm + |-------------------------------------------------------------------------- + | + | Specify the hashing algorithm that will be used to sign the token. + | + */ + + 'algo' => env('JWT_ALGO', Tymon\JWTAuth\Providers\JWT\Provider::ALGO_HS256), + + /* + |-------------------------------------------------------------------------- + | Required Claims + |-------------------------------------------------------------------------- + | + | Specify the required claims that must exist in any token. + | A TokenInvalidException will be thrown if any of these claims are not + | present in the payload. + | + */ + + 'required_claims' => [ + 'iss', + 'iat', + 'exp', + 'nbf', + 'sub', + 'jti', + ], + + /* + |-------------------------------------------------------------------------- + | Persistent Claims + |-------------------------------------------------------------------------- + | + | Specify the claim keys to be persisted when refreshing a token. + | `sub` and `iat` will automatically be persisted, in + | addition to the these claims. + | + | Note: If a claim does not exist then it will be ignored. + | + */ + + 'persistent_claims' => [ + // 'foo', + // 'bar', + ], + + /* + |-------------------------------------------------------------------------- + | Lock Subject + |-------------------------------------------------------------------------- + | + | This will determine whether a `prv` claim is automatically added to + | the token. The purpose of this is to ensure that if you have multiple + | authentication models e.g. `App\User` & `App\OtherPerson`, then we + | should prevent one authentication request from impersonating another, + | if 2 tokens happen to have the same id across the 2 different models. + | + | Under specific circumstances, you may want to disable this behaviour + | e.g. if you only have one authentication model, then you would save + | a little on token size. + | + */ + + 'lock_subject' => true, + + /* + |-------------------------------------------------------------------------- + | Leeway + |-------------------------------------------------------------------------- + | + | This property gives the jwt timestamp claims some "leeway". + | Meaning that if you have any unavoidable slight clock skew on + | any of your servers then this will afford you some level of cushioning. + | + | This applies to the claims `iat`, `nbf` and `exp`. + | + | Specify in seconds - only if you know you need it. + | + */ + + 'leeway' => env('JWT_LEEWAY', 0), + + /* + |-------------------------------------------------------------------------- + | Blacklist Enabled + |-------------------------------------------------------------------------- + | + | In order to invalidate tokens, you must have the blacklist enabled. + | If you do not want or need this functionality, then set this to false. + | + */ + + 'blacklist_enabled' => env('JWT_BLACKLIST_ENABLED', true), + + /* + | ------------------------------------------------------------------------- + | Blacklist Grace Period + | ------------------------------------------------------------------------- + | + | When multiple concurrent requests are made with the same JWT, + | it is possible that some of them fail, due to token regeneration + | on every request. + | + | Set grace period in seconds to prevent parallel request failure. + | + */ + + 'blacklist_grace_period' => env('JWT_BLACKLIST_GRACE_PERIOD', 0), + + /* + |-------------------------------------------------------------------------- + | Cookies encryption + |-------------------------------------------------------------------------- + | + | By default Laravel encrypt cookies for security reason. + | If you decide to not decrypt cookies, you will have to configure Laravel + | to not encrypt your cookie token by adding its name into the $except + | array available in the middleware "EncryptCookies" provided by Laravel. + | see https://laravel.com/docs/master/responses#cookies-and-encryption + | for details. + | + | Set it to true if you want to decrypt cookies. + | + */ + + 'decrypt_cookies' => false, + + /* + |-------------------------------------------------------------------------- + | Providers + |-------------------------------------------------------------------------- + | + | Specify the various providers used throughout the package. + | + */ + + 'providers' => [ + + /* + |-------------------------------------------------------------------------- + | JWT Provider + |-------------------------------------------------------------------------- + | + | Specify the provider that is used to create and decode the tokens. + | + */ + + 'jwt' => Tymon\JWTAuth\Providers\JWT\Lcobucci::class, + + /* + |-------------------------------------------------------------------------- + | Authentication Provider + |-------------------------------------------------------------------------- + | + | Specify the provider that is used to authenticate users. + | + */ + + 'auth' => Tymon\JWTAuth\Providers\Auth\Illuminate::class, + + /* + |-------------------------------------------------------------------------- + | Storage Provider + |-------------------------------------------------------------------------- + | + | Specify the provider that is used to store tokens in the blacklist. + | + */ + + 'storage' => Tymon\JWTAuth\Providers\Storage\Illuminate::class, + + ], + +]; diff --git a/resources/lang/en/validation.php b/resources/lang/en/validation.php index 4ce60f2..191b646 100644 --- a/resources/lang/en/validation.php +++ b/resources/lang/en/validation.php @@ -5,7 +5,8 @@ return [ 'u_empty' => 'The username cannot be empty', 'p_empty' => 'Password cannot be empty', 'u_p_error' => 'Account or password error', - 'u_disabled' => 'Account has been disabled' + 'u_disabled' => 'Account has been disabled', + 'invalid' => 'Invalid Credentials' ], 'admin_user' => [ 'l_a_empty' => 'Login account cannot be empty', diff --git a/resources/lang/zh-CN/validation.php b/resources/lang/zh-CN/validation.php index 829d586..d611777 100644 --- a/resources/lang/zh-CN/validation.php +++ b/resources/lang/zh-CN/validation.php @@ -5,7 +5,8 @@ return [ 'u_empty' => '用户名不能为空', 'p_empty' => '密码不能为空', 'u_p_error' => '账号或密码错误', - 'u_disabled' => '账号已被禁用' + 'u_disabled' => '账号已被禁用', + 'invalid' => '无效的凭据' ], 'admin_user' => [ 'l_a_empty' => '登录账号不能为空', diff --git a/resources/lang/zh-TW/validation.php b/resources/lang/zh-TW/validation.php index b28f1f6..10e14c4 100644 --- a/resources/lang/zh-TW/validation.php +++ b/resources/lang/zh-TW/validation.php @@ -5,7 +5,8 @@ return [ 'u_empty' => '用戶名不能為空', 'p_empty' => '密碼不能為空', 'u_p_error' => '帳號或密碼錯誤', - 'u_disabled' => '帳號已被禁用' + 'u_disabled' => '帳號已被禁用', + 'invalid' => '無效的憑證' ], 'admin_user' => [ 'l_a_empty' => '登入帳號不能為空', diff --git a/routes/admin/api.php b/routes/admin/api.php index 7a3b958..2a95876 100644 --- a/routes/admin/api.php +++ b/routes/admin/api.php @@ -47,7 +47,6 @@ use App\Http\Controllers\Admin\ProhibitedPassageController; Route::group(['prefix' => 'admin'], function () { // 认证相关接口 Route::post('/login', [AuthController::class, 'login']); - Route::get('/isapi', [AuthController::class, 'isApi']); // get测试区