Hey Folks, I want to add restriction to only allow...
# talk-kratos
f
Hey Folks, I want to add restriction to only allowed verified email to login and register. Currently it's working for login using this hook : How can do the same for registration flow to ?
ui_url: <http://localhost:4455/auth/login>
lifespan: 1h
after:
password:
hooks:
- hook: require_verified_address
m
But how can the email be verified if you dont have an account yet 🤔 ?
f
I would like to run this Hook on after the user have registered .
hook: require_verified_address
I'm able to manage the redirect on the client side but the cookie is already set .
m
Sorry I think I misunderstood, So after the sign up you don't want them to get a session, but instead verify address and then they get a session?
👍 1
f
My bad, did not explain clearly .Yes ! Exactly.
m
Copy code
registration:
      lifespan: 10m
      ui_url: <http://127.0.0.1:4455/registration>
      after:
        password:
          hooks:
            -
              hook: session
Do you have the session hook active like this? If you remove it, the user will be required to login after the registration. And since requiring verified is working for login, that would do it? Let me know if I missed something
🙌 1
👍 1
f
Thanks a lot @User Works now .
@User Is there a way I can set session cookie once the user click on verification link. Currently it redirect to login flow again
m
Hey @User I dont think there is an easy way to do this. Ideally the user should have an active session if they click on verification link, right? So either verify after registration (-> get active session when registering) or verify through manually starting verification flow (-> needs active session to start the flow). Am I missing something?
Hm it seems it is possible after all with hooks, have to do some more investigation 🤔
I opened an issue to make this more clear in the future, thanks for digging in @User https://github.com/ory/docs/issues/671
👍 1
f
@User when hook:
require_verified_address
is not set, the user get redirected with valid session cookie once they click on verification link. But when not set
require_verified_address
verification link redirect to loginFlow