s there anyway to change authentication main field from email to phone number and can i use fully custom authentication ?
@jmikrut 👀
hey there - you can certainly build you own authentication patterns
disableLocalStrategy: true
and then you are free to use any Passport-compatible auth strategy, or you can create your own
can you elaborate further to how can i do this exactly?
and thank you very much
@Bakry could this be of any help to you?
https://github.com/watscho/express-mongodb-rest-api-boilerplatethe thing is
im making a phone number/ password auth
Or maybe this because this is react based
https://github.com/ederssouza/reactjs-auth-boilerplateand i'm not sure how to do make a passport auth work with payload
Ahm, sorry but me neither, never needed it
But
It's surely possible to change the default with you own component
@Bakry
https://github.com/payloadcms/next-auth-frontend
Take a look at this and maybe you could rewrite it
If you are using next as frontend
Oh no wait, i don't know whether it will work with this
i am not unfortunately
tyty
idk how to implement it in the backend tbh
It needs quite of an aexperience as a developer to implement your own PassportJS auth strategies as it is stated in the docs as well, but it doesnt seem that difficult looking at PassportJS documentation to do so
yea it isn't that hard to make but the thing is
idk how to make it work with payload and payload admin
you'd just inject your own components into the login screen and make sure that your middleware properly authenticates a user via an HTTP-only cookie. If authenticated, you add the user to the
req.user
and then you're golden!
so if i make a token using jwt.sign
then set it in a cookie using setTokenCookie
and save my req.user as the current user
yep
that's basically all that Passport does really
the payload middleware authenticates my jwt automatically ?
it's just middleware that looks out for a cookie or a JWT header, and then decodes the JWT, and sets it to
req.user
No, if you are using a custom JWT, then Payload will not know to use it. It will be up to you to do that
what if i hook it up with ${payload.config.cookiePrefix}
as the token name
you will still need to make sure you use the same encryption that the passport-local-mongoose package uses
but it could be done
hmm can you elaborate more
yours truly is new to nodejs
aight i got some ideas i will try to implement and let you know if i run into any problems
I copied the strategy from the official payload repo
and in /login i made my own jwt using payload.secret
and set the cookie with payload.config.cookiePrefix-token
and set the req.user to the data i got
and its working somehow lmao
Star
Discord
online
Get help straight from the Payload team with an Enterprise License.