Home Reference Source
public class | source

EmailAuth

Extends:

Auth → EmailAuth

Email based login.

Requies passport-local package.

Constructor Summary

Public Constructor
public

constructor(options: object)

Member Summary

Public Members
public

If true, it remembers any passwords specified registration.

public

Name of application.

public

block: *

Settings for rate limiting failed requests.

public

Instance of crypt class for encrypting and verifying passwords.

public

Instance of email sender class for sending emails.

public

Email from address Used for sending email.

public

Settings for rate limiting through recaptcha.

Method Summary

Public Methods
public

async createProfileFromCredential(id: *, extra: {}): *

helper method that creates a profile object from a credential address

public

createUserFromProfile(profile: *): *

Override of helper method that inserts password into produced user if allowed by setting.

public

install(app: *, prefix: *, passport: *)

public

async passwordlessImpl(req: *, res: *): *

sends temporary login password to email address

public

sendTemporaryPassword(theme: string, to: string, password: string, expireMinutes: number, loginLinkPrefix: string): *

Helper method that sends temporary password to an email address for rego/login.

public

async strategyImpl(req: *, username: *, password: *, done: *)

logs users in based on token or based on username(email)/password

Inherited Summary

From class Auth
public

Additional settings given to passport.authenticate.

public

Custom fields

public

Default error message to return instead of actual errors (security).

public

Default roles new registered users should assume.

public

This is a standard descriptor of this authentication mechanism that is publicly shared.

public

method: *

Authentication method name.

public

users: CachedCollection

Users collection.

public

async createProfileFromCredential(id: *, extra: {}): *

helper method that creates a profile object from a credential address

public

createUserFromProfile(profile: Profile): User

Helper method that creates an User object from a Profile

public

findUser(value: string): User | false

Helper method that finds an user based on a credential.

public

generateId(): *

public

handleUserLoginByProfile(username: string, profile: Profile, done: Function, req: Request)

Helper method for SSO type logins.

public abstract

install(app: ExpressApplication, prefix: string, passport: Passport)

Must be overridden to provide implementation of said authentication method.

public

loggedIn(redirect: boolean): ExpressMiddleware

Helper method that produces a middleware to handle successful logged in case.

Public Constructors

public constructor(options: object) source

Override:

Auth#constructor

Params:

NameTypeAttributeDescription
options object

see Auth class + additional options for email configuration.

Public Members

public allowPasswordSettingDuringRegistration: * source

If true, it remembers any passwords specified registration.

public applicationName: string source

Name of application. Used for sending email.

public block: * source

Settings for rate limiting failed requests.

Note: use this or recaptcha.

public crypt: Crypt source

Instance of crypt class for encrypting and verifying passwords.

public emailSender: EmailSender source

Instance of email sender class for sending emails.

If this is not specified, email login is disabled.

public fromAddress: string source

Email from address Used for sending email.

public recaptcha: * source

Settings for rate limiting through recaptcha.

Note: use this or recaptcha.

Public Methods

public async createProfileFromCredential(id: *, extra: {}): * source

helper method that creates a profile object from a credential address

Override:

Auth#createProfileFromCredential

Params:

NameTypeAttributeDescription
id *
extra {}
  • optional
  • default: {}

Return:

*

public createUserFromProfile(profile: *): * source

Override of helper method that inserts password into produced user if allowed by setting.

Override:

Auth#createUserFromProfile

Params:

NameTypeAttributeDescription
profile *

Return:

*

public install(app: *, prefix: *, passport: *) source

Must be overridden to provide implementation of said authentication method.

Override:

Auth#install

Params:

NameTypeAttributeDescription
app *
prefix *
passport *

public async passwordlessImpl(req: *, res: *): * source

sends temporary login password to email address

Params:

NameTypeAttributeDescription
req *
res *

Return:

*

public sendTemporaryPassword(theme: string, to: string, password: string, expireMinutes: number, loginLinkPrefix: string): * source

Helper method that sends temporary password to an email address for rego/login.

Should be able to override this to specify custom formats for email.

Params:

NameTypeAttributeDescription
theme string

register | recover | passwordless etc. anything other than login or verify

to string

target email address

password string

temporary login token

expireMinutes number

number of minutes after which this login token will expire

loginLinkPrefix string
  • optional

forward url for any links in email

Return:

*

public async strategyImpl(req: *, username: *, password: *, done: *) source

logs users in based on token or based on username(email)/password

Params:

NameTypeAttributeDescription
req *
username *
password *
done *