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
- No server error on selfhosted appwrite
Please help me, my clients is ask what happen on their data? How can i make it up again?
- Upgrading selfhost version?
It is okay to upgrade version to higher one, of my current version is 1.7.4 to 1.8.1. Is that safe to do cause my clients already have data on that? Also is a...
- Local Serverless Function Testing: Are D...
I have followed the instructions to get the CLI working, and have been able to log-in, initialize my project, and created a simple Python function, which calls ...