Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Separate post register/login hooks #150

Merged
merged 4 commits into from
Dec 16, 2019
Merged

Separate post register/login hooks #150

merged 4 commits into from
Dec 16, 2019

Conversation

nmlc
Copy link
Contributor

@nmlc nmlc commented Dec 12, 2019

Related issue

#149

Proposed changes

Checklist

  • I have read the contributing guidelines
  • I have read the security policy
  • I confirm that this pull request does not address a security vulnerability. If this pull request addresses a security
    vulnerability, I confirm that I got green light (please contact security@ory.sh) from the maintainers to push the changes.
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation within the code base (if appropriate)
  • I have documented my changes in the developer guide (if appropriate)

Further comments

@claassistantio
Copy link

claassistantio commented Dec 12, 2019

CLA assistant check
All committers have signed the CLA.

@nmlc nmlc marked this pull request as ready for review December 12, 2019 09:26
@aeneasr
Copy link
Member

aeneasr commented Dec 12, 2019

Thank you! I'm working right now on fixing the go-acc issues and also some test related issues that surfaced due to this work. Once it's done, I'll ask you to rebase this PR on those changes and then it should be good for a review :)

@aeneasr
Copy link
Member

aeneasr commented Dec 12, 2019

Ok, so the PR is now done. Let's see how the CI likes it: #154

@aeneasr
Copy link
Member

aeneasr commented Dec 12, 2019

Ok, merged - had to resolve several issues that surfaced in the tests :) Good to rebase now!

@@ -73,3 +77,39 @@ func (m *RegistryDefault) hooksPost(credentialsType identity.CredentialsType, co

return i
}

func newRedirector(m *RegistryDefault, h configuration.SelfServiceHook, credentialsType identity.CredentialsType) (*hook.Redirector, error) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that this logic belongs to NewRedirector in hook package, but then we will couple it with config parsing. So I've left it there.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I was about to say that! :D We could however replace h configuration.SelfServiceHook with just config json.RawMessage and replace the WithField("hook", h.Run). line with the "redirector" because we know what hook we're creating here :) What do you think?

b[k] = v
}
return b
return m.hooksPostRegistration(credentialsType, m.c.SelfServiceRegistrationAfterHooks(string(credentialsType)))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we even need separate hooksPostLogin/Registration? I would rather inline it here.

Copy link
Member

@aeneasr aeneasr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could probably reduce code duplication by having one function getHooks returning []interface{} and then looping through the list in PostRegistrationHooks and do a type assertion for registration.PostHookExecutor and if the type assertion passes, add it to the return list. The same of course for login. What do you think?

@@ -73,3 +77,39 @@ func (m *RegistryDefault) hooksPost(credentialsType identity.CredentialsType, co

return i
}

func newRedirector(m *RegistryDefault, h configuration.SelfServiceHook, credentialsType identity.CredentialsType) (*hook.Redirector, error) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I was about to say that! :D We could however replace h configuration.SelfServiceHook with just config json.RawMessage and replace the WithField("hook", h.Run). line with the "redirector" because we know what hook we're creating here :) What do you think?

@aeneasr
Copy link
Member

aeneasr commented Dec 13, 2019

Perfect, thank you!

@aeneasr aeneasr merged commit f4b7812 into ory:master Dec 16, 2019
instcode pushed a commit to instcode/kratos that referenced this pull request Dec 31, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants