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:
+31
-31
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user