brilliant-orangeB
Refine2y ago
11 replies
brilliant-orange

How do I send with admin ID?

import { AuthBindings } from '@refinedev/core'
import nookies from 'nookies'

const mockUsers = [
  {
    id: 1,
    email: 'admin@test.com',
    password: 'admin',
    roles: ['admin'],
  },
  {
    id: 2,
    email: 'editor@test.com',
    password: 'admin',
    roles: ['editor'],
  },
  {
    id: 3,
    email: 'demo@test.com',
    password: 'admin',
    roles: ['demo'],
  },
]

export const authProvider: AuthBindings = {
  login: async ({ email, password }) => {
    // Suppose we actually send a request to the back end here.
    const user = mockUsers.find((item) => item.email === email && item.password === password)

    if (user) {
      nookies.set(null, 'auth', JSON.stringify(user), {
        maxAge: 30 * 24 * 60 * 60,
        path: '/',
      })
      return {
        success: true,
        redirectTo: '/',
      }
    }

    return {
      success: false,
      error: {
        message: 'Login failed',
        name: 'Invalid email or password',
      },
    }
  },

provider this code. I want when API call send with admi Id
Was this page helpful?