Authentication
Get Account
GET
https://demo.getlynx.dev/api/auth/me
Cookies
{
"success": true,
"result":{
"id":"be8881ce-af01-433b-a675-fe02e8a48a88",
"username":"demo",
"email":"demo@example.com",
"role":"standard",
"secret":"uihJEIwC0jjGIF0BhZnY7xI90jN664La",
"totp": false,
}
}
Log In
POST
https://demo.getlynx.dev/api/auth/login
Request Body
// Returns set-cookie header set to JWT Session under "token"
{
"success": true,
"message": "Successfully logged in!",
}
{
"success": false,
"message": "2FA token required",
}
Register
POST
https://demo.getlynx.dev/api/auth/register
Request Body
{
"success": true,
"result": "Account created",
}
{
"success": false,
"message": "Invalid field(s)",
"details": {
"invalid": {
"email": false,
"username": false,
"password": true,
},
},
}
{
"success": false,
"message": "Field(s) are already used",
"details": {
"exists": {
"email": true,
"username": true,
"password": false,
},
},
}
Occurs when at least 1 account exists and ENABLE_REGISTRATION is set to false
Log Out
DELETE
https://demo.getlynx.dev/api/auth/me
Cookies
// Cookie token is cleared
{
"success": true,
"message": "Successfully logged out",
}
Two-Factor Authentication (2FA)
Get new TOTP token
GET
https://demo.getlynx.dev/api/auth/totp
Cookies
{
"success": true,
"message": "TOTP secret successfully generated",
"result":{
"secret": "H6NYN2R23UB6KGAC3O6TARUVN773MBWT",
"uri": "otpauth://totp/Lynx:admin?issuer=Lynx&secret=H6NYN2R23UB6KGAC3O6TARUVN773MBWT&algorithm=SHA1&digits=6&period=30"
}
}
Enable 2FA
POST
https://demo.getlynx.dev/api/auth/totp
Cookies
Request Body
{
"success": true,
"message": "2FA successfully enabled",
"result":{
"backupCodes": ["57E5ht9zD1d3", "6bllbg1122Qc", "76A7n7AHEm0r", "6VL2z2W151L5", "fQxPJJ6AYTu2", "S2uZ7A12k551"],
}
}
Disable 2FA
DELETE
https://demo.getlynx.dev/api/auth/totp
Cookies
Request Body
{
"success": true,
"message": "2FA has been successfully disabled",
}
Account Recovery
Recover Account
POST
https://demo.getlynx.dev/api/auth/totp/recover
Request Body
// Returns set-cookie header set to JWT Session under "token"
{
"success": true,
"message": "2FA has been disabled and you have been logged in",
}
Manual Recovery
If you didn't save your backup codes you will need to run the following commands in your mongodb container/instance
Connect to your database and enter your password:
mongosh --port 27017 --username user --authenticationDatabase admin
Switch to the lynx database:
Disable 2FA for your account's username:
db.accounts.findOneAndUpdate({ username: "user2" },{ $set:{ "totp.enabled":false } })
Account Information Management
Update Email
PATCH
https://demo.getlynx.dev/api/auth/email
Cookies
Request Body
{
"success": true,
"result": "Email successfully updated",
}
Update Password
PATCH
https://demo.getlynx.dev/api/auth/password
Cookies
Request Body
{
"success": true,
"result": "Password successfully updated",
}
Update Username
PATCH
https://demo.getlynx.dev/api/auth/username
Cookies
Request Body
{
"success": true,
"result": "Username successfully updated",
}
Other
Get new secret
POST
https://demo.getlynx.dev/api/auth/newSecret
{
"success": true,
"result":{
"secret": "uihJEIwC0jjGIF0BhZnY7xI90jN664La",
}
}