📘
Lynx
GitHub
  • Welcome
  • Installation
    • Installation
      • Native
      • Docker
    • Post Installation
    • Environment Variables
  • Guides
    • Backups
  • API
    • Using the API
    • API Reference
      • Accounts
      • Users
      • Links
      • Import
      • Export
      • About
      • ShareX
  • Roadmap
Powered by GitBook
On this page
  • Authentication
  • Get Account
  • Log In
  • Register
  • Log Out
  • Two-Factor Authentication (2FA)
  • Get new TOTP token
  • Enable 2FA
  • Disable 2FA
  • Account Recovery
  • Recover Account
  • Account Information Management
  • Update Email
  • Update Password
  • Update Username
  • Other
  • Get new secret

Was this helpful?

Edit on GitHub
  1. API
  2. API Reference

Accounts

Authentication

Get Account

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

Headers

Name
Type
Description

Authorization

String

Your API key

Cookies

Name
Type
Description

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

Name
Type
Description

username*

String

password*

String

token

String

2FA Token

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

Name
Type
Description

username*

String

password*

String

email*

String

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

Name
Type
Description

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

Name
Type
Description

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

Name
Type
Description

token

String

Your JWT Session

Request Body

Name
Type
Description

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

Name
Type
Description

token

String

Your JWT Session

Request Body

Name
Type
Description

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

Name
Type
Description

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

Name
Type
Description

token*

String

Your JWT Session

Request Body

Name
Type
Description

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

Name
Type
Description

token*

String

Your JWT Session

Request Body

Name
Type
Description

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

Name
Type
Description

token*

String

Your JWT Session

Request Body

Name
Type
Description

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 1 year ago

Was this helpful?