小编crb*_*ast的帖子

JWT 令牌未保存在数据库中

用户认证返回token,但不保存在数据库中

验证控制器:

'use strict'

const User = use("App/Models/User");

class AuthController {
  async registrar({ request }) {
    const data = request.only(["username", "email", "password"]);

    const user = await User.create(data);

    return user;
  }

  async autenticar({ request, auth }) {
    const { email, password } = request.all();
    const retorno = {};
    let token;
    if (token = await auth.attempt(email, password)) {
      const user = await User.findBy('email', email)
      retorno.token = token.token;
      retorno.user = user.username;
      retorno.id = user.id;
    } else {
      retorno.data = "E-mail ou senha Incorretos"; …
Run Code Online (Sandbox Code Playgroud)

authentication jwt adonis.js

6
推荐指数
1
解决办法
1337
查看次数

标签 统计

adonis.js ×1

authentication ×1

jwt ×1