From 60eb2e7fe5ed3627ad4bd40286df1741529da75b Mon Sep 17 00:00:00 2001 From: Alexander Kavon Date: Thu, 25 Jan 2024 02:47:26 -0500 Subject: update hooks to more identifiable names, update migrations to work with votes, use a common enum state type --- src/user/hooks.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/user/hooks.go') 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 -- cgit v1.2.3