Simple login module using the Java Spark Framework
When the API requires you to be logged in or if authentication fails in some way it will return a Status code of 401
.
If there is information missing in a request it will return a Status of 400
.
Internal errors will result in Status of 500
.
Request:
POST /sign-up
{
"username":"[email protected]",
"password":"test",
"info": "Hello World!"
}
Response:
Status: 200 OK
{}
Request:
POST /login
{
"username":"[email protected]",
"password":"test"
}
Response:
Status: 200 OK
{"session":"5b30b1a4-31db-46e4-b359-9e726ccb681b"}
This will either return the profile information or a 404
Request:
GET /profile/:user
Response:
Status: 200 OK
{
"username":"[email protected]",
"info":"Hello World!"
}
Request:
PUT /profile
{
"username":"[email protected]",
"new_info":"Father, Software Engineer",
"session":"5b30b1a4-31db-46e4-b359-9e726ccb681b"
}
Response:
Status: 200 OK
{}
This requires either a session or the current password of the user
PUT /password
{
"username":"[email protected]",
"new_password":"test1", "new_password_confirm": "test1",
"session":"5b30b1a4-31db-46e4-b359-9e726ccb681b"
}
Response:
Status: 200 OK
{}
Request:
DELETE /profile
{
"username":"[email protected]",
"password":"test",
"session":"5b30b1a4-31db-46e4-b359-9e726ccb681b"
}
Response:
Status: 200 OK
{}