验证用户并使用不同表中的凭据创建令牌

时间:2018-04-17 13:40:25

标签: php laravel api authentication jwt

我如何验证用户并为另一个表中的用户表和密码字段中的用户名字段创建jwt令牌?

 $credentials = [
        'phone' => $request->phone,
        'confirm.password' => $request->confirmation_code,
    ];
    try {
        // attempt to verify the credentials and create a token for the user
        if (! $token = JWTAuth::attempt($credentials)) {
            return response()->json(['state' => False, 'error' => 'Invalid Credentials.'], 401);
        }
    } catch (JWTException $e) {
        // something went wrong whilst attempting to encode the token
        return response()->json(['state' => False, 'error' => 'can not create token !'], 500);
    }

我的密码在确认表和密码字段中。与其模型中的确认表相关的用户表。

0 个答案:

没有答案