Skip to main content

API Reference

Register new user

  POST /api/auth/register
Body ElementTypeDescription
usernamestringRequired. Nickname of the new user
emailstringRequired. User's email
passwordstringRequired. User's password

Response

    {
"message":"User was registered successfully!"
}

Login existing user

  POST /api/auth/login
Body ElementTypeDescription
usernamestringRequired. Nickname of existing user
passwordstringRequired. 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
HeaderTypeDescription
x-access-tokenstringRequired. 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
HeaderTypeDescription
refreshTokenstringRequired. 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
ParameterTypeDescription
idstringRequired. Id of item to fetch
HeaderTypeDescription
x-access-tokenstringRequired. 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}
ParameterTypeDescription
idstringRequired. Id of item to fetch
HeaderTypeDescription
x-access-tokenstringRequired. 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 ElementTypeDescription
imiestringRequired. Name of the member
nazwiskostringRequired. Surname of the member
wyksztalceniestringRequired. Education of the member
peselnumberRequired. Pesel number of the member
wojewodztwostringRequired. Voivodeship of the member
miejscowoscstringRequired. City of the member
ulicastringRequired. Street of the member
nrdomulokalustringRequired. House number of the member
kodpocztowystringRequired. Zip code of the member
emailstringRequired. Email of the member
telstringRequired. Telephone number of the member
HeaderTypeDescription
x-access-tokenstringRequired. 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
}