-
Notifications
You must be signed in to change notification settings - Fork 0
User
Provides access to login and register.
This endpoint lets user login.
Request body should contain JSON:
{
username: String,
password: String
}
Header | Value |
---|---|
Content-Type | application/json |
Status Code | 200 OK |
Response body contains User object:
{
token: String,
username: String
admin: Boolean
}
400 Bad Request
with error message "Invalid username or password": if given username and password combination does not exist.
This endpoint lets user register.
Request body should contain JSON with atleast fields username, password and email, but can also contain studentNumber and classGroup:
{
username: String,
password: String,
email: String
}
{
username: String,
password: String,
email: String
studentNumber: String,
classGroup: String
}
Header | Value |
---|---|
Content-Type | application/json |
Status Code | 200 OK |
400 Bad Request
: with error messages: "Käyttäjänimen tulee olla uniikki.": if given username of the new user is not unique.\
400 Bad Request
: with error messages: "Käyttäjänimen tulee olla vähintään 2 merkkiä pitkä.", if given field username
is less than 2 characters long.
400 Bad Request
: with error messages: "Käyttäjänimen tulee olla enintään 100 merkkiä pitkä.", if given field username
is more than 100 characters long.
400 Bad Request
: with error messages: "Käyttäjänimi on pakollinen.", if given field username
is empty.
400 Bad Request
: with error messages: "Salasana on pakollinen.", if given field password
is empty.
400 Bad Request
: with error messages: "Salasanan täytyy olla vähintään 3 merkkiä pitkä.", if given field password
is less than 3 characters long.
400 Bad Request
: with error messages: "Vuosikurssin tule alkaa merkeillä 'C-' ja loppua lukuun.", if given field classGroup
does not start with 'C-' and end with number.
400 Bad Request
: with error messages: "Sähköpostiosoite on pakollinen.", if given field email
is empty.
400 Bad Request
: with error messages: "Sähköpostiosoite on virheellinen.", if given field email
is not valid email address.
400 Bad Request
: with error messages: "Opiskelijanumeron tulee olla luku.", if given field studentNumber
is not number.
This endpoint return a list of users excluding one fetching them.
Header | Value |
---|---|
Content-Type | application/json |
Status Code | 200 OK |
Response body contains array of User objects:
[{
username: String,
admin: Boolean,
email: String
studentNumber: String,
classGroup: String
}]
401 Unauthorized
: with error message: "token missing or invalid" if current user is unauthorized.
This endpoint lets teacher (admin role) or user itself to remove User object and retuns a empty body.
Header | Value |
---|---|
Content-Type | application/json |
Status Code | 204 OK |
401 Unauthorized
: with error message: "token missing or invalid" if current user is unauthorized.
This endpoint lets teacher (admin role) to promote user to admin and retuns promoted User object.
Header | Value |
---|---|
Content-Type | application/json |
Status Code | 200 OK |
Response body contains User object:
{
username: String,
admin: Boolean,
email: String
studentNumber: String,
classGroup: String
}
401 Unauthorized
: with error message: "token missing or invalid" if current user is unauthorized.
400 Bad Request
: with error message: "Annettua käyttäjää ei löydy tietokannasta." if promoted user does not exist.
This endpoint lets teacher (admin role) to demote admin to user and retuns demoted User object.
Header | Value |
---|---|
Content-Type | application/json |
Status Code | 200 OK |
Response body contains User object:
{
username: String,
admin: Boolean,
email: String
studentNumber: String,
classGroup: String
}
401 Unauthorized
: with error message: "token missing or invalid" if current user is unauthorized.
400 Bad Request
: with error message: "Annettua käyttäjää ei löydy tietokannasta." if demoted user does not exist.