Home Reference Source
import Auth from '@osjs/server/src/auth.js'
public class | source

Auth

Authentication Handler

Constructor Summary

Public Constructor
public

constructor(core: Core, options: AuthOptions)

Creates a new instance

Member Summary

Public Members
public
public
public

Method Summary

Public Methods
public

Checks if login is allowed for this user

public

Tries to create home directory for a user

public

If the template is an array, it is a list of files that should be copied to the user's home directory

public

Creates user profile object

public

Destroys instance

public

async init(): Promise<boolean>

Initializes adapter

public

async login(req: Request, res: Response): Promise<undefined>

Performs a login request

public

async logout(req: Request, res: Response): Promise<undefined>

Performs a logout request

public

async register(req: Request, res: Response): Promise<undefined>

Performs a register request

Public Constructors

public constructor(core: Core, options: AuthOptions) source

Creates a new instance

Params:

NameTypeAttributeDescription
core Core

Core instance reference

options AuthOptions
  • optional
  • default: {}

Service Provider arguments

Public Members

public adapter: AuthAdapter source

public core: Core source

public options: AuthOptions source

Public Methods

public checkLoginPermissions(profile: AuthUserProfile): boolean source

Checks if login is allowed for this user

Params:

NameTypeAttributeDescription
profile AuthUserProfile

User profile

Return:

boolean

public async createHomeDirectory(profile: AuthUserProfile): Promise<undefined> source

Tries to create home directory for a user

Params:

NameTypeAttributeDescription
profile AuthUserProfile

User profile

Return:

Promise<undefined>

public async createHomeDirectoryFromArray(template: Object[], vfs: VFSServiceProvider, profile: AuthUserProfile) source

If the template is an array, it is a list of files that should be copied to the user's home directory

Params:

NameTypeAttributeDescription
template Object[]

Array of objects with a specified path, optionally with specified content but defaulting to an empty string

vfs VFSServiceProvider

An instance of the virtual file system

profile AuthUserProfile

User profile

public createUserProfile(fields: object, result: object): AuthUserProfile | boolean source

Creates user profile object

Params:

NameTypeAttributeDescription
fields object

Input fields

result object

Login result

public destroy() source

Destroys instance

public async init(): Promise<boolean> source

Initializes adapter

Return:

Promise<boolean>

public async login(req: Request, res: Response): Promise<undefined> source

Performs a login request

Params:

NameTypeAttributeDescription
req Request

HTTP request

res Response

HTTP response

Return:

Promise<undefined>

public async logout(req: Request, res: Response): Promise<undefined> source

Performs a logout request

Params:

NameTypeAttributeDescription
req Request

HTTP request

res Response

HTTP response

Return:

Promise<undefined>

public async register(req: Request, res: Response): Promise<undefined> source

Performs a register request

Params:

NameTypeAttributeDescription
req Request

HTTP request

res Response

HTTP response

Return:

Promise<undefined>