![Introducing Enhanced Alert Actions and Triage Functionality](https://cdn.sanity.io/images/cgdhsj6q/production/fe71306d515f85de6139b46745ea7180362324f0-2530x946.png?w=800&fit=max&auto=format)
Product
Introducing Enhanced Alert Actions and Triage Functionality
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.
@startupjs/auth-local
Advanced tools
Readme
import { LoginForm, RecoverForm, RegisterForm, ChangePasswordForm } from '@startupjs/auth-local' import Joi from '@hapi/joi' import { Button } from '@startupjs/ui'
@startupjs/auth: >= 0.33.0
text-encoding-polyfill: >= 0.6.7
In root index.js add:
import 'text-encoding-polyfill'
If you want to add reCaptcha for registration and password change forms, follow the instructions from documentation @startupjs/recaptcha and add the recaptchaEnabled
parameter in file server/index.js
:
initAuth(ee, {
// ...
recaptchaEnabled: true,
// ...
})
If you want to force users to confirm their email when they register, then specify next option confirmRegistration
with true
value
initAuth(ee, {
// ...
confirmRegistration: true, // Default: false
// ...
})
Prop name | Default value | Type | Purpouse |
---|---|---|---|
confirmEmailTimeLimit | 86400000 | number | A time limit im ms for email confirmation |
registrationConfirmedUrl | /auth/confirmed-email | string | Page url to inform a user about successful email confirmation |
Importing strategy:
import { Strategy as LocalStrategy } from '@startupjs/auth-local/server'
initAuth(ee, {
strategies: [
new LocalStrategy()
]
})
Form for login
import { LoginForm } from '@startupjs/auth-local'
Accepts props:
return <LoginForm />
Customization Props for customization:
properties
from ObjectInput, you can add new fields or override the standard onesfunction renderActions ({ onSubmit }) {
return pug`
Button(
style={ marginTop: 16 }
onPress=onSubmit
) Login
`
}
return pug`
LoginForm(
properties={
age: {
input: 'number',
label: 'Age',
placeholder: 'Enter your age'
}
}
validateSchema={
age: Joi.number()
.required()
.messages({
'any.required': 'Fill in the field',
'string.empty': 'Fill in the field'
})
}
renderActions=renderActions
)
`
Form for registration
import { RegisterForm } from '@startupjs/auth-local'
Accepts props:
return <RegisterForm />
Customization Props for customization:
properties
from ObjectInput, you can add new fields or override the standard onesfunction renderActions ({ onSubmit }) {
return pug`
Button(
style={ marginTop: 16 }
onPress=onSubmit
) Sign In
`
}
return pug`
RegisterForm(
properties={
age: {
input: 'number',
label: 'Age',
placeholder: 'Enter your age'
}
}
validateSchema={
age: Joi.number()
.required()
.messages({
'any.required': 'Fill in the field',
'string.empty': 'Fill in the field'
})
}
renderActions=renderActions
)
`
Password change form
import { RecoverForm } from '@startupjs/auth-local'
return <RecoverForm />
Helper-middleware, called before registration
initAuth(ee, {
// ...
strategies: [
new LocalStrategy({
onBeforeRegister: (req, res, next, opts) => {
console.log('onBeforeRegister')
next()
}
})
]
// ...
}
Helper-middleware, called after registration
initAuth(ee, {
// ...
strategies: [
new LocalStrategy({
onAfterRegister: ({ userId }, req) => {
console.log('onAfterRegister')
}
})
]
// ...
}
Helper-middleware, called before creating the password reset code
initAuth(ee, {
// ...
strategies: [
new LocalStrategy({
onBeforeCreatePasswordResetSecret: (req, res, done) => {
console.log('onBeforeCreatePasswordResetSecret')
const { email } = req.body
if (!email) return done('Missing email')
done(null, email)
}
})
]
// ...
}
Helper-middleware, called when creating a password reset code
initAuth(ee, {
// ...
strategies: [
new LocalStrategy({
onCreatePasswordResetSecret: ({ userId, secret }, req) => {
console.log('onCreatePasswordResetSecret')
}
})
]
// ...
}
Helper-middleware, called before password recovery
initAuth(ee, {
// ...
strategies: [
new LocalStrategy({
onBeforePasswordReset: (req, res, next) => {
console.log('onBeforePasswordReset')
next()
}
})
]
// ...
}
Helper-middleware, called after password recovery
initAuth(ee, {
// ...
strategies: [
new LocalStrategy({
onAfterPasswordReset: ({ userId }, req) => {
console.log('onAfterPasswordReset')
}
})
]
// ...
}
Helper-middleware, called before changing the password
initAuth(ee, {
// ...
strategies: [
new LocalStrategy({
onBeforePasswordChange: (req, res, next) => {
console.log('onBeforePasswordChange')
next()
}
})
]
// ...
}
Helper-middleware, called after changing the password
initAuth(ee, {
// ...
strategies: [
new LocalStrategy({
onAfterPasswordChange: ({ userId }, req) => {
console.log('onAfterPasswordChange')
}
})
]
// ...
}
Helper-middleware, called before confirmation registration process
initAuth(ee, {
// ...
strategies: [
new LocalStrategy({
onBeforeConfirmRegistration: (req, res, next) => {
console.log('onBeforeConfirmRegistration')
}
})
]
// ...
}
Helper-middleware, called before resend email confirmation
initAuth(ee, {
// ...
strategies: [
new LocalStrategy({
onBeforeResendConfirmation: (req, res, config, next) => {
console.log('onBeforeResendConfirmation')
}
})
]
// ...
}
Helper-middleware, called after confirmation a registration
initAuth(ee, {
// ...
strategies: [
new LocalStrategy({
sendRegistrationConfirmationComplete: (userId, next) => {
console.log('sendRegistrationConfirmationComplete')
}
})
]
// ...
}
Helper-middleware, implements confirmation a registration
initAuth(ee, {
// ...
strategies: [
new LocalStrategy({
confirmEmail: (model, userId, config, next) => {
console.log('confirmEmail')
}
})
]
// ...
}
Helper-middleware, called after registration and on resend confirmation email. You need override this middleware if confirmRegistration option is true
to send an email with confirmation link
initAuth(ee, {
// ...
strategies: [
new LocalStrategy({
sendRegistrationConfirmation: (req, userId, next) => {
console.log('sendRegistrationConfirmation')
}
})
]
// ...
}
FAQs
Local auth plugin for StartupJS auth module
The npm package @startupjs/auth-local receives a total of 78 weekly downloads. As such, @startupjs/auth-local popularity was classified as not popular.
We found that @startupjs/auth-local demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 6 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.
Security News
Polyfill.io has been serving malware for months via its CDN, after the project's open source maintainer sold the service to a company based in China.
Security News
OpenSSF is warning open source maintainers to stay vigilant against reputation farming on GitHub, where users artificially inflate their status by manipulating interactions on closed issues and PRs.