logologo
Get Started
Guide
Development
Plugins
API
English
简体中文
Get Started
Guide
Development
Plugins
API
English
简体中文
logologo
API Overview

@nocobase/auth

AuthManager
Auth
BaseAuth

@nocobase/cli

NocoBase CLI
Global Environment Variables

@nocobase/client

Application
Plugin

@nocobase/database

Collection
Field

interfaces

BaseInterface
Filter Operators

RelationRepository

BelongsToManyRepository
belongs-to-repository
HasManyRepository
HasOneRepository
Repository

shared

create-options
destroy-options
find-one
find-options
transaction
update-options

@nocobase/flow-engine

DataSourceManager
FlowContext
FlowEngine
FlowModel
FlowResource

@nocobase/server

AppCommand
Application
AuditManager
Context
Migration
Plugin

@nocobase/sdk

Auth
Storage
Previous PageAuthManager
Next PageBaseAuth

#Auth

#Overview

Auth is an abstract class for user authentication types. It defines the interfaces required to complete user authentication. To extend a new user authentication type, you need to inherit the Auth class and implement its methods. For a basic implementation, refer to: BaseAuth.

interface IAuth {
  user: Model;
  // Check the authenticaiton status and return the current user.
  check(): Promise<Model>;
  signIn(): Promise<any>;
  signUp(): Promise<any>;
  signOut(): Promise<any>;
}

export abstract class Auth implements IAuth {
  abstract user: Model;
  abstract check(): Promise<Model>;
  // ...
}

class CustomAuth extends Auth {
  // check: authentication
  async check() {
    // ...
  }
}

#Instance Properties

#user

Authenticated user information.

#Signature

  • abstract user: Model

#Class Methods

#constructor()

Constructor, creates an Auth instance.

#Signature

  • constructor(config: AuthConfig)

#Type

export type AuthConfig = {
  authenticator: Authenticator;
  options: {
    [key: string]: any;
  };
  ctx: Context;
};

#Details

#AuthConfig
PropertyTypeDescription
authenticatorAuthenticatorAuthenticator data model. The actual type in a NocoBase application is AuthModel.
optionsRecord<string, any>Authenticator-related configuration.
ctxContextRequest context.

#check()

User authentication. Returns user information. This is an abstract method that all authentication types must implement.

#Signature

  • abstract check(): Promise<Model>

#signIn()

User sign in.

#Signature

  • signIn(): Promise<any>

#signUp()

User sign up.

#Signature

  • signUp(): Promise<any>

#signOut()

User sign out.

#Signature

  • signOut(): Promise<any>