Rank 3: Container
Solved the above error
Votes
0
Replies
24
Participants
Unknown
Messages
25
Rank 3: Container
Solved the above error
Rank 3: Container
But still the main issue persists
Rank 3: Container
Have you edited the original permissions?
Rank 3: Container
so remove this from the collection
Rank 3: Container
wait let me do it
Rank 3: Container
Ah then that is probably the issue
Rank 3: Container
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
Rank 3: Container
What is your code your having with the imports?
Rank 3: Container
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
Rank 3: Container
This is the code
Rank 3: Container
check once
Rank 3: Container
I think this needs to be update not write
Rank 3: Container
I dont think permission write is a thing
Rank 3: Container
there is
Rank 3: Container
hmmm
Rank 3: Container
Nvm ^_^
Rank 3: Container
maybe log the userId?
Rank 3: Container
see what it returns with
Rank 3: Container
It returns the user id
Rank 3: Container
Because here it says the user is wrong
Rank 3: Container
But I'm just trying to add new todo
Rank 3: Container
I sadly have not a clue why it returns that maybe wait for someone else?
Rank 3: Container
Okay
Rank 3: Container
Solved using [SOLVED] Viewing document based on user's ID
Rank 3: Container
[SOLVED] Protect User's Data