Example Support Auth Remix.js

Hi everyone, I'm trying to make a usage example for Remix.js Auth and theoretically it works but when I use the client methods it says I'm not authorized. https://remix.run/resources/remix-auth
Remix Auth | Remix Resources
Simple Authentication for Remix
No description
40 Replies
bekacru
bekacru5mo ago
can you describe the issue more? Were you able to sign in but not being able to reterive session?
Unknown User
Unknown User5mo ago
Message Not Public
Sign In & Join Server To View
Hola Soy Yigs
Hola Soy YigsOP5mo ago
:v I will leave this post closed since I overlooked that there was still no stable version and they changed many things about the API Hello, how are you, yes... I have been updating my test project to v1 for a while and my answer is correct, I can log in and log out normally, the problem lies when I want to use the administrator methods, such as obtaining the list of database users
Hola Soy Yigs
Hola Soy YigsOP5mo ago
No description
Hola Soy Yigs
Hola Soy YigsOP5mo ago
No description
Hola Soy Yigs
Hola Soy YigsOP5mo ago
auth.ts
No description
Hola Soy Yigs
Hola Soy YigsOP5mo ago
client.ts
No description
Hola Soy Yigs
Hola Soy YigsOP5mo ago
account login app
No description
Hola Soy Yigs
Hola Soy YigsOP5mo ago
No description
Hola Soy Yigs
Hola Soy YigsOP5mo ago
I am using the 2 parts of the client, it is assumed that with the administrator part if I am logged in I can bring that information that with the normal client does not have this feature
Unknown User
Unknown User5mo ago
Message Not Public
Sign In & Join Server To View
Hola Soy Yigs
Hola Soy YigsOP5mo ago
@Jeremy
No description
Hola Soy Yigs
Hola Soy YigsOP5mo ago
☝️ read more up
Unknown User
Unknown User5mo ago
Message Not Public
Sign In & Join Server To View
Hola Soy Yigs
Hola Soy YigsOP5mo ago
your whats database adapter using ? am using prisma adapter
Unknown User
Unknown User5mo ago
Message Not Public
Sign In & Join Server To View
Hola Soy Yigs
Hola Soy YigsOP5mo ago
:/ is a bug ?
bekacru
bekacru5mo ago
401 is only returned if the role !== "admin". please double check if the user you're logged in role is set to "admin" and there is no whitespace or anything.
Hola Soy Yigs
Hola Soy YigsOP5mo ago
No description
Hola Soy Yigs
Hola Soy YigsOP5mo ago
the role is admin
bekacru
bekacru5mo ago
and it still returns 401 when you try to list users?
Hola Soy Yigs
Hola Soy YigsOP5mo ago
yes
Hola Soy Yigs
Hola Soy YigsOP5mo ago
No description
Hola Soy Yigs
Hola Soy YigsOP5mo ago
it is my log
bekacru
bekacru5mo ago
can you check before you try to list users there is a valid session? either do getSession or useSession if you're on the client alos make sure you haven't changed adminRole in the admin config.
Hola Soy Yigs
Hola Soy YigsOP5mo ago
No description
Hola Soy Yigs
Hola Soy YigsOP5mo ago
No description
Hola Soy Yigs
Hola Soy YigsOP5mo ago
// the admin config
plugins: [
admin(),
organization(),
openAPI()
],
// the admin config
plugins: [
admin(),
organization(),
openAPI()
],
bekacru
bekacru5mo ago
this is cause you're trying to call authClient on the sevrer. meaning it can't read cookies. You should use auth.api and pass the header from the loader request object
Hola Soy Yigs
Hola Soy YigsOP5mo ago
@bekacru Hello, I think I also missed explaining that I am not using better-auth within the integrated remix server, since I am using a separate server, which I am using as an authentication provider for other applications. and the Better-Auth package only has the browser client as a consumer and no other server to provide services from.
Hola Soy Yigs
Hola Soy YigsOP5mo ago
No description
Hola Soy Yigs
Hola Soy YigsOP5mo ago
How the package proposes to do authentications through SSR applications ???
bekacru
bekacru5mo ago
then you can use authClient yuo just need to pass the headers to the authClient
authClient.getSession({
fetchOptions: {
headers: //pass headers
}
})
authClient.getSession({
fetchOptions: {
headers: //pass headers
}
})
Hola Soy Yigs
Hola Soy YigsOP5mo ago
No description
Hola Soy Yigs
Hola Soy YigsOP5mo ago
Hello everyone, @bekacru after several trial and error attempts I think that using the api and literally the remix of the remix.js headers to make a bypass between better-auth and the remix server, my solution at the moment to be able to use the better-auth authentication service was this thing a bit archaic since the better-auth-client is not able to return the response to be able to manipulate the request at will and avoid this code that It could be visually ugly 😛
Hola Soy Yigs
Hola Soy YigsOP5mo ago
No description
Hola Soy Yigs
Hola Soy YigsOP5mo ago
his taking into account that we want to manage everything on the server side
Unknown User
Unknown User5mo ago
Message Not Public
Sign In & Join Server To View
Hola Soy Yigs
Hola Soy YigsOP5mo ago
Hello, how are you, I understand your point but in this case if we pay attention to the detail the cookie is being saved with a "__session" tag which is the REMIX AUTH standard, what happened is that in a moment of madness I tried to remix these authentication methods, which was not possible since they both established the tokens in their own way, for that reason I discarded remix-auth and took a more manual approach for verification of sessions making redundancy a remix of the headers y better-auth I understand your point of view on how I could interconnect applications through tokenization strategies or similar, but I also find it interesting how these implementations would work directly from the server side, either for some use case (like mine), or directly mere curiosity

Did you find this page helpful?