NbPasswordAuthStrategy
The most common authentication provider for email/password strategy.
Strategy settings. Note, there is no need to copy over the whole object to change the settings you need.
Also, this.getOption call won't work outside of the default options declaration
(which is inside of the NbPasswordAuthStrategy
class), so you have to replace it with a custom helper function
if you need it.
export class NbPasswordAuthStrategyOptions extends NbAuthStrategyOptions {
name: string;
baseEndpoint? = '/api/auth/';
login?: boolean | NbPasswordStrategyModule = {
alwaysFail: false,
endpoint: 'login',
method: 'post',
requireValidToken: true,
redirect: {
success: '/',
failure: null,
},
defaultErrors: ['Login/Email combination is not correct, please try again.'],
defaultMessages: ['You have been successfully logged in.'],
};
register?: boolean | NbPasswordStrategyModule = {
alwaysFail: false,
endpoint: 'register',
method: 'post',
requireValidToken: true,
redirect: {
success: '/',
failure: null,
},
defaultErrors: ['Something went wrong, please try again.'],
defaultMessages: ['You have been successfully registered.'],
};
requestPass?: boolean | NbPasswordStrategyModule = {
endpoint: 'request-pass',
method: 'post',
redirect: {
success: '/',
failure: null,
},
defaultErrors: ['Something went wrong, please try again.'],
defaultMessages: ['Reset password instructions have been sent to your email.'],
};
resetPass?: boolean | NbPasswordStrategyReset = {
endpoint: 'reset-pass',
method: 'put',
redirect: {
success: '/',
failure: null,
},
resetPasswordTokenKey: 'reset_password_token',
defaultErrors: ['Something went wrong, please try again.'],
defaultMessages: ['Your password has been successfully changed.'],
};
logout?: boolean | NbPasswordStrategyReset = {
alwaysFail: false,
endpoint: 'logout',
method: 'delete',
redirect: {
success: '/',
failure: null,
},
defaultErrors: ['Something went wrong, please try again.'],
defaultMessages: ['You have been successfully logged out.'],
};
refreshToken?: boolean | NbPasswordStrategyModule = {
endpoint: 'refresh-token',
method: 'post',
requireValidToken: true,
redirect: {
success: null,
failure: null,
},
defaultErrors: ['Something went wrong, please try again.'],
defaultMessages: ['Your token has been successfully refreshed.'],
};
token?: NbPasswordStrategyToken = {
class: NbAuthSimpleToken,
key: 'data.token',
getter: (module: string, res: HttpResponse<Object>, options: NbPasswordAuthStrategyOptions) => getDeepFromObject(
res.body,
options.token.key,
),
};
errors?: NbPasswordStrategyMessage = {
key: 'data.errors',
getter: (module: string, res: HttpErrorResponse, options: NbPasswordAuthStrategyOptions) => getDeepFromObject(
res.error,
options.errors.key,
options[module].defaultErrors,
),
};
messages?: NbPasswordStrategyMessage = {
key: 'data.messages',
getter: (module: string, res: HttpResponse<Object>, options: NbPasswordAuthStrategyOptions) => getDeepFromObject(
res.body,
options.messages.key,
options[module].defaultMessages,
),
};
validation?: {
password?: {
required?: boolean;
minLength?: number | null;
maxLength?: number | null;
regexp?: string | null;
};
email?: {
required?: boolean;
regexp?: string | null;
};
fullName?: {
required?: boolean;
minLength?: number | null;
maxLength?: number | null;
regexp?: string | null;
};
};
}
Previous page
NbOAuth2AuthStrategy
Next page
Need some help or found an issue?
Ask on Stack Overflow with tag `nebular` or post an issue on GitHub.