API Reference
Register new user
POST /api/auth/register
| Body Element | Type | Description |
|---|---|---|
username | string | Required. Nickname of the new user |
email | string | Required. User's email |
password | string | Required. User's password |
Response
{
"message":"User was registered successfully!"
}
Login existing user
POST /api/auth/login
| Body Element | Type | Description |
|---|---|---|
username | string | Required. Nickname of existing user |
password | string | Required. User's password |
Response
{
"id": "69fd67b4bff1edbb2e41d7a6",
"username": "example",
"email": "example@mail.com",
"roles": ["ROLE_ADMIN"],
"accessToken": "eyJhbGciOiJIUzI1NiJ9.eyJSb2xlIjoiQWRtaW4iLCJJc3N1ZXIiOiJJc3N1ZXIiLCJVc2VybmFtZSI6IkphdmFJblVzZSIsImV4cCI6MTY3ODM5ODkyNywiaWF0IjoxNjc4Mzk4OTI3fQ.GO7p6WBvhybRuXML37nutsLPWIx2TPT65XN2OSwhh8A",
"refreshToken": "9623f6b1-a2ed-7658-141b-56f40129387a"
}
Check if token is still valid
POST /api/auth/refreshtoken
| Header | Type | Description |
|---|---|---|
x-access-token | string | Required. Users current accessToken which is in request's header |
Response if token is valid
{
"message": "Authorized"
}
Error when user had not valid token in header
{
"message": "Unauthorized! Access Token was expired!"
}
Refresh token
POST /api/auth/refreshtoken
| Header | Type | Description |
|---|---|---|
refreshToken | string | Required. Existing refresh token from database linked to user, then returned in response as confirmation in addition to new access token |
Response
{
"accessToken": "eyJhbGciOiJIUzI1NiJ9.eyJSb2xlIjoiQWRtaW4iLCJJc3N1ZXIiOiJJc3N1ZXIiLCJVc2VybmFtZSI6IkphdmFJblVzZSIsImV4cCI6MTY3ODM5ODkyNywiaWF0IjoxNjc4Mzk4OTI3fQ.GO7p6WBvhybRuXML37nutsLPWIx2TPT65XN2OSwhh8A",
"refreshToken": "60bdcac2-6b8e-4c6c-bccb-1fcd1aa8afbb"
}
Error when user gave not existing token
{
"message": "This refresh token doesn't exist in database"
}
Get all NGO's members
GET /api/membership/members
| Parameter | Type | Description |
|---|---|---|
id | string | Required. Id of item to fetch |
| Header | Type | Description |
|---|---|---|
x-access-token | string | Required. Token obtained after login |
Response
[
{
"_id": "63da9d81c934680470087cd9",
"imie": "test",
"nazwisko": "member",
"wyksztalcenie": "Średnie",
"pesel": 77543187764,
"wojewodztwo": "Mazowieckie",
"miejscowosc": "Warszawa",
"ulica": "Przykładowa",
"nrdomulokalu": "5b",
"kodpocztowy": "72-978",
"email": "example@mail.com",
"tel": "768-895-832",
"__v": 0
}
]
Get NGO's member by id
GET /api/membership/members/${id}
| Parameter | Type | Description |
|---|---|---|
id | string | Required. Id of item to fetch |
| Header | Type | Description |
|---|---|---|
x-access-token | string | Required. Token obtained after login |
Response
{
"_id": "63da9d81c934680470087cd9",
"imie": "test",
"nazwisko": "member",
"wyksztalcenie": "Średnie",
"pesel": 77543187764,
"wojewodztwo": "Mazowieckie",
"miejscowosc": "Warszawa",
"ulica": "Przykładowa",
"nrdomulokalu": "5b",
"kodpocztowy": "72-978",
"email": "example@mail.com",
"tel": "768-895-832",
"__v": 0
}
Add new NGO's member
GET /api/membership/members
| Body Element | Type | Description |
|---|---|---|
imie | string | Required. Name of the member |
nazwisko | string | Required. Surname of the member |
wyksztalcenie | string | Required. Education of the member |
pesel | number | Required. Pesel number of the member |
wojewodztwo | string | Required. Voivodeship of the member |
miejscowosc | string | Required. City of the member |
ulica | string | Required. Street of the member |
nrdomulokalu | string | Required. House number of the member |
kodpocztowy | string | Required. Zip code of the member |
email | string | Required. Email of the member |
tel | string | Required. Telephone number of the member |
| Header | Type | Description |
|---|---|---|
x-access-token | string | Required. Token obtained after login |
Response
{
"imie": "test",
"nazwisko": "member",
"wyksztalcenie": "Średnie",
"pesel": 77543187764,
"wojewodztwo": "Mazowieckie",
"miejscowosc": "Warszawa",
"ulica": "Przykładowa",
"nrdomulokalu": "5b",
"kodpocztowy": "72-978",
"email": "example@mail.com",
"tel": "768-895-832",
"_id": "640a666fe85441ec60d63a6d",
"__v": 0
}