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

Seprate out login & registeration POST hooks #149

Closed
yindia opened this issue Dec 11, 2019 · 3 comments
Closed

Seprate out login & registeration POST hooks #149

yindia opened this issue Dec 11, 2019 · 3 comments

Comments

@yindia
Copy link
Contributor

yindia commented Dec 11, 2019

Is your feature request related to a problem? Please describe.
In current Implementation we are using common post hooks for login & registration. in #139 we face same issue where we have to implement POST hook for only login not for registration. Currently we use a blank ExecuteRegistrationPostHook but that is extra ideally we have to handle it separately

Describe the solution you'd like

each hook should be handled individually. registry_default_login.go
instead of using the postHook interface here, we should just iterate over []interface which has all of the hooks, and then do a type assertion

Describe alternatives you've considered

A clear and concise description of any alternative solutions or features you've considered.

Additional context

Add any other context or screenshots about the feature request here.

@yindia yindia changed the title Seprate out login & registeration hooks Seprate out login & registeration POST hooks Dec 11, 2019
@yindia
Copy link
Contributor Author

yindia commented Dec 11, 2019

one solution can be this

#registry_default_login.go
func (m *RegistryDefault) PostLoginHooks(credentialsType identity.CredentialsType) []login.PostHookExecutor {
	a := m.hooksPost(credentialsType, m.c.SelfServiceLoginAfterHooks(string(credentialsType)))
        a = append(a,hook.NewSessionDestroyer(m))
        b := make([]login.PostHookExecutor, len(a))
	for k, v := range a {
		b[k] = v
	}
	return b
}
# registry_default_registration.go
func (m *RegistryDefault) PostRegistrationHooks(credentialsType identity.CredentialsType) []registration.PostHookExecutor {
	a := m.hooksPost(credentialsType, m.c.SelfServiceRegistrationAfterHooks(string(credentialsType)))
        // add hooks if any in case of registration
	b := make([]registration.PostHookExecutor, len(a))
	for k, v := range a {
		b[k] = v
	}
	return b
}

Default registry hook only have common hooks like redirect and sessionIssuer

@nmlc
Copy link
Contributor

nmlc commented Dec 12, 2019

@evalsocket can I grab this one? Seems like small enough issue to start with :)

@yindia
Copy link
Contributor Author

yindia commented Dec 12, 2019

@nmlc discuss it with @aeneasr before starting.

instcode pushed a commit to instcode/kratos that referenced this issue 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

No branches or pull requests

2 participants