mirror of
https://github.com/teamhanko/hanko.git
synced 2025-10-27 06:06:54 +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>
35 lines
809 B
Go
35 lines
809 B
Go
package shared
|
|
|
|
import (
|
|
"fmt"
|
|
"github.com/gofrs/uuid"
|
|
"github.com/teamhanko/hanko/backend/flowpilot"
|
|
"github.com/teamhanko/hanko/backend/persistence/models"
|
|
)
|
|
|
|
type PasswordSave struct {
|
|
Action
|
|
}
|
|
|
|
func (h PasswordSave) Execute(c flowpilot.HookExecutionContext) error {
|
|
deps := h.GetDeps(c)
|
|
|
|
if !c.Stash().Get(StashPathNewPassword).Exists() {
|
|
return nil
|
|
}
|
|
|
|
passwordId, _ := uuid.NewV4()
|
|
passwordCredential := models.PasswordCredential{
|
|
ID: passwordId,
|
|
UserId: uuid.FromStringOrNil(c.Stash().Get(StashPathUserID).String()),
|
|
Password: c.Stash().Get(StashPathNewPassword).String(),
|
|
}
|
|
|
|
err := deps.Persister.GetPasswordCredentialPersister().Create(passwordCredential)
|
|
if err != nil {
|
|
return fmt.Errorf("could not create password: %w", err)
|
|
}
|
|
// TODO: add audit log?
|
|
return nil
|
|
}
|