1.2.2 • Published 12 months ago

node_auth_module v1.2.2

Weekly downloads
58
License
SEE LICENSE IN LI...
Repository
github
Last release
12 months ago

node_auth_module

Authentication module using node_db_module

This uses the sequelize framework to provide an authentication frameowork to integrate with your application, using supported SQL OSBDs.

Import the db schema

mysql -u [user] -D [database] -p < sql/schema.sql

Configure credentials

The basic credentials structure is the following. They can be setup as a file in the root that is passed on when instancing the module. You can also send the JSON directly if you are storing the varibles as ENV variables. Ex: (...),password:proccess.env.PASSWORD,(...)

{
  "sql": {
    "host":"127.0.0.1", 
    "database":"yourdatabasename",
    "username":"yourusername",
    "password":"yourpassword",
    "dialect":"mysql",
    "logging":false,
    "timezone":"+00:00"
  },
  "seedDB":false,
  "seedMongoDB":false,
  "seedDBForce":true,
  "db":"sql"
}

Simple example

const Auth =  require('node_auth_module')
const authModule=new Auth(".config_auth.js")
  • .config_auth.js is the JSON file with the credentials this file should be in the root of your app. (Not of this required module) Then run one of the following functions

Authentication

register

  • type: async function
  • parameters: firstName,lastName,email,password,thirdparty

    • firstName (string)
    • lastName (string)
    • email (string)
    • password (sring)
    • thirdparty (boolean) optional
  • returns id (int)

    • The primary key (id) of the table User
  • return error

    • if there is some problem
  • Usage:

authModule.auth.register(firstName,lastName,email,password,thirdparty)

activateUser

  • type: async function
  • parameters: id

    • id (int)
  • returns ??

    • db model with update result
  • return error

    • if there is some problem (it should at least)
  • Usage:

authModule.auth.activateUser(id)

inactivateUser

banUser

unbanUser

isBanned

isActive

resetpassword

resetpassword(id)
  • type:asycn function
  • Returns: new password

validateLogin

validateLogin(email,password,callback,req,res)
  • type:async function
  • Returns: What every happens in the callback function. Generally used to set alternative response in case of error in callback. {action,path,payload}

getUserInfo

getUserMetadata

getIdFromEmail

hashPassword

listUsers

validateEmailConfirmationToken

validateEmailConfirmationToken(email,confirmationToken)
  • Validates the confirmation token belongs to the email user
  • parameters: email, confirmationToken
  • Returns: boolean ###setNewConfirmationToken
setNewConfirmationToken(id)

Generates a new confirmation token and stores it for the user.

  • Returns confirmation token

Session

saveSession

  • type: async function
  • parameters: user_id,ipv4,ipv6,platform,valid,city,country

    • user_id (int)
    • ipv4 (string)
    • ipv6 (string)
    • platform (sring)
    • valid (boolean)
    • city (string)
    • country (string)
  • returns id

    • if all goes well
  • return error

    • if there is some problem
  • Usage:

authModule.session.saveSession(user_id,ipv4,ipv6,platform,valid,city,country)

listSessions

  • type: async function
  • parameters: userId

  • returns (array)

    • List of all the session for the userId, the accessToken will not be present in the array
  • Usage:

authModule.session.listSessions(userId)

revokeSession

  • type: async function
  • parameters: id

    • id (int)
  • returns ??

    • update result
  • Usage:

authModule.session.revokeSession(id)

validateSession

  • type: async function
  • parameters: id,accessToken

    • id (int)
    • accessToken (string)
  • returns (boolean)

    • Valid or Not
  • Usage:

authModule.session.validateSession(id,accessToken)
1.2.0

12 months ago

1.1.7

12 months ago

1.2.2

12 months ago

1.2.1

12 months ago

1.1.1

1 year ago

1.1.0

1 year ago

1.1.6

1 year ago

1.1.5

1 year ago

1.1.4

1 year ago

1.1.3

1 year ago

1.1.2

1 year ago

1.0.11

4 years ago

1.0.10

4 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago