diff options
Diffstat (limited to 'src/user/hooks.go')
| -rw-r--r-- | src/user/hooks.go | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/user/hooks.go b/src/user/hooks.go index c7b7632..21eaaa3 100644 --- a/src/user/hooks.go +++ b/src/user/hooks.go @@ -8,13 +8,13 @@ import ( "gitlab.com/alexkavon/newsstand/src/models" ) -func InitHooks() { - models.AddUserHook(boil.BeforeInsertHook, validateNew) +func InitInsertHooks() { + models.AddUserHook(boil.BeforeInsertHook, validateNewHook) // should always be last - models.AddUserHook(boil.BeforeInsertHook, hashSecretBeforeInsert) + models.AddUserHook(boil.BeforeInsertHook, hashSecretHook) } -func validateNew(ctx context.Context, exec boil.ContextExecutor, u *models.User) error { +func validateNewHook(ctx context.Context, exec boil.ContextExecutor, u *models.User) error { // validate user err := validation.ValidateStruct(u, validation.Field(&u.Username, validation.Required, validation.Length(3, 50)), @@ -27,7 +27,7 @@ func validateNew(ctx context.Context, exec boil.ContextExecutor, u *models.User) return nil } -func hashSecretBeforeInsert(ctx context.Context, exec boil.ContextExecutor, u *models.User) error { +func hashSecretHook(ctx context.Context, exec boil.ContextExecutor, u *models.User) error { hashed, err := hashSecret(u.Secret) if err != nil { return err |
