New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@3merge/express-auth-middleware

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@3merge/express-auth-middleware

Authentication middleware for Express APIs

  • 1.0.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
decreased by-85.71%
Maintainers
1
Weekly downloads
 
Created
Source

Authentication middleware

Work in progress!

The user model

Discriminating the user model, the preferred approach, assigns a kind property to all documents. I recommend using the decorator functions in this module to get/set properties in the base as well.

Schema

PropertyTypeDescriptionDefault
activebooleanSystem-generated to keep track of "deleted" userstrue
email*stringSelf-explanatorynull
firstName*stringSelf-explanatorynull
frozenbooleanSomewhat of an alias for active, only setting it does not affect other propertiesfalse
langstringThe preferred locale (en-CA or fr-CA).en-CA
lastName*stringSelf-explanatorynull
loginAttemptsnumberUsed to block excessive login attempts (< 5)0
passwordpasswordUsed to authenticatenull
secret*stringUsed to read and write JWT tokens. Nullifying this would destroy all active sessionsnull
verifiedbooleanRepresents the validity of an email address. Login attempts are blocked without verificationfalse

Methods

NameDescriptionReturn
await Model.findByEmail(string)Lookup active users by email addressobject
await Model.findUnverifiedByEmail(string)Lookup unverified users by emailobject
await Model.findVerifiedByEmail(string)Lookup verified users by emailobject
await Model.findVerifiedById(string)Lookup verified users by idobject
await doc.setSecret()Generate secret tokenobject
await doc.verifyPassword(string, boolean)Compare string against stored password. Throws error if second parameter is trueboolean
await doc.deactivate()Deletes a user for most intents-and-purposesobject
doc.isBlockedIs the user allowed to login?boolean
doc.hasExpiredHas more than 24 hours elapsed since requesting verification?boolean
doc.isPermittedDoes the user have all the necessary properties to login?boolean

FAQs

Package last updated on 18 Sep 2019

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc