UserController - adkuba/TL-backend GitHub Wiki


Endpoints

Delete user

Path

DELETE /api/users/{username}

requires ROLE_ADMIN

Path variable

Variable Type Description
username String user's username

Response

HTTP Status Code Scenario
201 Ok user with all relations in database deleted

Get all users

Path

GET /api/users/all

requires ROLE_ADMIN

Response

HTTP Status Code Scenario
201 Ok all users returned

Returns List<UserResponse>.


Change email

Changes email based on jwt token.

Path

PUT /api/users/email

Request param

Parameter Type Description
email String new email

Response

HTTP Status Code Scenario
201 Ok email changed
400 Bad Request error

Create subscription

Path

POST /api/users/create-subscription

Request body

Subscription request

{
    "fullName": "Jakub Adamski",
    "username": "akuba",
    "paymentMethodId": "1", #Stripe
    "priceId": "1", #Stripe
}

Response

HTTP Status Code Scenario
201 Ok subscription created
400 Bad Request error

Returns Json subscription object from Stripe or String error message.


Cancel subscription

Cancels subscription based on jwt token username.

Path

POST /api/users/cancel-subscription

Response

HTTP Status Code Scenario
201 Ok subscription canceled

Returns Boolean, true if success.


Change name

Changes name based on jwt token username.

Path

PUT /api/users/name

Request param

Parameter Type Description
name String new name

Response

HTTP Status Code Scenario
201 Ok name changed
400 Bad Request error

Change password

Changes password based on jwt token username.

Path

PUT /api/users/password

Request body

Password reset request

{
    "oldPassword": "jdhweuifhd",
    "newPassword": "defrewg",
    "token": "defrag444f" #token send in email link
}

Response

HTTP Status Code Scenario
201 Ok password changed
400 Bad Request error

Check subscription

Check if user has valid premium subscription, based on jwt token. Makes changes in user's timelines and informations.

Path

GET /api/users/check-subscription

Response null


Get notifications

Notifications for requesting user - based on jwt token.

Path

GET /api/users/notifications

Response

HTTP Status Code Scenario
201 Ok notifications returned

Returns Notification and marks it as read.


Block user

Path

POST /api/users/block

Request params

Parameter Type Description
username String user to be blocked
reason String reason

WARNING ADD ADMIN ROLE REQUIREMENT

Response

HTTP Status Code Scenario
201 Ok user blocked

User now can't log in. Sends email with reason.


Unblock user

Path

POST /api/users/unblock

Request param

Parameter Type Description
username String user to be unblocked

Response

HTTP Status Code Scenario
201 Ok user unblocked

Check user

Path

GET /api/users/public/{username}

Path variable

Variable Type Description
username String user's username

Request param

Parameter Type Description
profile Boolean optional, if true counts as profile view

Response

HTTP Status Code Scenario
201 Ok user returned

Returns UserResponse.


Follow user

Follows, or unfollows if requesting user (jwt token) already is following.

Path

POST /api/users/{username}

Path variable

Variable Type Description
username String user to be followed

Response

HTTP Status Code Scenario
201 Ok user followed/unfollowed

Retuns new requesting user's followers List<InteractionEvent>