mirror of
https://github.com/teamhanko/hanko.git
synced 2025-10-30 08:07:28 +08:00
This pull request introduces the new Flowpilot system along with several new features and various improvements. The key enhancements include configurable authorization, registration, and profile flows, as well as the ability to enable and disable user identifiers (e.g., email addresses and usernames) and login methods. --------- Co-authored-by: Frederic Jahn <frederic.jahn@hanko.io> Co-authored-by: Lennart Fleischmann <lennart.fleischmann@hanko.io> Co-authored-by: lfleischmann <67686424+lfleischmann@users.noreply.github.com> Co-authored-by: merlindru <hello@merlindru.com>
72 lines
1.5 KiB
Go
72 lines
1.5 KiB
Go
package flowpilot
|
|
|
|
type allowedValue interface {
|
|
toResponseAllowedValue() *ResponseAllowedValue
|
|
getValue() interface{}
|
|
}
|
|
|
|
type defaultAllowedValue struct {
|
|
text string
|
|
value interface{}
|
|
}
|
|
|
|
func (av *defaultAllowedValue) getValue() interface{} {
|
|
return av.value
|
|
}
|
|
|
|
// toResponseAllowedValue converts the allowedValue to a ResponseAllowedValue for public exposure.
|
|
func (av *defaultAllowedValue) toResponseAllowedValue() *ResponseAllowedValue {
|
|
return &ResponseAllowedValue{
|
|
Text: av.text,
|
|
Value: av.value,
|
|
}
|
|
}
|
|
|
|
type allowedValues interface {
|
|
isAllowed(value string) bool
|
|
add(allowedValue)
|
|
toResponseAllowedValues() *ResponseAllowedValues
|
|
hasAny() bool
|
|
getValues() []string
|
|
}
|
|
|
|
type defaultAllowedValues []allowedValue
|
|
|
|
func (av *defaultAllowedValues) isAllowed(value string) bool {
|
|
if len(*av) == 0 {
|
|
return true
|
|
}
|
|
|
|
for _, v := range *av {
|
|
if v.getValue().(string) == value {
|
|
return true
|
|
}
|
|
}
|
|
|
|
return false
|
|
}
|
|
|
|
func (av *defaultAllowedValues) add(value allowedValue) {
|
|
*av = append(*av, value)
|
|
}
|
|
|
|
func (av *defaultAllowedValues) hasAny() bool {
|
|
return len(*av) > 0
|
|
}
|
|
|
|
func (av *defaultAllowedValues) getValues() []string {
|
|
values := make([]string, len(*av))
|
|
for i, v := range *av {
|
|
values[i] = v.getValue().(string)
|
|
}
|
|
return values
|
|
}
|
|
|
|
func (av *defaultAllowedValues) toResponseAllowedValues() *ResponseAllowedValues {
|
|
values := make(ResponseAllowedValues, len(*av))
|
|
for i, v := range *av {
|
|
values[i] = v.toResponseAllowedValue()
|
|
}
|
|
return &values
|
|
}
|