#[SOLVED] AppwriteException: The current user is not authorized to perform the requested action
73 messages · Page 1 of 1 (latest)
Where does this error show? In the Console, in your application? What were you trying to do?
Checked all are granted
What's the function you're using?
const { toast } = useToast();
const navigate = useNavigate();
const { checkAuthUser, isLoading: isUserLoading } = useUserContext();
// Query
const { mutateAsync: signInAccount, isLoading } = useSignInAccount();
const form = useForm<z.infer<typeof SigninValidation>>({
resolver: zodResolver(SigninValidation),
defaultValues: {
email: "",
password: "",
},
});
const handleSignin = async (user: z.infer<typeof SigninValidation>) => {
const session = await signInAccount(user);
if (!session) {
toast({ title: "Login failed. Please try again." });
return;
}
const isLoggedIn = await checkAuthUser();
if (isLoggedIn) {
form.reset();
navigate("/");
} else {
toast({ title: "Login failed. Please try again.", });
return;
}
};```
unable to login
Permission wise it looks good
yup
What function are you using that's triggering the error?
handleSignin
here is the same issue
That has no connection to your issue, as far as I can see
different is Vue vs react
see this
I don't see any function here called isLoggedIn? All I see is a var, which calls a function called checkAuthUser(). If that's what you're referring to, what does that function do? Could we please see that?
That isn't an error, it's a warning which you don't really need to worry about during development
It shouldn't have anything to do with the "not authorized to perform the requested action" error
oh
- Are Document Level Permissions enabled?
- Is it possible this Collection has a Relationship with another Collection which has different permissions?
yes i have other collections also and all having full permissions
Yes to which?
all are having all the permissions
Are Document Level Permissions enabled?
You still haven't answered what you're actually doing that's triggering this
yes all are enabled
And what permissions are set on the individual Documents?
btw what do you mean by document level i just know this
Inside each Document. These are the permissions on the Collection, but if you've enabled Document Level Permissions, the permissions are set by Document
...
firstly I'm log in where i getting this warning
and after directly login i'm creating post and posting that toDB
there i'm unable to post it to db getting this error
What's the code that you're using to do this?
using react query
try {
// Upload file to appwrite storage
const uploadedFile = await uploadFile(post.file[0]);
if (!uploadedFile) throw Error;
// Get file url
const fileUrl = getFilePreview(uploadedFile.$id);
if (!fileUrl) {
await deleteFile(uploadedFile.$id);
throw Error;
}
// Convert tags into array
const tags = post.tags?.replace(/ /g, "").split(",") || [];
// Create post
const newPost = await databases.createDocument(
appwriteConfig.databaseId,
appwriteConfig.postCollectionId,
ID.unique(),
{
creator: post.userId,
caption: post.caption,
imageUrl: fileUrl,
imageId: uploadedFile.$id,
location: post.location,
tags: tags,
}
);
if (!newPost) {
await deleteFile(uploadedFile.$id);
throw Error;
}
return newPost;
} catch (error) {
console.log(error);
}
}```
And where's the error being thrown?
yes here i'm getting error
Where?
console.log(error);
}```
You have this whole thing in a try catch block. What's actually throwing the error?
Huh. That's line 124?
no its line 149 in my editor
124 is const uploadedFile = await uploadFile(post.file[0]);
So what's uploadFile()?
after removing tag the error is gone
creator: post.userId,
caption: post.caption,
imageUrl: fileUrl,
imageId: uploadedFile.$id,
location: post.location,
// tags: tags,
}```
After removing a parameter from createDocument() the error on 124 is gone?!
That's... uh... not a function
try {
// Upload file to appwrite storage
const uploadedFile = await uploadFile(post.file[0]);
if (!uploadedFile) throw Error;
// Get file url
const fileUrl = getFilePreview(uploadedFile.$id);
if (!fileUrl) {
await deleteFile(uploadedFile.$id);
throw Error;
}
// Convert tags into array
const tags = post.tags?.replace(/ /g, "").split(",") || [];
// Create post
const newPost = await databases.createDocument(
appwriteConfig.databaseId,
appwriteConfig.postCollectionId,
ID.unique(),
{
creator: post.userId,
caption: post.caption,
imageUrl: fileUrl,
imageId: uploadedFile.$id,
location: post.location,
// tags: tags,
}
);
if (!newPost) {
await deleteFile(uploadedFile.$id);
throw Error;
}
return newPost;
} catch (error) {
console.log(error);
}
}``` this full function
after just removing this tags: tags,
// Update post
const updatedPost = await databases.updateDocument(
appwriteConfig.databaseId,
appwriteConfig.postCollectionId,
post.postId,
{
caption: post.caption,
imageUrl: image.imageUrl,
imageId: image.imageId,
location: post.location,
tags: tags,
}```
this was not working
Oh, is this not api.ts?
If your issue has been solved, you can close this post by adding “[SOLVED]” to the beginning of the title
No, to the title
AppwriteException: The current user is not authorized to perform the requested action [SOLVED]
To the beginning of the title
kkk