https://supertokens.com/ logo
k

KalibCheil

03/30/2022, 1:24 PM
Hi, I have a question. I am creating a login for a company dashboard. Right now anybody can sign up and sign in, but I want that the user account has to be approved (just one time) before to log in. Is there a way to do it. I am using email and password authentication
r

rp

03/30/2022, 1:25 PM
So will you be creating the user's account + adding some password for them manually before? Or just allowing whitelisted emails to sign up?
k

KalibCheil

03/30/2022, 1:25 PM
just allowing whitelisted emails to sign up
r

rp

03/30/2022, 1:26 PM
you can do that by overriding the sign up API and before calling the original implementation, check if the input email is whitelisted or not
checkout advanced customisation > API override section
k

KalibCheil

03/30/2022, 2:02 PM
Thank you
That was the solution
g

gidgiddoni

08/29/2022, 10:13 PM
@KalibCheil Did you override the frontend or backend to implement this? If you have a snippet to share I would appreciate it
r

rp

08/30/2022, 2:22 AM
@gidgiddoni you need to override then backend’s signUp function.
g

gidgiddoni

08/30/2022, 3:06 AM
@KalibCheil Thanks for responding! I have this on my backend config but it doesn't seem to be doing anything. Is there something I am missing? https://gist.github.com/GideonStowell/0fd02235264bf64edc0af502c111d58b
r

rp

08/30/2022, 3:24 AM
Can you add a console log in that function and see if it gets printed?
g

gidgiddoni

08/30/2022, 3:26 AM
I did and it doesn't get printed. I thought maybe it was because I was overriding the
thirdPartySignUpIn
function but I am testing using a email and password to login. So I tried overriding the
emailpasswordSignIn
function but I a,m getting the same result. It won't print anything to the logs
r

rp

08/30/2022, 3:27 AM
Are you calling the sign up or sign in api?
There is also emailpasswordSignUp. You want to add this logic in there instead of emailpasswordSignIn
g

gidgiddoni

08/30/2022, 3:28 AM
I just updated the gist to show what I am trying rn. I think I am using the emailPasswordSignUp/In api correctly
r

rp

08/30/2022, 3:29 AM
Hmm. You should check the types from the lib to confirm you are doing it correctly
And you can even enable the backend debug logs and see the output of that when calling the api to see what’s happening
g

gidgiddoni

08/30/2022, 3:30 AM
How do I enable those logs?
r

rp

08/30/2022, 3:30 AM
Troubleshooting section in docs
g

gidgiddoni

08/30/2022, 3:34 AM
Okay cool. Turning on those logs I can now see the
input
getting logged. Also I have a type error so this gives me somewhere to troubleshoot.. thanks!!
r

rp

08/30/2022, 3:34 AM
👍
g

gidgiddoni

08/30/2022, 3:51 AM
In case anyone else finds this thread this example in the docs shows another way of doing this by overriding the POST apis. https://supertokens.com/docs/thirdpartyemailpassword/advanced-customizations/apis-override/custom-response/general-error
3 Views