Back

[SOLVED] Access Database from Functions

  • 0
  • Functions
Binyamin
7 Jul, 2023, 05:00

This is what actually happened when you're contacting Appwrite using a function.

TL;DR
The user was looking for guidance on how to access a database from functions. They received advice on using the database to mark users as verified and checking the verification status on the frontend. It was also discussed how the function would return the response and update the database accordingly. The user questioned if it was possible for someone to manipulate the response to attain a false verified status, but it was explained that the database is the source of truth. The user also received guidance on best practices for handling sensitive information in functions. The solution was to use appwrite.json to store environment variables.
Binyamin
7 Jul, 2023, 05:00

the dashed line marked the sequential request

Aarush Acharya
7 Jul, 2023, 05:08

Okay thanks a lot would try using it like this also but what would happen if I directly put the variables there rather than putting them as environment variables also if project-based environment variables would be set that would help a lot

Aarush Acharya
7 Jul, 2023, 05:09

yes exactly that was what I was looking for

Binyamin
7 Jul, 2023, 05:09

In few functions I've put the values directly in the function

Binyamin
7 Jul, 2023, 05:10

Its usually just best practice to avoid putting sensitive information in a function that could be in Git or something like this

Aarush Acharya
7 Jul, 2023, 05:11

Alright I understand now why is it important to provide them, providing them only expands our scope of using Apwwrite in different ways.

Aarush Acharya
7 Jul, 2023, 05:13

Okay I Understand would try to use the best practices and would use appwrite.json to do so as you shared

Binyamin
7 Jul, 2023, 05:14

Exactly

Aarush Acharya
7 Jul, 2023, 05:15

thanks a lot for the guidance and help

Binyamin
7 Jul, 2023, 05:15

<a:agooglethumbsup:635256484682530825>

Aarush Acharya
7 Jul, 2023, 05:16

[SOLVED] Access Database from Functions

Aarush Acharya
7 Jul, 2023, 05:17

Also @Binyamin one last thing would like your guidance in

Aarush Acharya
7 Jul, 2023, 05:17

not related with this issue

Aarush Acharya
7 Jul, 2023, 05:17

Let us say I am using a function

Aarush Acharya
7 Jul, 2023, 05:17

to verify the otp

Binyamin
7 Jul, 2023, 05:18

Okay?

Aarush Acharya
7 Jul, 2023, 05:19

entered by the user rest of all the logic is handled and if the OTP matches the function returns "verified" and if a mismatch occurs it returns "not-verified"

Aarush Acharya
7 Jul, 2023, 05:23

let us say that the response returned was "not-verified" is it possible for someone (a user) to encrypt the "not-verified" response from the function to the frontend as "verified" in order to attain their hacky verified status

Binyamin
7 Jul, 2023, 05:26

From what I understand the function is returning the response right. Meaning that when the user is verified, you actually change something in the database, right? about the user.

If that's the case, it doesn't really matter what the user try to change it because the only source of truth is what the database have

Aarush Acharya
7 Jul, 2023, 05:29

Okay thanks a lot I got an Idea from your response, earlier wasn't using the data base would use the database to put the user as verified from the functions side only and then when the response returns would check at the frontend side using the database if the user is verified

Binyamin
7 Jul, 2023, 05:29

Exactly. That's sounds like a good approach

Aarush Acharya
7 Jul, 2023, 05:29

if it is verified then would proceed else would declare verifications unsuccessful;

Aarush Acharya
7 Jul, 2023, 05:29

thanks a lot

Aarush Acharya
7 Jul, 2023, 05:30

solved another potential issue

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more