Module

UserController

This controller is in charge of all of the actions relating to a user/users

View Source backend/controllers/userController.js, line 1

Methods

# static check_username_exists()

Checks if a username exists in the databaase
Parameters:
Name Type Description
req.body.username * username to check for

View Source backend/controllers/userController.js, line 135

# static facebook_auth()

Uses passport for authentication

View Source backend/controllers/userController.js, line 233

# static facebook_auth_callback()

Callback after authentication, redirects user to previously set URI

View Source backend/controllers/userController.js, line 240

# static get_user()

Returns the up-to-date data of the currently signed in user (or null if no user exist)

View Source backend/controllers/userController.js, line 108

# 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 *

View Source backend/controllers/userController.js, line 117

# static google_auth()

Uses passport for authentication

View Source backend/controllers/userController.js, line 217

# static google_auth_callback()

Callback after authentication, redirects user to previously set URI

View Source backend/controllers/userController.js, line 224

# static isUserOnline(res)

Check if user is online
Parameters:
Name Type Description
req.body._id * users id
res * contains true or false

View Source backend/controllers/userController.js, line 291

# static logout()

Logs the current user on the session out

View Source backend/controllers/userController.js, line 43

# 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

View Source backend/controllers/userController.js, line 160

# static setRedirectURL()

Sets the redirect URI for authentication calls to be the recieved uri Take the data from the header (the referrer)

View Source backend/controllers/userController.js, line 185

# static successRedirect()

This function redirect the caller to the redirect URI on the session

View Source backend/controllers/userController.js, line 193

# static twitch_auth()

Uses passport for authentication

View Source backend/controllers/userController.js, line 201

# static twitch_auth_callback()

Callback after authentication, redirects user to previously set URI

View Source backend/controllers/userController.js, line 208

# 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 *

View Source backend/controllers/userController.js, line 272

# 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 *

View Source backend/controllers/userController.js, line 252

# 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

View Source backend/controllers/userController.js, line 24

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

View Source backend/controllers/userController.js, line 58