next-auth icon indicating copy to clipboard operation
next-auth copied to clipboard

Custom sign-in page for cognito with username and password sign-in

Open colin-riddell opened this issue 4 years ago • 6 comments

Question 💬

I am using the cognito provider, and up until now I've been quite happy with the UI that cognito provides. But now I want to implement my own UI for sign-up and sign-in. I'm a little confused by next-auth's support on "sign-in" with respect to a simple username and password sign-in flow.

For "sign-up" it's clear that next-auth doesn't support this, so I implemented sign-up by going directly to the cognito/amplify library. A little messier than I wanted, but no huge problem.. ✅

I then went to implement my custom sign-in page that allows username and password (just like like the cognito provided UI gives, but except within my own UI) but it seems that next-auth doesn't support this either? I can do signIn('cognito') which just forwards to the cognito hosted UI. But I can't see how to do something like signIn('cognito', {'username: 'usr', password: 'pass'}) <- for example?

The documentation for next-auth ( https://next-auth.js.org/configuration/pages#credentials-sign-in ) has a section for credentials sign in - but it's my understanding that if I'm using cognito I don't want or need to setup a credentials provider? or can cognito be used as a credentials provider?

Any and all help and advice is greatly appreciated.

How to reproduce ☕️

Nothing to reproduce really - just looking for advice.

Contributing 🙌🏽

Yes, I am willing to help answer this question in a PR

colin-riddell avatar Jul 07 '22 10:07 colin-riddell

Duplicate of #2525. See https://github.com/nextauthjs/next-auth/issues/2525#issuecomment-899569064

balazsorban44 avatar Jul 07 '22 11:07 balazsorban44

Hey @balazsorban44 - thanks for pointing that out.

So are you concluding that in response to my question:

custom sign-in page that allows username and password (just like like the cognito provided UI gives, but except within my own UI) but it seems that next-auth doesn't support this either?

That the answer is: no - signIn with username and password is not supported in any way by next-auth? Just want to make 100% sure.

Thanks

colin-riddell avatar Jul 07 '22 12:07 colin-riddell

It's supported through the Credentials provider https://next-auth.js.org/providers/credentials

balazsorban44 avatar Jul 07 '22 12:07 balazsorban44

Hey Colin, did you manage to implement Cognito as a provider with a custom page login? Thanks

zul-yang avatar Aug 25 '22 02:08 zul-yang

Hey @colin-riddell, @zul-yang, were you able to implement custom page for login and still using Cognito as a provider? Thanks in advance.

gopan-radian avatar Jul 24 '24 20:07 gopan-radian

For anyone looking for an example, I made this: https://github.com/jamaybyrone/Next-Auth-Custom-Cognito

jamaybyrone avatar Oct 27 '24 11:10 jamaybyrone