AuthController

AuthController handle with login and signup process.

Methods

private, inner _generateToken(data) → {json}

Receive a Mongoose Object Scheme of User type and generates a new JWT Token.
Parameters:
Name Type Description
data object models\schemes\UserModel Object.
Returns:
json - json containing => { acess_token: "", token_type: "" }.
To Do:
  • Write comments

inner login(req, res) → {json}

Login method. Responds to POST /auth/login. If Success returns 200 status code, user-object and token-header => { acess_token: "", token_type: "" }. If error return 403 status code and message of invalid credentials => { errors }. 500 status code only will be returned if the method generates some unexpected error.
Parameters:
Name Type Description
req object Express requisition object.
res object Express response object.
Returns:
json - status and return object.

inner signup(req, res) → {json}

Signup method. Responds to POST /auth/signup. If Success returns 201 status code, user-object and token-header => { acess_token: "", token_type: "" }. If error return 400 status code and a object => { errors }. 500 status code only will be returned if the method generates some unexpected error.
Parameters:
Name Type Description
req object Express requisition object.
res object Express response object.
Returns:
json - status and return object.
To Do:
  • Refactor this method breaking him in 2. One for student signup and another for teacher signup.