Accounts

Authentication

Get Account

GET https://demo.getlynx.dev/api/auth/me

Headers

NameTypeDescription

Authorization

String

Your API key

Cookies

NameTypeDescription

token

String

Your JWT Session

{
    "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

NameTypeDescription

username*

String

password*

String

token

String

2FA Token

// Returns set-cookie header set to JWT Session under "token"
{
    "success": true,
    "message": "Successfully logged in!",
}

Register

POST https://demo.getlynx.dev/api/auth/register

Request Body

NameTypeDescription

username*

String

password*

String

email*

String

{
    "success": true,
    "result": "Account created",
}

Log Out

DELETE https://demo.getlynx.dev/api/auth/me

Cookies

NameTypeDescription

token*

String

Your JWT Session

// 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

NameTypeDescription

token

String

Your JWT Session

{
    "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

NameTypeDescription

token

String

Your JWT Session

Request Body

NameTypeDescription

token*

String

2FA Token

{
    "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

NameTypeDescription

token

String

Your JWT Session

Request Body

NameTypeDescription

token

String

2FA Token

{
    "success": true,
    "message": "2FA has been successfully disabled",
}

Account Recovery

Recover Account

POST https://demo.getlynx.dev/api/auth/totp/recover

Request Body

NameTypeDescription

backupCode*

String

password*

String

username*

String

// 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:

use shortener

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

NameTypeDescription

token*

String

Your JWT Session

Request Body

NameTypeDescription

newEmail*

String

password*

String

token

String

2FA Token (If Enabled)

{
    "success": true,
    "result": "Email successfully updated",
}

Update Password

PATCH https://demo.getlynx.dev/api/auth/password

Cookies

NameTypeDescription

token*

String

Your JWT Session

Request Body

NameTypeDescription

password*

String

newPassword*

String

token

String

2FA Token (If Enabled)

{
    "success": true,
    "result": "Password successfully updated",
}

Update Username

PATCH https://demo.getlynx.dev/api/auth/username

Cookies

NameTypeDescription

token*

String

Your JWT Session

Request Body

NameTypeDescription

newUsername*

String

password*

String

token

String

2FA Token (If Enabled)

{
    "success": true,
    "result": "Username successfully updated",
}

Other

Get new secret

POST https://demo.getlynx.dev/api/auth/newSecret

{
    "success": true,
    "result":{
        "secret": "uihJEIwC0jjGIF0BhZnY7xI90jN664La",
    }
}

Last updated