Skip to content
This repository has been archived by the owner on Jul 16, 2022. It is now read-only.

Demo to create user profile document upon a new user account creation… #289

Conversation

gireeshp
Copy link
Contributor

… - issue#288

@gireeshp
Copy link
Contributor Author

This PR is for issue #288

@gireeshp
Copy link
Contributor Author

@eldadfux @adityaoberai - can you review this?

Copy link
Contributor

@Meldiron Meldiron left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requested a few changes

from appwrite.client import Client
from appwrite.services.database import Database

user_collection_id = "617497ffb09f7"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's store this in environment variable as it changes for everyone.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Comment on lines 1 to 10
## Introduction
This function will be triggered at the new user account creation event. This will create the 'users' collection with the newly registered user's profile information.

## Steps
* Run below code to:
* Point PIP target to .appwrite directory in the current working directory
* Install appwrite library from requirements.txt
```
PIP_TARGET=./.appwrite pip3 install -r ./requirements.txt --upgrade --ignore-installed
```
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's use readme file from some of the existing functions and let's stick to it's structure.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@gireeshp
Copy link
Contributor Author

gireeshp commented Nov 2, 2021

Hi @Meldiron - suggested changes are implemented. Please take a look.

client = init_client()
database = Database(client)

database.create_document(user_collection_id, {'user_id': userId, 'user_name': userName, 'email': email}, read=['*'], write=['*'])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's give write permissions only to the user, otherwise hackers would remove them all 😅

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @Meldiron - removed the wildcard write permission.

As discussed with @Meldiron, keeping the access permission to "anyone to read" and "only owner to write".
@gireeshp
Copy link
Contributor Author

Hello @Meldiron - can you check this pls?

Copy link
Contributor

@Meldiron Meldiron left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me

@Meldiron Meldiron merged commit 670129c into appwrite:master Nov 15, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
2 participants