wahyubucil / adonis-prisma

Prisma Provider for AdonisJS
MIT License
81 stars 9 forks source link

Token provider #6

Open WailRoth opened 1 year ago

WailRoth commented 1 year ago

In the readme, we understand how to implement prisma with auth. But for web api using token, what should be the config for the auth.ts for the token provider ? Thanks.

michaelcosj commented 1 year ago

This is what I used in my config

import type { AuthConfig } from "@ioc:Adonis/Addons/Auth";

const authConfig: AuthConfig = {
  guard: "api",
  guards: {
    api: {
      driver: "oat",
      tokenProvider: {
        type: "api",
        driver: "redis",
        redisConnection: "local",
        foreignKey: "user_id",
      },

      provider: {
        driver: "prisma",
        identifierKey: "id",
        uids: ["email"],
        model: "user",
      },
    },
  },
};

export default authConfig;