Add authentication, styling needs to be fixed

# Conflicts:
#	starter/ent/runtime.go
#	starter/go.mod
#	starter/go.sum
#	starter/routes/routing.go
This commit is contained in:
Achim Rohn
2026-03-20 20:35:20 +00:00
parent f768e9e47c
commit a15ca501b8
34 changed files with 468 additions and 258 deletions
+3 -4
View File
@@ -11,14 +11,13 @@ import (
"git.gorlug.de/code/ersteller/starter/ent/migrate"
"git.gorlug.de/code/ersteller/starter/ent/googleauth"
"git.gorlug.de/code/ersteller/starter/ent/todo"
"git.gorlug.de/code/ersteller/starter/ent/user"
"entgo.io/ent"
"entgo.io/ent/dialect"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"git.gorlug.de/code/ersteller/starter/ent/googleauth"
"git.gorlug.de/code/ersteller/starter/ent/todo"
"git.gorlug.de/code/ersteller/starter/ent/user"
)
// Client is the client that holds all ent builders.
+3 -3
View File
@@ -6,15 +6,15 @@ import (
"context"
"errors"
"fmt"
"git.gorlug.de/code/ersteller/starter/ent/googleauth"
"git.gorlug.de/code/ersteller/starter/ent/todo"
"git.gorlug.de/code/ersteller/starter/ent/user"
"reflect"
"sync"
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"git.gorlug.de/code/ersteller/starter/ent/googleauth"
"git.gorlug.de/code/ersteller/starter/ent/todo"
"git.gorlug.de/code/ersteller/starter/ent/user"
)
// ent aliases to avoid import conflicts in user's code.
+1 -2
View File
@@ -9,9 +9,8 @@ import (
// required by schema hooks.
_ "git.gorlug.de/code/ersteller/starter/ent/runtime"
"git.gorlug.de/code/ersteller/starter/ent/migrate"
"entgo.io/ent/dialect/sql/schema"
"git.gorlug.de/code/ersteller/starter/ent/migrate"
)
type (
+3 -3
View File
@@ -5,14 +5,14 @@ package ent
import (
"encoding/json"
"fmt"
"git.gorlug.de/code/ersteller/starter/ent/googleauth"
"git.gorlug.de/code/ersteller/starter/ent/schema"
"git.gorlug.de/code/ersteller/starter/ent/user"
"strings"
"time"
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
"git.gorlug.de/code/ersteller/starter/ent/googleauth"
"git.gorlug.de/code/ersteller/starter/ent/schema"
"git.gorlug.de/code/ersteller/starter/ent/user"
)
// GoogleAuth is the model entity for the GoogleAuth schema.
+1 -1
View File
@@ -3,11 +3,11 @@
package googleauth
import (
"git.gorlug.de/code/ersteller/starter/ent/predicate"
"time"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"git.gorlug.de/code/ersteller/starter/ent/predicate"
)
// ID filters vertices based on their ID field.
+3 -3
View File
@@ -6,13 +6,13 @@ import (
"context"
"errors"
"fmt"
"git.gorlug.de/code/ersteller/starter/ent/googleauth"
"git.gorlug.de/code/ersteller/starter/ent/schema"
"git.gorlug.de/code/ersteller/starter/ent/user"
"time"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"git.gorlug.de/code/ersteller/starter/ent/googleauth"
"git.gorlug.de/code/ersteller/starter/ent/schema"
"git.gorlug.de/code/ersteller/starter/ent/user"
)
// GoogleAuthCreate is the builder for creating a GoogleAuth entity.
+2 -2
View File
@@ -4,12 +4,12 @@ package ent
import (
"context"
"git.gorlug.de/code/ersteller/starter/ent/googleauth"
"git.gorlug.de/code/ersteller/starter/ent/predicate"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"git.gorlug.de/code/ersteller/starter/ent/googleauth"
"git.gorlug.de/code/ersteller/starter/ent/predicate"
)
// GoogleAuthDelete is the builder for deleting a GoogleAuth entity.
+3 -3
View File
@@ -5,15 +5,15 @@ package ent
import (
"context"
"fmt"
"git.gorlug.de/code/ersteller/starter/ent/googleauth"
"git.gorlug.de/code/ersteller/starter/ent/predicate"
"git.gorlug.de/code/ersteller/starter/ent/user"
"math"
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"git.gorlug.de/code/ersteller/starter/ent/googleauth"
"git.gorlug.de/code/ersteller/starter/ent/predicate"
"git.gorlug.de/code/ersteller/starter/ent/user"
)
// GoogleAuthQuery is the builder for querying GoogleAuth entities.
+4 -4
View File
@@ -6,15 +6,15 @@ import (
"context"
"errors"
"fmt"
"git.gorlug.de/code/ersteller/starter/ent/googleauth"
"git.gorlug.de/code/ersteller/starter/ent/predicate"
"git.gorlug.de/code/ersteller/starter/ent/schema"
"git.gorlug.de/code/ersteller/starter/ent/user"
"time"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"git.gorlug.de/code/ersteller/starter/ent/googleauth"
"git.gorlug.de/code/ersteller/starter/ent/predicate"
"git.gorlug.de/code/ersteller/starter/ent/schema"
"git.gorlug.de/code/ersteller/starter/ent/user"
)
// GoogleAuthUpdate is the builder for updating GoogleAuth entities.
+1
View File
@@ -5,6 +5,7 @@ package hook
import (
"context"
"fmt"
"git.gorlug.de/code/ersteller/starter/ent"
)
+2 -2
View File
@@ -58,8 +58,8 @@ var (
{Name: "id", Type: field.TypeInt, Increment: true},
{Name: "created_at", Type: field.TypeTime},
{Name: "updated_at", Type: field.TypeTime},
{Name: "email", Type: field.TypeString, Default: "unknown@localhost"},
{Name: "password", Type: field.TypeString, Default: ""},
{Name: "email", Type: field.TypeString, Unique: true},
{Name: "password_hash", Type: field.TypeString, Default: ""},
}
// UsersTable holds the schema information for the "users" table.
UsersTable = &schema.Table{
+31 -31
View File
@@ -6,16 +6,16 @@ import (
"context"
"errors"
"fmt"
"git.gorlug.de/code/ersteller/starter/ent/googleauth"
"git.gorlug.de/code/ersteller/starter/ent/predicate"
"git.gorlug.de/code/ersteller/starter/ent/schema"
"git.gorlug.de/code/ersteller/starter/ent/todo"
"git.gorlug.de/code/ersteller/starter/ent/user"
"sync"
"time"
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
"git.gorlug.de/code/ersteller/starter/ent/googleauth"
"git.gorlug.de/code/ersteller/starter/ent/predicate"
"git.gorlug.de/code/ersteller/starter/ent/schema"
"git.gorlug.de/code/ersteller/starter/ent/todo"
"git.gorlug.de/code/ersteller/starter/ent/user"
)
const (
@@ -1097,7 +1097,7 @@ type UserMutation struct {
created_at *time.Time
updated_at *time.Time
email *string
password *string
password_hash *string
clearedFields map[string]struct{}
done bool
oldValue func(context.Context) (*User, error)
@@ -1310,40 +1310,40 @@ func (m *UserMutation) ResetEmail() {
m.email = nil
}
// SetPassword sets the "password" field.
func (m *UserMutation) SetPassword(s string) {
m.password = &s
// SetPasswordHash sets the "password_hash" field.
func (m *UserMutation) SetPasswordHash(s string) {
m.password_hash = &s
}
// Password returns the value of the "password" field in the mutation.
func (m *UserMutation) Password() (r string, exists bool) {
v := m.password
// PasswordHash returns the value of the "password_hash" field in the mutation.
func (m *UserMutation) PasswordHash() (r string, exists bool) {
v := m.password_hash
if v == nil {
return
}
return *v, true
}
// OldPassword returns the old "password" field's value of the User entity.
// OldPasswordHash returns the old "password_hash" field's value of the User entity.
// If the User object wasn't provided to the builder, the object is fetched from the database.
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
func (m *UserMutation) OldPassword(ctx context.Context) (v string, err error) {
func (m *UserMutation) OldPasswordHash(ctx context.Context) (v string, err error) {
if !m.op.Is(OpUpdateOne) {
return v, errors.New("OldPassword is only allowed on UpdateOne operations")
return v, errors.New("OldPasswordHash is only allowed on UpdateOne operations")
}
if m.id == nil || m.oldValue == nil {
return v, errors.New("OldPassword requires an ID field in the mutation")
return v, errors.New("OldPasswordHash requires an ID field in the mutation")
}
oldValue, err := m.oldValue(ctx)
if err != nil {
return v, fmt.Errorf("querying old value for OldPassword: %w", err)
return v, fmt.Errorf("querying old value for OldPasswordHash: %w", err)
}
return oldValue.Password, nil
return oldValue.PasswordHash, nil
}
// ResetPassword resets all changes to the "password" field.
func (m *UserMutation) ResetPassword() {
m.password = nil
// ResetPasswordHash resets all changes to the "password_hash" field.
func (m *UserMutation) ResetPasswordHash() {
m.password_hash = nil
}
// Where appends a list predicates to the UserMutation builder.
@@ -1390,8 +1390,8 @@ func (m *UserMutation) Fields() []string {
if m.email != nil {
fields = append(fields, user.FieldEmail)
}
if m.password != nil {
fields = append(fields, user.FieldPassword)
if m.password_hash != nil {
fields = append(fields, user.FieldPasswordHash)
}
return fields
}
@@ -1407,8 +1407,8 @@ func (m *UserMutation) Field(name string) (ent.Value, bool) {
return m.UpdatedAt()
case user.FieldEmail:
return m.Email()
case user.FieldPassword:
return m.Password()
case user.FieldPasswordHash:
return m.PasswordHash()
}
return nil, false
}
@@ -1424,8 +1424,8 @@ func (m *UserMutation) OldField(ctx context.Context, name string) (ent.Value, er
return m.OldUpdatedAt(ctx)
case user.FieldEmail:
return m.OldEmail(ctx)
case user.FieldPassword:
return m.OldPassword(ctx)
case user.FieldPasswordHash:
return m.OldPasswordHash(ctx)
}
return nil, fmt.Errorf("unknown User field %s", name)
}
@@ -1456,12 +1456,12 @@ func (m *UserMutation) SetField(name string, value ent.Value) error {
}
m.SetEmail(v)
return nil
case user.FieldPassword:
case user.FieldPasswordHash:
v, ok := value.(string)
if !ok {
return fmt.Errorf("unexpected type %T for field %s", value, name)
}
m.SetPassword(v)
m.SetPasswordHash(v)
return nil
}
return fmt.Errorf("unknown User field %s", name)
@@ -1521,8 +1521,8 @@ func (m *UserMutation) ResetField(name string) error {
case user.FieldEmail:
m.ResetEmail()
return nil
case user.FieldPassword:
m.ResetPassword()
case user.FieldPasswordHash:
m.ResetPasswordHash()
return nil
}
return fmt.Errorf("unknown User field %s", name)
+6 -9
View File
@@ -3,11 +3,12 @@
package ent
import (
"time"
"git.gorlug.de/code/ersteller/starter/ent/googleauth"
"git.gorlug.de/code/ersteller/starter/ent/schema"
"git.gorlug.de/code/ersteller/starter/ent/todo"
"git.gorlug.de/code/ersteller/starter/ent/user"
"time"
)
// The init function reads all schema descriptors with runtime code
@@ -67,12 +68,8 @@ func init() {
user.DefaultUpdatedAt = userDescUpdatedAt.Default.(func() time.Time)
// user.UpdateDefaultUpdatedAt holds the default value on update for the updated_at field.
user.UpdateDefaultUpdatedAt = userDescUpdatedAt.UpdateDefault.(func() time.Time)
// userDescEmail is the schema descriptor for email field.
userDescEmail := userFields[0].Descriptor()
// user.DefaultEmail holds the default value on creation for the email field.
user.DefaultEmail = userDescEmail.Default.(string)
// userDescPassword is the schema descriptor for password field.
userDescPassword := userFields[1].Descriptor()
// user.DefaultPassword holds the default value on creation for the password field.
user.DefaultPassword = userDescPassword.Default.(string)
// userDescPasswordHash is the schema descriptor for password_hash field.
userDescPasswordHash := userFields[1].Descriptor()
// user.DefaultPasswordHash holds the default value on creation for the password_hash field.
user.DefaultPasswordHash = userDescPasswordHash.Default.(string)
}
+1 -1
View File
@@ -2,7 +2,7 @@
package runtime
// The schema-stitching logic is generated in ersteller-lib/starter/ent/runtime.go
// The schema-stitching logic is generated in git.gorlug.de/code/ersteller/starter/ent/runtime.go
const (
Version = "v0.14.5" // Version of ent codegen.
+4 -2
View File
@@ -20,7 +20,9 @@ func (User) Mixin() []ent.Mixin {
func (User) Fields() []ent.Field {
return []ent.Field{
field.String("email").
Default("unknown@localhost"),
field.String("password").Default(""),
Unique(),
field.String("password_hash").
Default("").
Sensitive(),
}
}
+2 -2
View File
@@ -4,13 +4,13 @@ package ent
import (
"fmt"
"git.gorlug.de/code/ersteller/starter/ent/todo"
"git.gorlug.de/code/ersteller/starter/ent/user"
"strings"
"time"
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
"git.gorlug.de/code/ersteller/starter/ent/todo"
"git.gorlug.de/code/ersteller/starter/ent/user"
)
// Todo is the model entity for the Todo schema.
+1 -1
View File
@@ -3,11 +3,11 @@
package todo
import (
"git.gorlug.de/code/ersteller/starter/ent/predicate"
"time"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"git.gorlug.de/code/ersteller/starter/ent/predicate"
)
// ID filters vertices based on their ID field.
+2 -2
View File
@@ -6,12 +6,12 @@ import (
"context"
"errors"
"fmt"
"git.gorlug.de/code/ersteller/starter/ent/todo"
"git.gorlug.de/code/ersteller/starter/ent/user"
"time"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"git.gorlug.de/code/ersteller/starter/ent/todo"
"git.gorlug.de/code/ersteller/starter/ent/user"
)
// TodoCreate is the builder for creating a Todo entity.
+2 -2
View File
@@ -4,12 +4,12 @@ package ent
import (
"context"
"git.gorlug.de/code/ersteller/starter/ent/predicate"
"git.gorlug.de/code/ersteller/starter/ent/todo"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"git.gorlug.de/code/ersteller/starter/ent/predicate"
"git.gorlug.de/code/ersteller/starter/ent/todo"
)
// TodoDelete is the builder for deleting a Todo entity.
+3 -3
View File
@@ -5,15 +5,15 @@ package ent
import (
"context"
"fmt"
"git.gorlug.de/code/ersteller/starter/ent/predicate"
"git.gorlug.de/code/ersteller/starter/ent/todo"
"git.gorlug.de/code/ersteller/starter/ent/user"
"math"
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"git.gorlug.de/code/ersteller/starter/ent/predicate"
"git.gorlug.de/code/ersteller/starter/ent/todo"
"git.gorlug.de/code/ersteller/starter/ent/user"
)
// TodoQuery is the builder for querying Todo entities.
+3 -3
View File
@@ -6,14 +6,14 @@ import (
"context"
"errors"
"fmt"
"git.gorlug.de/code/ersteller/starter/ent/predicate"
"git.gorlug.de/code/ersteller/starter/ent/todo"
"git.gorlug.de/code/ersteller/starter/ent/user"
"time"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"git.gorlug.de/code/ersteller/starter/ent/predicate"
"git.gorlug.de/code/ersteller/starter/ent/todo"
"git.gorlug.de/code/ersteller/starter/ent/user"
)
// TodoUpdate is the builder for updating Todo entities.
+8 -9
View File
@@ -4,12 +4,12 @@ package ent
import (
"fmt"
"git.gorlug.de/code/ersteller/starter/ent/user"
"strings"
"time"
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
"git.gorlug.de/code/ersteller/starter/ent/user"
)
// User is the model entity for the User schema.
@@ -23,8 +23,8 @@ type User struct {
UpdatedAt time.Time `json:"updated_at,omitempty"`
// Email holds the value of the "email" field.
Email string `json:"email,omitempty"`
// Password holds the value of the "password" field.
Password string `json:"password,omitempty"`
// PasswordHash holds the value of the "password_hash" field.
PasswordHash string `json:"-"`
selectValues sql.SelectValues
}
@@ -35,7 +35,7 @@ func (*User) scanValues(columns []string) ([]any, error) {
switch columns[i] {
case user.FieldID:
values[i] = new(sql.NullInt64)
case user.FieldEmail, user.FieldPassword:
case user.FieldEmail, user.FieldPasswordHash:
values[i] = new(sql.NullString)
case user.FieldCreatedAt, user.FieldUpdatedAt:
values[i] = new(sql.NullTime)
@@ -78,11 +78,11 @@ func (_m *User) assignValues(columns []string, values []any) error {
} else if value.Valid {
_m.Email = value.String
}
case user.FieldPassword:
case user.FieldPasswordHash:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field password", values[i])
return fmt.Errorf("unexpected type %T for field password_hash", values[i])
} else if value.Valid {
_m.Password = value.String
_m.PasswordHash = value.String
}
default:
_m.selectValues.Set(columns[i], values[i])
@@ -129,8 +129,7 @@ func (_m *User) String() string {
builder.WriteString("email=")
builder.WriteString(_m.Email)
builder.WriteString(", ")
builder.WriteString("password=")
builder.WriteString(_m.Password)
builder.WriteString("password_hash=<sensitive>")
builder.WriteByte(')')
return builder.String()
}
+8 -10
View File
@@ -19,8 +19,8 @@ const (
FieldUpdatedAt = "updated_at"
// FieldEmail holds the string denoting the email field in the database.
FieldEmail = "email"
// FieldPassword holds the string denoting the password field in the database.
FieldPassword = "password"
// FieldPasswordHash holds the string denoting the password_hash field in the database.
FieldPasswordHash = "password_hash"
// Table holds the table name of the user in the database.
Table = "users"
)
@@ -31,7 +31,7 @@ var Columns = []string{
FieldCreatedAt,
FieldUpdatedAt,
FieldEmail,
FieldPassword,
FieldPasswordHash,
}
// ValidColumn reports if the column name is valid (part of the table columns).
@@ -51,10 +51,8 @@ var (
DefaultUpdatedAt func() time.Time
// UpdateDefaultUpdatedAt holds the default value on update for the "updated_at" field.
UpdateDefaultUpdatedAt func() time.Time
// DefaultEmail holds the default value on creation for the "email" field.
DefaultEmail string
// DefaultPassword holds the default value on creation for the "password" field.
DefaultPassword string
// DefaultPasswordHash holds the default value on creation for the "password_hash" field.
DefaultPasswordHash string
)
// OrderOption defines the ordering options for the User queries.
@@ -80,7 +78,7 @@ func ByEmail(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldEmail, opts...).ToFunc()
}
// ByPassword orders the results by the password field.
func ByPassword(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldPassword, opts...).ToFunc()
// ByPasswordHash orders the results by the password_hash field.
func ByPasswordHash(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldPasswordHash, opts...).ToFunc()
}
+43 -43
View File
@@ -3,10 +3,10 @@
package user
import (
"git.gorlug.de/code/ersteller/starter/ent/predicate"
"time"
"entgo.io/ent/dialect/sql"
"git.gorlug.de/code/ersteller/starter/ent/predicate"
)
// ID filters vertices based on their ID field.
@@ -69,9 +69,9 @@ func Email(v string) predicate.User {
return predicate.User(sql.FieldEQ(FieldEmail, v))
}
// Password applies equality check predicate on the "password" field. It's identical to PasswordEQ.
func Password(v string) predicate.User {
return predicate.User(sql.FieldEQ(FieldPassword, v))
// PasswordHash applies equality check predicate on the "password_hash" field. It's identical to PasswordHashEQ.
func PasswordHash(v string) predicate.User {
return predicate.User(sql.FieldEQ(FieldPasswordHash, v))
}
// CreatedAtEQ applies the EQ predicate on the "created_at" field.
@@ -219,69 +219,69 @@ func EmailContainsFold(v string) predicate.User {
return predicate.User(sql.FieldContainsFold(FieldEmail, v))
}
// PasswordEQ applies the EQ predicate on the "password" field.
func PasswordEQ(v string) predicate.User {
return predicate.User(sql.FieldEQ(FieldPassword, v))
// PasswordHashEQ applies the EQ predicate on the "password_hash" field.
func PasswordHashEQ(v string) predicate.User {
return predicate.User(sql.FieldEQ(FieldPasswordHash, v))
}
// PasswordNEQ applies the NEQ predicate on the "password" field.
func PasswordNEQ(v string) predicate.User {
return predicate.User(sql.FieldNEQ(FieldPassword, v))
// PasswordHashNEQ applies the NEQ predicate on the "password_hash" field.
func PasswordHashNEQ(v string) predicate.User {
return predicate.User(sql.FieldNEQ(FieldPasswordHash, v))
}
// PasswordIn applies the In predicate on the "password" field.
func PasswordIn(vs ...string) predicate.User {
return predicate.User(sql.FieldIn(FieldPassword, vs...))
// PasswordHashIn applies the In predicate on the "password_hash" field.
func PasswordHashIn(vs ...string) predicate.User {
return predicate.User(sql.FieldIn(FieldPasswordHash, vs...))
}
// PasswordNotIn applies the NotIn predicate on the "password" field.
func PasswordNotIn(vs ...string) predicate.User {
return predicate.User(sql.FieldNotIn(FieldPassword, vs...))
// PasswordHashNotIn applies the NotIn predicate on the "password_hash" field.
func PasswordHashNotIn(vs ...string) predicate.User {
return predicate.User(sql.FieldNotIn(FieldPasswordHash, vs...))
}
// PasswordGT applies the GT predicate on the "password" field.
func PasswordGT(v string) predicate.User {
return predicate.User(sql.FieldGT(FieldPassword, v))
// PasswordHashGT applies the GT predicate on the "password_hash" field.
func PasswordHashGT(v string) predicate.User {
return predicate.User(sql.FieldGT(FieldPasswordHash, v))
}
// PasswordGTE applies the GTE predicate on the "password" field.
func PasswordGTE(v string) predicate.User {
return predicate.User(sql.FieldGTE(FieldPassword, v))
// PasswordHashGTE applies the GTE predicate on the "password_hash" field.
func PasswordHashGTE(v string) predicate.User {
return predicate.User(sql.FieldGTE(FieldPasswordHash, v))
}
// PasswordLT applies the LT predicate on the "password" field.
func PasswordLT(v string) predicate.User {
return predicate.User(sql.FieldLT(FieldPassword, v))
// PasswordHashLT applies the LT predicate on the "password_hash" field.
func PasswordHashLT(v string) predicate.User {
return predicate.User(sql.FieldLT(FieldPasswordHash, v))
}
// PasswordLTE applies the LTE predicate on the "password" field.
func PasswordLTE(v string) predicate.User {
return predicate.User(sql.FieldLTE(FieldPassword, v))
// PasswordHashLTE applies the LTE predicate on the "password_hash" field.
func PasswordHashLTE(v string) predicate.User {
return predicate.User(sql.FieldLTE(FieldPasswordHash, v))
}
// PasswordContains applies the Contains predicate on the "password" field.
func PasswordContains(v string) predicate.User {
return predicate.User(sql.FieldContains(FieldPassword, v))
// PasswordHashContains applies the Contains predicate on the "password_hash" field.
func PasswordHashContains(v string) predicate.User {
return predicate.User(sql.FieldContains(FieldPasswordHash, v))
}
// PasswordHasPrefix applies the HasPrefix predicate on the "password" field.
func PasswordHasPrefix(v string) predicate.User {
return predicate.User(sql.FieldHasPrefix(FieldPassword, v))
// PasswordHashHasPrefix applies the HasPrefix predicate on the "password_hash" field.
func PasswordHashHasPrefix(v string) predicate.User {
return predicate.User(sql.FieldHasPrefix(FieldPasswordHash, v))
}
// PasswordHasSuffix applies the HasSuffix predicate on the "password" field.
func PasswordHasSuffix(v string) predicate.User {
return predicate.User(sql.FieldHasSuffix(FieldPassword, v))
// PasswordHashHasSuffix applies the HasSuffix predicate on the "password_hash" field.
func PasswordHashHasSuffix(v string) predicate.User {
return predicate.User(sql.FieldHasSuffix(FieldPasswordHash, v))
}
// PasswordEqualFold applies the EqualFold predicate on the "password" field.
func PasswordEqualFold(v string) predicate.User {
return predicate.User(sql.FieldEqualFold(FieldPassword, v))
// PasswordHashEqualFold applies the EqualFold predicate on the "password_hash" field.
func PasswordHashEqualFold(v string) predicate.User {
return predicate.User(sql.FieldEqualFold(FieldPasswordHash, v))
}
// PasswordContainsFold applies the ContainsFold predicate on the "password" field.
func PasswordContainsFold(v string) predicate.User {
return predicate.User(sql.FieldContainsFold(FieldPassword, v))
// PasswordHashContainsFold applies the ContainsFold predicate on the "password_hash" field.
func PasswordHashContainsFold(v string) predicate.User {
return predicate.User(sql.FieldContainsFold(FieldPasswordHash, v))
}
// And groups predicates with the AND operator between them.
+15 -27
View File
@@ -6,11 +6,11 @@ import (
"context"
"errors"
"fmt"
"git.gorlug.de/code/ersteller/starter/ent/user"
"time"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"git.gorlug.de/code/ersteller/starter/ent/user"
)
// UserCreate is the builder for creating a User entity.
@@ -54,24 +54,16 @@ func (_c *UserCreate) SetEmail(v string) *UserCreate {
return _c
}
// SetNillableEmail sets the "email" field if the given value is not nil.
func (_c *UserCreate) SetNillableEmail(v *string) *UserCreate {
if v != nil {
_c.SetEmail(*v)
}
// SetPasswordHash sets the "password_hash" field.
func (_c *UserCreate) SetPasswordHash(v string) *UserCreate {
_c.mutation.SetPasswordHash(v)
return _c
}
// SetPassword sets the "password" field.
func (_c *UserCreate) SetPassword(v string) *UserCreate {
_c.mutation.SetPassword(v)
return _c
}
// SetNillablePassword sets the "password" field if the given value is not nil.
func (_c *UserCreate) SetNillablePassword(v *string) *UserCreate {
// SetNillablePasswordHash sets the "password_hash" field if the given value is not nil.
func (_c *UserCreate) SetNillablePasswordHash(v *string) *UserCreate {
if v != nil {
_c.SetPassword(*v)
_c.SetPasswordHash(*v)
}
return _c
}
@@ -119,13 +111,9 @@ func (_c *UserCreate) defaults() {
v := user.DefaultUpdatedAt()
_c.mutation.SetUpdatedAt(v)
}
if _, ok := _c.mutation.Email(); !ok {
v := user.DefaultEmail
_c.mutation.SetEmail(v)
}
if _, ok := _c.mutation.Password(); !ok {
v := user.DefaultPassword
_c.mutation.SetPassword(v)
if _, ok := _c.mutation.PasswordHash(); !ok {
v := user.DefaultPasswordHash
_c.mutation.SetPasswordHash(v)
}
}
@@ -140,8 +128,8 @@ func (_c *UserCreate) check() error {
if _, ok := _c.mutation.Email(); !ok {
return &ValidationError{Name: "email", err: errors.New(`ent: missing required field "User.email"`)}
}
if _, ok := _c.mutation.Password(); !ok {
return &ValidationError{Name: "password", err: errors.New(`ent: missing required field "User.password"`)}
if _, ok := _c.mutation.PasswordHash(); !ok {
return &ValidationError{Name: "password_hash", err: errors.New(`ent: missing required field "User.password_hash"`)}
}
return nil
}
@@ -181,9 +169,9 @@ func (_c *UserCreate) createSpec() (*User, *sqlgraph.CreateSpec) {
_spec.SetField(user.FieldEmail, field.TypeString, value)
_node.Email = value
}
if value, ok := _c.mutation.Password(); ok {
_spec.SetField(user.FieldPassword, field.TypeString, value)
_node.Password = value
if value, ok := _c.mutation.PasswordHash(); ok {
_spec.SetField(user.FieldPasswordHash, field.TypeString, value)
_node.PasswordHash = value
}
return _node, _spec
}
+2 -2
View File
@@ -4,12 +4,12 @@ package ent
import (
"context"
"git.gorlug.de/code/ersteller/starter/ent/predicate"
"git.gorlug.de/code/ersteller/starter/ent/user"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"git.gorlug.de/code/ersteller/starter/ent/predicate"
"git.gorlug.de/code/ersteller/starter/ent/user"
)
// UserDelete is the builder for deleting a User entity.
+2 -2
View File
@@ -5,14 +5,14 @@ package ent
import (
"context"
"fmt"
"git.gorlug.de/code/ersteller/starter/ent/predicate"
"git.gorlug.de/code/ersteller/starter/ent/user"
"math"
"entgo.io/ent"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"git.gorlug.de/code/ersteller/starter/ent/predicate"
"git.gorlug.de/code/ersteller/starter/ent/user"
)
// UserQuery is the builder for querying User entities.
+18 -18
View File
@@ -6,13 +6,13 @@ import (
"context"
"errors"
"fmt"
"git.gorlug.de/code/ersteller/starter/ent/predicate"
"git.gorlug.de/code/ersteller/starter/ent/user"
"time"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/schema/field"
"git.gorlug.de/code/ersteller/starter/ent/predicate"
"git.gorlug.de/code/ersteller/starter/ent/user"
)
// UserUpdate is the builder for updating User entities.
@@ -48,16 +48,16 @@ func (_u *UserUpdate) SetNillableEmail(v *string) *UserUpdate {
return _u
}
// SetPassword sets the "password" field.
func (_u *UserUpdate) SetPassword(v string) *UserUpdate {
_u.mutation.SetPassword(v)
// SetPasswordHash sets the "password_hash" field.
func (_u *UserUpdate) SetPasswordHash(v string) *UserUpdate {
_u.mutation.SetPasswordHash(v)
return _u
}
// SetNillablePassword sets the "password" field if the given value is not nil.
func (_u *UserUpdate) SetNillablePassword(v *string) *UserUpdate {
// SetNillablePasswordHash sets the "password_hash" field if the given value is not nil.
func (_u *UserUpdate) SetNillablePasswordHash(v *string) *UserUpdate {
if v != nil {
_u.SetPassword(*v)
_u.SetPasswordHash(*v)
}
return _u
}
@@ -118,8 +118,8 @@ func (_u *UserUpdate) sqlSave(ctx context.Context) (_node int, err error) {
if value, ok := _u.mutation.Email(); ok {
_spec.SetField(user.FieldEmail, field.TypeString, value)
}
if value, ok := _u.mutation.Password(); ok {
_spec.SetField(user.FieldPassword, field.TypeString, value)
if value, ok := _u.mutation.PasswordHash(); ok {
_spec.SetField(user.FieldPasswordHash, field.TypeString, value)
}
if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
@@ -161,16 +161,16 @@ func (_u *UserUpdateOne) SetNillableEmail(v *string) *UserUpdateOne {
return _u
}
// SetPassword sets the "password" field.
func (_u *UserUpdateOne) SetPassword(v string) *UserUpdateOne {
_u.mutation.SetPassword(v)
// SetPasswordHash sets the "password_hash" field.
func (_u *UserUpdateOne) SetPasswordHash(v string) *UserUpdateOne {
_u.mutation.SetPasswordHash(v)
return _u
}
// SetNillablePassword sets the "password" field if the given value is not nil.
func (_u *UserUpdateOne) SetNillablePassword(v *string) *UserUpdateOne {
// SetNillablePasswordHash sets the "password_hash" field if the given value is not nil.
func (_u *UserUpdateOne) SetNillablePasswordHash(v *string) *UserUpdateOne {
if v != nil {
_u.SetPassword(*v)
_u.SetPasswordHash(*v)
}
return _u
}
@@ -261,8 +261,8 @@ func (_u *UserUpdateOne) sqlSave(ctx context.Context) (_node *User, err error) {
if value, ok := _u.mutation.Email(); ok {
_spec.SetField(user.FieldEmail, field.TypeString, value)
}
if value, ok := _u.mutation.Password(); ok {
_spec.SetField(user.FieldPassword, field.TypeString, value)
if value, ok := _u.mutation.PasswordHash(); ok {
_spec.SetField(user.FieldPasswordHash, field.TypeString, value)
}
_node = &User{config: _u.config}
_spec.Assign = _node.assignValues