Diagram
  • Introduction
  • Get Started
    • Hello World
    • Connecting to a DB
    • From a template
  • Concepts
    • Endpoints
    • Algorithm
  • Nodes
    • Bcrypt
    • Code
    • Constant
    • Database
    • EasyDB
    • Firestore
    • If / Then
    • Request
    • Response
    • JWT
    • Mapper
    • MongoDB
    • Stripe
    • Webhook
  • Templates
    • Login
    • Register
    • Get User
  • Resources
    • Dashboard
    • Contact
    • FAQs
Powered by GitBook
On this page

Was this helpful?

  1. Get Started

From a template

PreviousConnecting to a DBNextEndpoints

Last updated 3 years ago

Was this helpful?

Register Template

This endpoint will create a user in our hosted Firestore database. It will get the user's document from the "users" collection, check their password and if the password is correct return an authentication token for the user.

This endpoint can act as a guide for creating a register endpoint with your own Firestore instance or with the other databases we support ie. MongoDB and EasyDB (and soon Postgres)

To set it up:‌

  1. Drag and drop a mongodb node and click on it to open the settings.

  2. Head to https://www.ondiagram.com/app, click "From Template" and select "Register".

  3. Right after, click on JWT node to open the settings. If that's the first time you are viewing the settings of a JWT node for this Diagram project, you will be asked for a secret key to encrypt tokens with.

  4. To test out the endpoint open the debug panel. Click on the "Body" tab and add two properties to the body of the request, the first should be "email" and the second "password" with values for a new user.

  5. Click "Run" and Diagram will create a new user for you and return their token.

  6. This endpoint can also be called from a frontend or in another nocode app in a similarly but remember to set the request to POST.

After setting up the "Register" endpoint you can create a "Login" endpoint for the same users. To do that click on "From Template" and click "Login". The JWT settings are already set so everything is good to test the endpoint out. So, open the debug panel and add the same email and password to the HTTP body parameters and hit "Run". If the credentials are correct it will return the user's authentication token, otherwise will will return a 401 if the password is wrong or a 404 if the user is not found.