Solved the above error
But still the main issue persists
Have you edited the original permissions?
so remove this from the collection
wait let me do it
Ah then that is probably the issue
New error:
AppwriteException: Invalid permissions: Role "user" identifier value is invalid: Parameter must contain at most 36 chars. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char
What is your code your having with the imports?
import React, { useState } from 'react' import { v4 as uuidv4 } from 'uuid' import { databases } from '@/appwrite/appwrite' import { Permission, Role } from 'appwrite';
function TodoForm(userId) { const [todoItem, setTodoItem] = useState("") const data = { todoitem: todoItem }; console.log(data);
const handleSubmit = (e) => {
e.preventDefault()
const promise = databases.createDocument(
"DATABASE_ID",
"COLLECTION_ID",
uuidv4(),
data,
[
Permission.write(Role.user(userId)), // User can write this document
]
)
console.log(promise);
promise.then(
function (response) {
console.log(response);
// window.location.reload()
},
function (error) {
console.log(error);
// window.location.reload()
},
);
e.target.reset()
}
return (
<div className="max-w-7xl mx-auto mt-10 text-white">
<form
action=""
onSubmit={handleSubmit}
className="flex justify-center mb-10"
>
<input
type="text"
name=""
id=""
placeholder="Enter Todo"
className="border p-2 w-2/3 rounded-md text-black placeholder-gray-600"
onChange={(e) => {
setTodoItem(e.target.value)
}}
/>
<button
className="bg-pink-600 hover:bg-pink-700 p-2 text-white ml-2 rounded-md"
type="submit"
>
Add Todo
</button>
</form>
</div>
)
}
export default TodoForm
This is the code
check once
I think this needs to be update not write
I dont think permission write is a thing
there is
hmmm
Nvm ^_^
maybe log the userId?
see what it returns with
It returns the user id
Because here it says the user is wrong
But I'm just trying to add new todo
I sadly have not a clue why it returns that maybe wait for someone else?
Okay
Solved using <#1112060655072190464>
[SOLVED] Protect User's Data
Recommended threads
- Update User Error
```ts const { users, databases } = await createAdminClient(); const session = await getLoggedInUser(); const user = await users.get(session.$id); if (!use...
- apple exchange code to token
hello guys, im new here 🙂 I have created a project and enabled apple oauth, filled all data (client id, key id, p8 file itself etc). I generate oauth code form...
- Our Appwrite organization is suspended
Please give support regarding this , no app is working now , please solve my issue and give support , no one is replying in message section or email.