I want to save the preferences of my users during the signup phase, like this:
email: 'user@example.com',
password: 'password',
data: {'userType': 'doctor'}, // other is patient
);
but account.create does not have the data property. I have two different users, how can I separate them when signing up or?
Hi @Hz.Bootlegger ,
you can handle such situation like this:
await account.create(
email: 'user@example.com',
password: 'password',
).then((response) async {
//! TODO: you will need to login the user.
//! before running `updatePrefs`.
await account.updatePrefs(
prefs: {'userType': 'doctor'},
);
return response;
}).then((response) {
/// do whatever you want todo with `response` returned from `account.create` here
});
that's how you can handle it on client side.
or you can create function using Server SDK that can handles user creation process including updating prefs for that user. and you can call that function using function URL on client side to create user instead of using account.create
from Appwrite SDK.
do you mean I'd open a session in between codebase but dont lead user to homepage as really logged in then update their pref and log out?
like fake session
yeah you can do it that way if you don't want to use function or server sdk, but I think that's not good way to approch it, you should use function approch instead.
server function replaces all account.create stuff ?
yes
you just need to send http POST request
to function URL
so its actually a rest
and function can handle the account.create & account.updatePrefs
functions can be executed via URLs as REST API.
okay I like it. Would you share the example link
you can get started with functions here: https://appwrite.io/docs/products/functions/quick-start
in this case the function I needed should be available for anyone but guests right?
or any is enough
guests is correct
for creating new user using server SDK in your function, refer this: https://appwrite.io/docs/references/cloud/server-nodejs/users#create
and for updating user's prefs using server SDK in function, refer this: https://appwrite.io/docs/references/cloud/server-nodejs/account#updatePrefs
Recommended threads
- Type Mismatch in AppwriteException
There is a discrepancy in the TypeScript type definitions for AppwriteException. The response property is defined as a string in the type definitions, but in pr...
- [SOLVED] OAuth With Google & Flutter
Hi all, I'm trying to sign in with google and it all goes swimmingly until the call back. I get a new user created on the appwrite dashboard however the flutte...
- What Query's are valid for GetDocument?
Documentation shows that Queries are valid here, but doesn't explain which queries are valid. At first I presumed this to be a bug, but before creating a githu...