dinggo +jwt 写登录ap报错,请大家批评一下

错误

开发环境

用dinggo和jwt开发登录网页出现上述错误,php版本7.4,laravel框架。

项目代码


<?php
namespace Api\PrintCodeControllers;

use App\Models\User;
use App\Http\Requests\RegisterAuthRequest;
use Api\Controllers\BaseController;
use Illuminate\Http\Request;
use JWTAuth;
use Tymon\JWTAuth\Exceptions\JWTException;

class LoginController extends BaseController
{
    public function register(RegisterAuthRequest $request)
    {
        $user = new User();
        $user->username = $request->username;
        $user->password = bcrypt($request->password);
        $user->save();
    }
    public function login(Request $request)
    {
        $input = $request->only('username', 'password');
        $jwt_token = null;

        if(!$jwt_token = JWTAuth::attempt($input))
        {

            return response()->json([
                'success'=> false,
                'message'=> 'Invalid Username or Password',
            ],401);
        }
        return response()->json([
            'success' => true,
            'token' => $jwt_token,
        ]);
    }
}
《L03 构架 API 服务器》
你将学到如 RESTFul 设计风格、PostMan 的使用、OAuth 流程,JWT 概念及使用 和 API 开发相关的进阶知识。
《L02 从零构建论坛系统》
以构建论坛项目 LaraBBS 为线索,展开对 Laravel 框架的全面学习。应用程序架构思路贴近 Laravel 框架的设计哲学。
讨论数量: 3

相关配置没搞好?

3年前 评论
wangjun1995 (楼主) 3年前
wangjun1995 (楼主) 3年前

jwt加密的key貌似有问题

3年前 评论
wangjun1995 (楼主) 3年前
66
jwt:secret
3年前 评论

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!