This controller is in charge of all of the actions relating to a user/users
Methods
# static check_username_exists()
Checks if a username exists in the databaase
Parameters:
Name | Type | Description |
---|---|---|
req.body.username |
* | username to check for |
# static facebook_auth()
Uses passport for authentication
# static facebook_auth_callback()
Callback after authentication, redirects user to previously set URI
# static get_user()
Returns the up-to-date data of the currently signed in user (or null if no user exist)
# static get_user_data(req)
Returns data regarding a specific requested user by username
Parameters:
Name | Type | Description |
---|---|---|
req.body.userId |
* | username of the user to search for |
req |
* |
# static google_auth()
Uses passport for authentication
# static google_auth_callback()
Callback after authentication, redirects user to previously set URI
# static isUserOnline(res)
Check if user is online
Parameters:
Name | Type | Description |
---|---|---|
req.body._id |
* | users id |
res |
* | contains true or false |
# static logout()
Logs the current user on the session out
# static searchUsers()
Searches user by a search string (looks at their username and various data) and what page to look in
Results are paginated to pages with 20 entries each
Parameters:
Name | Type | Description |
---|---|---|
req.body.searchString |
* | string to search in |
req.body.page |
* | what page of the results we are looking for |
# static setRedirectURL()
Sets the redirect URI for authentication calls to be the recieved uri
Take the data from the header (the referrer)
# static successRedirect()
This function redirect the caller to the redirect URI on the session
# static twitch_auth()
Uses passport for authentication
# static twitch_auth_callback()
Callback after authentication, redirects user to previously set URI
# static updateUserInterests(res)
Update user's points of interest
Parameters:
Name | Type | Description |
---|---|---|
req.body.userId |
* | id of user |
req.body.interests |
* | list of interests |
res |
* |
# static updateUserShortDescription(res)
Update user's profile description
Parameters:
Name | Type | Description |
---|---|---|
req.body.userId |
* | id of user |
req.body.shortDescription |
* | new description text |
res |
* |
# static user_login()
Tries to sign in a user with a given username and password
Redirects the user to the same page he previously was on
Parameters:
Name | Type | Description |
---|---|---|
req.body.username |
* | userName to login with |
req.body.password |
* | password tor login with |
if failed, a string describing the failure, otherwise the data of the user that signed in
# static user_signup()
Tries to register a custom user with given username , email and password
if succesful password is encrypted with bcrypt and user data is written to database
Parameters:
Name | Type | Description |
---|---|---|
req.body.username |
* | userName to register with |
req.body.email |
* | email to registerwith |
req.body.password |
* | password tor register with |