1.2.2 • Published 23 days ago

express-usercontrols v1.2.2

Weekly downloads
-
License
ISC
Repository
-
Last release
23 days ago

express-usercontrols

====================

express-usercontrols is a module that interacts with express, to streamline login, payment and phone number verification while interacting with a mongoDB server to efficiently store all user information.

Setup

Full documentation + setup at https://tableflipped.xyz?project=express-usercontrols-1-2

  1. Install mongoDB community edition server and mongoDB compass `>Create a new database with a name of your choice, and then 2 new collections. There MUST be a collection called users to store all user data, and a collection called codes if you are using ANY stripe billing functions

  2. $ npm install express-usercontrols

  3. Get oauth2 credentials (get the client ID and the client secret), and set the redirect URI to: server-url/auth/provider-name/callback, for example https://tableflipped.xyz/auth/discord/callback. This module supports oauth2 for discord, microsoft, google, github and other providers listed to work with passportjs`.
  4. Start express-usercontrols. (For uneccessary fields enter null) const usercontrols = require("express-usercontrols") usercontrols.initialise(config)
  5. Enter the oauth2 credentials into their respective functions.
    usercontrols.discord_oauth2(clientId, clientSecret) usercontrols.google_oauth2(clientId, clientSecret) usercontrols.github_oauth2(clientId, clientSecret) usercontrols.microsoft_oauth2(clientId, clientSecret)

  6. Set up email/password login usercontrols.local_auth(validate_email, default_mfa, auth_route, secret)

  7. Set up sms verification with twilio/TWverify (optional) usercontrols.sms_verify(authroute,authrouteverify,accountSid,authToken,verifySid, trial_balance)

Your express app should now be set up with express-usercontrols! You can now...

  1. Validate hcaptcha-protected forms from routes (optional)
    app.post('/verify', validatecaptcha, async(req, res) =>{})
  2. Check that a user is logged in and is unbanned on selected routes, and return their up-to-date user object in req.session.user. Optionally requiring them to have verified their phone number
    app.get('/dashboard', determineuser(true), async(req, res) =>{}) determineuser(verified_phone_number_required)

Full documentation + setup at https://tableflipped.xyz?project=express-usercontrols-1-1-1