create account, create email
This commit is contained in:
parent
fd8fdc899c
commit
80289f1929
@ -226,6 +226,16 @@ func NicknameHasSuffix(v string) predicate.Account {
|
|||||||
return predicate.Account(sql.FieldHasSuffix(FieldNickname, v))
|
return predicate.Account(sql.FieldHasSuffix(FieldNickname, v))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NicknameIsNil applies the IsNil predicate on the "nickname" field.
|
||||||
|
func NicknameIsNil() predicate.Account {
|
||||||
|
return predicate.Account(sql.FieldIsNull(FieldNickname))
|
||||||
|
}
|
||||||
|
|
||||||
|
// NicknameNotNil applies the NotNil predicate on the "nickname" field.
|
||||||
|
func NicknameNotNil() predicate.Account {
|
||||||
|
return predicate.Account(sql.FieldNotNull(FieldNickname))
|
||||||
|
}
|
||||||
|
|
||||||
// NicknameEqualFold applies the EqualFold predicate on the "nickname" field.
|
// NicknameEqualFold applies the EqualFold predicate on the "nickname" field.
|
||||||
func NicknameEqualFold(v string) predicate.Account {
|
func NicknameEqualFold(v string) predicate.Account {
|
||||||
return predicate.Account(sql.FieldEqualFold(FieldNickname, v))
|
return predicate.Account(sql.FieldEqualFold(FieldNickname, v))
|
||||||
@ -291,6 +301,16 @@ func NameHasSuffix(v string) predicate.Account {
|
|||||||
return predicate.Account(sql.FieldHasSuffix(FieldName, v))
|
return predicate.Account(sql.FieldHasSuffix(FieldName, v))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NameIsNil applies the IsNil predicate on the "name" field.
|
||||||
|
func NameIsNil() predicate.Account {
|
||||||
|
return predicate.Account(sql.FieldIsNull(FieldName))
|
||||||
|
}
|
||||||
|
|
||||||
|
// NameNotNil applies the NotNil predicate on the "name" field.
|
||||||
|
func NameNotNil() predicate.Account {
|
||||||
|
return predicate.Account(sql.FieldNotNull(FieldName))
|
||||||
|
}
|
||||||
|
|
||||||
// NameEqualFold applies the EqualFold predicate on the "name" field.
|
// NameEqualFold applies the EqualFold predicate on the "name" field.
|
||||||
func NameEqualFold(v string) predicate.Account {
|
func NameEqualFold(v string) predicate.Account {
|
||||||
return predicate.Account(sql.FieldEqualFold(FieldName, v))
|
return predicate.Account(sql.FieldEqualFold(FieldName, v))
|
||||||
|
@ -56,12 +56,28 @@ func (ac *AccountCreate) SetNickname(s string) *AccountCreate {
|
|||||||
return ac
|
return ac
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SetNillableNickname sets the "nickname" field if the given value is not nil.
|
||||||
|
func (ac *AccountCreate) SetNillableNickname(s *string) *AccountCreate {
|
||||||
|
if s != nil {
|
||||||
|
ac.SetNickname(*s)
|
||||||
|
}
|
||||||
|
return ac
|
||||||
|
}
|
||||||
|
|
||||||
// SetName sets the "name" field.
|
// SetName sets the "name" field.
|
||||||
func (ac *AccountCreate) SetName(s string) *AccountCreate {
|
func (ac *AccountCreate) SetName(s string) *AccountCreate {
|
||||||
ac.mutation.SetName(s)
|
ac.mutation.SetName(s)
|
||||||
return ac
|
return ac
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SetNillableName sets the "name" field if the given value is not nil.
|
||||||
|
func (ac *AccountCreate) SetNillableName(s *string) *AccountCreate {
|
||||||
|
if s != nil {
|
||||||
|
ac.SetName(*s)
|
||||||
|
}
|
||||||
|
return ac
|
||||||
|
}
|
||||||
|
|
||||||
// SetSecret sets the "secret" field.
|
// SetSecret sets the "secret" field.
|
||||||
func (ac *AccountCreate) SetSecret(b []byte) *AccountCreate {
|
func (ac *AccountCreate) SetSecret(b []byte) *AccountCreate {
|
||||||
ac.mutation.SetSecret(b)
|
ac.mutation.SetSecret(b)
|
||||||
@ -154,12 +170,6 @@ func (ac *AccountCreate) check() error {
|
|||||||
if _, ok := ac.mutation.UpdatedAt(); !ok {
|
if _, ok := ac.mutation.UpdatedAt(); !ok {
|
||||||
return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "Account.updated_at"`)}
|
return &ValidationError{Name: "updated_at", err: errors.New(`ent: missing required field "Account.updated_at"`)}
|
||||||
}
|
}
|
||||||
if _, ok := ac.mutation.Nickname(); !ok {
|
|
||||||
return &ValidationError{Name: "nickname", err: errors.New(`ent: missing required field "Account.nickname"`)}
|
|
||||||
}
|
|
||||||
if _, ok := ac.mutation.Name(); !ok {
|
|
||||||
return &ValidationError{Name: "name", err: errors.New(`ent: missing required field "Account.name"`)}
|
|
||||||
}
|
|
||||||
if _, ok := ac.mutation.Secret(); !ok {
|
if _, ok := ac.mutation.Secret(); !ok {
|
||||||
return &ValidationError{Name: "secret", err: errors.New(`ent: missing required field "Account.secret"`)}
|
return &ValidationError{Name: "secret", err: errors.New(`ent: missing required field "Account.secret"`)}
|
||||||
}
|
}
|
||||||
|
@ -50,6 +50,12 @@ func (au *AccountUpdate) SetNillableNickname(s *string) *AccountUpdate {
|
|||||||
return au
|
return au
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ClearNickname clears the value of the "nickname" field.
|
||||||
|
func (au *AccountUpdate) ClearNickname() *AccountUpdate {
|
||||||
|
au.mutation.ClearNickname()
|
||||||
|
return au
|
||||||
|
}
|
||||||
|
|
||||||
// SetName sets the "name" field.
|
// SetName sets the "name" field.
|
||||||
func (au *AccountUpdate) SetName(s string) *AccountUpdate {
|
func (au *AccountUpdate) SetName(s string) *AccountUpdate {
|
||||||
au.mutation.SetName(s)
|
au.mutation.SetName(s)
|
||||||
@ -64,6 +70,12 @@ func (au *AccountUpdate) SetNillableName(s *string) *AccountUpdate {
|
|||||||
return au
|
return au
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ClearName clears the value of the "name" field.
|
||||||
|
func (au *AccountUpdate) ClearName() *AccountUpdate {
|
||||||
|
au.mutation.ClearName()
|
||||||
|
return au
|
||||||
|
}
|
||||||
|
|
||||||
// SetSecret sets the "secret" field.
|
// SetSecret sets the "secret" field.
|
||||||
func (au *AccountUpdate) SetSecret(b []byte) *AccountUpdate {
|
func (au *AccountUpdate) SetSecret(b []byte) *AccountUpdate {
|
||||||
au.mutation.SetSecret(b)
|
au.mutation.SetSecret(b)
|
||||||
@ -187,9 +199,15 @@ func (au *AccountUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
|||||||
if value, ok := au.mutation.Nickname(); ok {
|
if value, ok := au.mutation.Nickname(); ok {
|
||||||
_spec.SetField(account.FieldNickname, field.TypeString, value)
|
_spec.SetField(account.FieldNickname, field.TypeString, value)
|
||||||
}
|
}
|
||||||
|
if au.mutation.NicknameCleared() {
|
||||||
|
_spec.ClearField(account.FieldNickname, field.TypeString)
|
||||||
|
}
|
||||||
if value, ok := au.mutation.Name(); ok {
|
if value, ok := au.mutation.Name(); ok {
|
||||||
_spec.SetField(account.FieldName, field.TypeString, value)
|
_spec.SetField(account.FieldName, field.TypeString, value)
|
||||||
}
|
}
|
||||||
|
if au.mutation.NameCleared() {
|
||||||
|
_spec.ClearField(account.FieldName, field.TypeString)
|
||||||
|
}
|
||||||
if value, ok := au.mutation.Secret(); ok {
|
if value, ok := au.mutation.Secret(); ok {
|
||||||
_spec.SetField(account.FieldSecret, field.TypeBytes, value)
|
_spec.SetField(account.FieldSecret, field.TypeBytes, value)
|
||||||
}
|
}
|
||||||
@ -284,6 +302,12 @@ func (auo *AccountUpdateOne) SetNillableNickname(s *string) *AccountUpdateOne {
|
|||||||
return auo
|
return auo
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ClearNickname clears the value of the "nickname" field.
|
||||||
|
func (auo *AccountUpdateOne) ClearNickname() *AccountUpdateOne {
|
||||||
|
auo.mutation.ClearNickname()
|
||||||
|
return auo
|
||||||
|
}
|
||||||
|
|
||||||
// SetName sets the "name" field.
|
// SetName sets the "name" field.
|
||||||
func (auo *AccountUpdateOne) SetName(s string) *AccountUpdateOne {
|
func (auo *AccountUpdateOne) SetName(s string) *AccountUpdateOne {
|
||||||
auo.mutation.SetName(s)
|
auo.mutation.SetName(s)
|
||||||
@ -298,6 +322,12 @@ func (auo *AccountUpdateOne) SetNillableName(s *string) *AccountUpdateOne {
|
|||||||
return auo
|
return auo
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ClearName clears the value of the "name" field.
|
||||||
|
func (auo *AccountUpdateOne) ClearName() *AccountUpdateOne {
|
||||||
|
auo.mutation.ClearName()
|
||||||
|
return auo
|
||||||
|
}
|
||||||
|
|
||||||
// SetSecret sets the "secret" field.
|
// SetSecret sets the "secret" field.
|
||||||
func (auo *AccountUpdateOne) SetSecret(b []byte) *AccountUpdateOne {
|
func (auo *AccountUpdateOne) SetSecret(b []byte) *AccountUpdateOne {
|
||||||
auo.mutation.SetSecret(b)
|
auo.mutation.SetSecret(b)
|
||||||
@ -451,9 +481,15 @@ func (auo *AccountUpdateOne) sqlSave(ctx context.Context) (_node *Account, err e
|
|||||||
if value, ok := auo.mutation.Nickname(); ok {
|
if value, ok := auo.mutation.Nickname(); ok {
|
||||||
_spec.SetField(account.FieldNickname, field.TypeString, value)
|
_spec.SetField(account.FieldNickname, field.TypeString, value)
|
||||||
}
|
}
|
||||||
|
if auo.mutation.NicknameCleared() {
|
||||||
|
_spec.ClearField(account.FieldNickname, field.TypeString)
|
||||||
|
}
|
||||||
if value, ok := auo.mutation.Name(); ok {
|
if value, ok := auo.mutation.Name(); ok {
|
||||||
_spec.SetField(account.FieldName, field.TypeString, value)
|
_spec.SetField(account.FieldName, field.TypeString, value)
|
||||||
}
|
}
|
||||||
|
if auo.mutation.NameCleared() {
|
||||||
|
_spec.ClearField(account.FieldName, field.TypeString)
|
||||||
|
}
|
||||||
if value, ok := auo.mutation.Secret(); ok {
|
if value, ok := auo.mutation.Secret(); ok {
|
||||||
_spec.SetField(account.FieldSecret, field.TypeBytes, value)
|
_spec.SetField(account.FieldSecret, field.TypeBytes, value)
|
||||||
}
|
}
|
||||||
|
@ -465,15 +465,15 @@ func (c *EmailClient) GetX(ctx context.Context, id uuid.UUID) *Email {
|
|||||||
return obj
|
return obj
|
||||||
}
|
}
|
||||||
|
|
||||||
// QueryAccounts queries the accounts edge of a Email.
|
// QueryAccount queries the account edge of a Email.
|
||||||
func (c *EmailClient) QueryAccounts(e *Email) *AccountQuery {
|
func (c *EmailClient) QueryAccount(e *Email) *AccountQuery {
|
||||||
query := (&AccountClient{config: c.config}).Query()
|
query := (&AccountClient{config: c.config}).Query()
|
||||||
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
query.path = func(context.Context) (fromV *sql.Selector, _ error) {
|
||||||
id := e.ID
|
id := e.ID
|
||||||
step := sqlgraph.NewStep(
|
step := sqlgraph.NewStep(
|
||||||
sqlgraph.From(email.Table, email.FieldID, id),
|
sqlgraph.From(email.Table, email.FieldID, id),
|
||||||
sqlgraph.To(account.Table, account.FieldID),
|
sqlgraph.To(account.Table, account.FieldID),
|
||||||
sqlgraph.Edge(sqlgraph.M2O, true, email.AccountsTable, email.AccountsColumn),
|
sqlgraph.Edge(sqlgraph.M2O, true, email.AccountTable, email.AccountColumn),
|
||||||
)
|
)
|
||||||
fromV = sqlgraph.Neighbors(e.driver.Dialect(), step)
|
fromV = sqlgraph.Neighbors(e.driver.Dialect(), step)
|
||||||
return fromV, nil
|
return fromV, nil
|
||||||
|
20
ent/email.go
20
ent/email.go
@ -37,22 +37,22 @@ type Email struct {
|
|||||||
|
|
||||||
// EmailEdges holds the relations/edges for other nodes in the graph.
|
// EmailEdges holds the relations/edges for other nodes in the graph.
|
||||||
type EmailEdges struct {
|
type EmailEdges struct {
|
||||||
// Accounts holds the value of the accounts edge.
|
// Account holds the value of the account edge.
|
||||||
Accounts *Account `json:"accounts,omitempty"`
|
Account *Account `json:"account,omitempty"`
|
||||||
// loadedTypes holds the information for reporting if a
|
// loadedTypes holds the information for reporting if a
|
||||||
// type was loaded (or requested) in eager-loading or not.
|
// type was loaded (or requested) in eager-loading or not.
|
||||||
loadedTypes [1]bool
|
loadedTypes [1]bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// AccountsOrErr returns the Accounts value or an error if the edge
|
// AccountOrErr returns the Account value or an error if the edge
|
||||||
// was not loaded in eager-loading, or loaded but was not found.
|
// was not loaded in eager-loading, or loaded but was not found.
|
||||||
func (e EmailEdges) AccountsOrErr() (*Account, error) {
|
func (e EmailEdges) AccountOrErr() (*Account, error) {
|
||||||
if e.Accounts != nil {
|
if e.Account != nil {
|
||||||
return e.Accounts, nil
|
return e.Account, nil
|
||||||
} else if e.loadedTypes[0] {
|
} else if e.loadedTypes[0] {
|
||||||
return nil, &NotFoundError{label: account.Label}
|
return nil, &NotFoundError{label: account.Label}
|
||||||
}
|
}
|
||||||
return nil, &NotLoadedError{edge: "accounts"}
|
return nil, &NotLoadedError{edge: "account"}
|
||||||
}
|
}
|
||||||
|
|
||||||
// scanValues returns the types for scanning values from sql.Rows.
|
// scanValues returns the types for scanning values from sql.Rows.
|
||||||
@ -139,9 +139,9 @@ func (e *Email) Value(name string) (ent.Value, error) {
|
|||||||
return e.selectValues.Get(name)
|
return e.selectValues.Get(name)
|
||||||
}
|
}
|
||||||
|
|
||||||
// QueryAccounts queries the "accounts" edge of the Email entity.
|
// QueryAccount queries the "account" edge of the Email entity.
|
||||||
func (e *Email) QueryAccounts() *AccountQuery {
|
func (e *Email) QueryAccount() *AccountQuery {
|
||||||
return NewEmailClient(e.config).QueryAccounts(e)
|
return NewEmailClient(e.config).QueryAccount(e)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update returns a builder for updating this Email.
|
// Update returns a builder for updating this Email.
|
||||||
|
@ -22,17 +22,17 @@ const (
|
|||||||
FieldVerificationCode = "verification_code"
|
FieldVerificationCode = "verification_code"
|
||||||
// FieldResetCode holds the string denoting the reset_code field in the database.
|
// FieldResetCode holds the string denoting the reset_code field in the database.
|
||||||
FieldResetCode = "reset_code"
|
FieldResetCode = "reset_code"
|
||||||
// EdgeAccounts holds the string denoting the accounts edge name in mutations.
|
// EdgeAccount holds the string denoting the account edge name in mutations.
|
||||||
EdgeAccounts = "accounts"
|
EdgeAccount = "account"
|
||||||
// Table holds the table name of the email in the database.
|
// Table holds the table name of the email in the database.
|
||||||
Table = "emails"
|
Table = "emails"
|
||||||
// AccountsTable is the table that holds the accounts relation/edge.
|
// AccountTable is the table that holds the account relation/edge.
|
||||||
AccountsTable = "emails"
|
AccountTable = "emails"
|
||||||
// AccountsInverseTable is the table name for the Account entity.
|
// AccountInverseTable is the table name for the Account entity.
|
||||||
// It exists in this package in order to avoid circular dependency with the "account" package.
|
// It exists in this package in order to avoid circular dependency with the "account" package.
|
||||||
AccountsInverseTable = "accounts"
|
AccountInverseTable = "accounts"
|
||||||
// AccountsColumn is the table column denoting the accounts relation/edge.
|
// AccountColumn is the table column denoting the account relation/edge.
|
||||||
AccountsColumn = "account_emails"
|
AccountColumn = "account_emails"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Columns holds all SQL columns for email fields.
|
// Columns holds all SQL columns for email fields.
|
||||||
@ -106,16 +106,16 @@ func ByResetCode(opts ...sql.OrderTermOption) OrderOption {
|
|||||||
return sql.OrderByField(FieldResetCode, opts...).ToFunc()
|
return sql.OrderByField(FieldResetCode, opts...).ToFunc()
|
||||||
}
|
}
|
||||||
|
|
||||||
// ByAccountsField orders the results by accounts field.
|
// ByAccountField orders the results by account field.
|
||||||
func ByAccountsField(field string, opts ...sql.OrderTermOption) OrderOption {
|
func ByAccountField(field string, opts ...sql.OrderTermOption) OrderOption {
|
||||||
return func(s *sql.Selector) {
|
return func(s *sql.Selector) {
|
||||||
sqlgraph.OrderByNeighborTerms(s, newAccountsStep(), sql.OrderByField(field, opts...))
|
sqlgraph.OrderByNeighborTerms(s, newAccountStep(), sql.OrderByField(field, opts...))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
func newAccountsStep() *sqlgraph.Step {
|
func newAccountStep() *sqlgraph.Step {
|
||||||
return sqlgraph.NewStep(
|
return sqlgraph.NewStep(
|
||||||
sqlgraph.From(Table, FieldID),
|
sqlgraph.From(Table, FieldID),
|
||||||
sqlgraph.To(AccountsInverseTable, FieldID),
|
sqlgraph.To(AccountInverseTable, FieldID),
|
||||||
sqlgraph.Edge(sqlgraph.M2O, true, AccountsTable, AccountsColumn),
|
sqlgraph.Edge(sqlgraph.M2O, true, AccountTable, AccountColumn),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -314,21 +314,21 @@ func ResetCodeContainsFold(v string) predicate.Email {
|
|||||||
return predicate.Email(sql.FieldContainsFold(FieldResetCode, v))
|
return predicate.Email(sql.FieldContainsFold(FieldResetCode, v))
|
||||||
}
|
}
|
||||||
|
|
||||||
// HasAccounts applies the HasEdge predicate on the "accounts" edge.
|
// HasAccount applies the HasEdge predicate on the "account" edge.
|
||||||
func HasAccounts() predicate.Email {
|
func HasAccount() predicate.Email {
|
||||||
return predicate.Email(func(s *sql.Selector) {
|
return predicate.Email(func(s *sql.Selector) {
|
||||||
step := sqlgraph.NewStep(
|
step := sqlgraph.NewStep(
|
||||||
sqlgraph.From(Table, FieldID),
|
sqlgraph.From(Table, FieldID),
|
||||||
sqlgraph.Edge(sqlgraph.M2O, true, AccountsTable, AccountsColumn),
|
sqlgraph.Edge(sqlgraph.M2O, true, AccountTable, AccountColumn),
|
||||||
)
|
)
|
||||||
sqlgraph.HasNeighbors(s, step)
|
sqlgraph.HasNeighbors(s, step)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// HasAccountsWith applies the HasEdge predicate on the "accounts" edge with a given conditions (other predicates).
|
// HasAccountWith applies the HasEdge predicate on the "account" edge with a given conditions (other predicates).
|
||||||
func HasAccountsWith(preds ...predicate.Account) predicate.Email {
|
func HasAccountWith(preds ...predicate.Account) predicate.Email {
|
||||||
return predicate.Email(func(s *sql.Selector) {
|
return predicate.Email(func(s *sql.Selector) {
|
||||||
step := newAccountsStep()
|
step := newAccountStep()
|
||||||
sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) {
|
sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) {
|
||||||
for _, p := range preds {
|
for _, p := range preds {
|
||||||
p(s)
|
p(s)
|
||||||
|
@ -89,23 +89,23 @@ func (ec *EmailCreate) SetID(u uuid.UUID) *EmailCreate {
|
|||||||
return ec
|
return ec
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetAccountsID sets the "accounts" edge to the Account entity by ID.
|
// SetAccountID sets the "account" edge to the Account entity by ID.
|
||||||
func (ec *EmailCreate) SetAccountsID(id uuid.UUID) *EmailCreate {
|
func (ec *EmailCreate) SetAccountID(id uuid.UUID) *EmailCreate {
|
||||||
ec.mutation.SetAccountsID(id)
|
ec.mutation.SetAccountID(id)
|
||||||
return ec
|
return ec
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetNillableAccountsID sets the "accounts" edge to the Account entity by ID if the given value is not nil.
|
// SetNillableAccountID sets the "account" edge to the Account entity by ID if the given value is not nil.
|
||||||
func (ec *EmailCreate) SetNillableAccountsID(id *uuid.UUID) *EmailCreate {
|
func (ec *EmailCreate) SetNillableAccountID(id *uuid.UUID) *EmailCreate {
|
||||||
if id != nil {
|
if id != nil {
|
||||||
ec = ec.SetAccountsID(*id)
|
ec = ec.SetAccountID(*id)
|
||||||
}
|
}
|
||||||
return ec
|
return ec
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetAccounts sets the "accounts" edge to the Account entity.
|
// SetAccount sets the "account" edge to the Account entity.
|
||||||
func (ec *EmailCreate) SetAccounts(a *Account) *EmailCreate {
|
func (ec *EmailCreate) SetAccount(a *Account) *EmailCreate {
|
||||||
return ec.SetAccountsID(a.ID)
|
return ec.SetAccountID(a.ID)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mutation returns the EmailMutation object of the builder.
|
// Mutation returns the EmailMutation object of the builder.
|
||||||
@ -219,12 +219,12 @@ func (ec *EmailCreate) createSpec() (*Email, *sqlgraph.CreateSpec) {
|
|||||||
_spec.SetField(email.FieldResetCode, field.TypeString, value)
|
_spec.SetField(email.FieldResetCode, field.TypeString, value)
|
||||||
_node.ResetCode = value
|
_node.ResetCode = value
|
||||||
}
|
}
|
||||||
if nodes := ec.mutation.AccountsIDs(); len(nodes) > 0 {
|
if nodes := ec.mutation.AccountIDs(); len(nodes) > 0 {
|
||||||
edge := &sqlgraph.EdgeSpec{
|
edge := &sqlgraph.EdgeSpec{
|
||||||
Rel: sqlgraph.M2O,
|
Rel: sqlgraph.M2O,
|
||||||
Inverse: true,
|
Inverse: true,
|
||||||
Table: email.AccountsTable,
|
Table: email.AccountTable,
|
||||||
Columns: []string{email.AccountsColumn},
|
Columns: []string{email.AccountColumn},
|
||||||
Bidi: false,
|
Bidi: false,
|
||||||
Target: &sqlgraph.EdgeTarget{
|
Target: &sqlgraph.EdgeTarget{
|
||||||
IDSpec: sqlgraph.NewFieldSpec(account.FieldID, field.TypeUUID),
|
IDSpec: sqlgraph.NewFieldSpec(account.FieldID, field.TypeUUID),
|
||||||
|
@ -24,7 +24,7 @@ type EmailQuery struct {
|
|||||||
order []email.OrderOption
|
order []email.OrderOption
|
||||||
inters []Interceptor
|
inters []Interceptor
|
||||||
predicates []predicate.Email
|
predicates []predicate.Email
|
||||||
withAccounts *AccountQuery
|
withAccount *AccountQuery
|
||||||
withFKs bool
|
withFKs bool
|
||||||
// intermediate query (i.e. traversal path).
|
// intermediate query (i.e. traversal path).
|
||||||
sql *sql.Selector
|
sql *sql.Selector
|
||||||
@ -62,8 +62,8 @@ func (eq *EmailQuery) Order(o ...email.OrderOption) *EmailQuery {
|
|||||||
return eq
|
return eq
|
||||||
}
|
}
|
||||||
|
|
||||||
// QueryAccounts chains the current query on the "accounts" edge.
|
// QueryAccount chains the current query on the "account" edge.
|
||||||
func (eq *EmailQuery) QueryAccounts() *AccountQuery {
|
func (eq *EmailQuery) QueryAccount() *AccountQuery {
|
||||||
query := (&AccountClient{config: eq.config}).Query()
|
query := (&AccountClient{config: eq.config}).Query()
|
||||||
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
|
query.path = func(ctx context.Context) (fromU *sql.Selector, err error) {
|
||||||
if err := eq.prepareQuery(ctx); err != nil {
|
if err := eq.prepareQuery(ctx); err != nil {
|
||||||
@ -76,7 +76,7 @@ func (eq *EmailQuery) QueryAccounts() *AccountQuery {
|
|||||||
step := sqlgraph.NewStep(
|
step := sqlgraph.NewStep(
|
||||||
sqlgraph.From(email.Table, email.FieldID, selector),
|
sqlgraph.From(email.Table, email.FieldID, selector),
|
||||||
sqlgraph.To(account.Table, account.FieldID),
|
sqlgraph.To(account.Table, account.FieldID),
|
||||||
sqlgraph.Edge(sqlgraph.M2O, true, email.AccountsTable, email.AccountsColumn),
|
sqlgraph.Edge(sqlgraph.M2O, true, email.AccountTable, email.AccountColumn),
|
||||||
)
|
)
|
||||||
fromU = sqlgraph.SetNeighbors(eq.driver.Dialect(), step)
|
fromU = sqlgraph.SetNeighbors(eq.driver.Dialect(), step)
|
||||||
return fromU, nil
|
return fromU, nil
|
||||||
@ -276,21 +276,21 @@ func (eq *EmailQuery) Clone() *EmailQuery {
|
|||||||
order: append([]email.OrderOption{}, eq.order...),
|
order: append([]email.OrderOption{}, eq.order...),
|
||||||
inters: append([]Interceptor{}, eq.inters...),
|
inters: append([]Interceptor{}, eq.inters...),
|
||||||
predicates: append([]predicate.Email{}, eq.predicates...),
|
predicates: append([]predicate.Email{}, eq.predicates...),
|
||||||
withAccounts: eq.withAccounts.Clone(),
|
withAccount: eq.withAccount.Clone(),
|
||||||
// clone intermediate query.
|
// clone intermediate query.
|
||||||
sql: eq.sql.Clone(),
|
sql: eq.sql.Clone(),
|
||||||
path: eq.path,
|
path: eq.path,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// WithAccounts tells the query-builder to eager-load the nodes that are connected to
|
// WithAccount tells the query-builder to eager-load the nodes that are connected to
|
||||||
// the "accounts" edge. The optional arguments are used to configure the query builder of the edge.
|
// the "account" edge. The optional arguments are used to configure the query builder of the edge.
|
||||||
func (eq *EmailQuery) WithAccounts(opts ...func(*AccountQuery)) *EmailQuery {
|
func (eq *EmailQuery) WithAccount(opts ...func(*AccountQuery)) *EmailQuery {
|
||||||
query := (&AccountClient{config: eq.config}).Query()
|
query := (&AccountClient{config: eq.config}).Query()
|
||||||
for _, opt := range opts {
|
for _, opt := range opts {
|
||||||
opt(query)
|
opt(query)
|
||||||
}
|
}
|
||||||
eq.withAccounts = query
|
eq.withAccount = query
|
||||||
return eq
|
return eq
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -374,10 +374,10 @@ func (eq *EmailQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Email,
|
|||||||
withFKs = eq.withFKs
|
withFKs = eq.withFKs
|
||||||
_spec = eq.querySpec()
|
_spec = eq.querySpec()
|
||||||
loadedTypes = [1]bool{
|
loadedTypes = [1]bool{
|
||||||
eq.withAccounts != nil,
|
eq.withAccount != nil,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
if eq.withAccounts != nil {
|
if eq.withAccount != nil {
|
||||||
withFKs = true
|
withFKs = true
|
||||||
}
|
}
|
||||||
if withFKs {
|
if withFKs {
|
||||||
@ -401,16 +401,16 @@ func (eq *EmailQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Email,
|
|||||||
if len(nodes) == 0 {
|
if len(nodes) == 0 {
|
||||||
return nodes, nil
|
return nodes, nil
|
||||||
}
|
}
|
||||||
if query := eq.withAccounts; query != nil {
|
if query := eq.withAccount; query != nil {
|
||||||
if err := eq.loadAccounts(ctx, query, nodes, nil,
|
if err := eq.loadAccount(ctx, query, nodes, nil,
|
||||||
func(n *Email, e *Account) { n.Edges.Accounts = e }); err != nil {
|
func(n *Email, e *Account) { n.Edges.Account = e }); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nodes, nil
|
return nodes, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (eq *EmailQuery) loadAccounts(ctx context.Context, query *AccountQuery, nodes []*Email, init func(*Email), assign func(*Email, *Account)) error {
|
func (eq *EmailQuery) loadAccount(ctx context.Context, query *AccountQuery, nodes []*Email, init func(*Email), assign func(*Email, *Account)) error {
|
||||||
ids := make([]uuid.UUID, 0, len(nodes))
|
ids := make([]uuid.UUID, 0, len(nodes))
|
||||||
nodeids := make(map[uuid.UUID][]*Email)
|
nodeids := make(map[uuid.UUID][]*Email)
|
||||||
for i := range nodes {
|
for i := range nodes {
|
||||||
|
@ -111,23 +111,23 @@ func (eu *EmailUpdate) ClearResetCode() *EmailUpdate {
|
|||||||
return eu
|
return eu
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetAccountsID sets the "accounts" edge to the Account entity by ID.
|
// SetAccountID sets the "account" edge to the Account entity by ID.
|
||||||
func (eu *EmailUpdate) SetAccountsID(id uuid.UUID) *EmailUpdate {
|
func (eu *EmailUpdate) SetAccountID(id uuid.UUID) *EmailUpdate {
|
||||||
eu.mutation.SetAccountsID(id)
|
eu.mutation.SetAccountID(id)
|
||||||
return eu
|
return eu
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetNillableAccountsID sets the "accounts" edge to the Account entity by ID if the given value is not nil.
|
// SetNillableAccountID sets the "account" edge to the Account entity by ID if the given value is not nil.
|
||||||
func (eu *EmailUpdate) SetNillableAccountsID(id *uuid.UUID) *EmailUpdate {
|
func (eu *EmailUpdate) SetNillableAccountID(id *uuid.UUID) *EmailUpdate {
|
||||||
if id != nil {
|
if id != nil {
|
||||||
eu = eu.SetAccountsID(*id)
|
eu = eu.SetAccountID(*id)
|
||||||
}
|
}
|
||||||
return eu
|
return eu
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetAccounts sets the "accounts" edge to the Account entity.
|
// SetAccount sets the "account" edge to the Account entity.
|
||||||
func (eu *EmailUpdate) SetAccounts(a *Account) *EmailUpdate {
|
func (eu *EmailUpdate) SetAccount(a *Account) *EmailUpdate {
|
||||||
return eu.SetAccountsID(a.ID)
|
return eu.SetAccountID(a.ID)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mutation returns the EmailMutation object of the builder.
|
// Mutation returns the EmailMutation object of the builder.
|
||||||
@ -135,9 +135,9 @@ func (eu *EmailUpdate) Mutation() *EmailMutation {
|
|||||||
return eu.mutation
|
return eu.mutation
|
||||||
}
|
}
|
||||||
|
|
||||||
// ClearAccounts clears the "accounts" edge to the Account entity.
|
// ClearAccount clears the "account" edge to the Account entity.
|
||||||
func (eu *EmailUpdate) ClearAccounts() *EmailUpdate {
|
func (eu *EmailUpdate) ClearAccount() *EmailUpdate {
|
||||||
eu.mutation.ClearAccounts()
|
eu.mutation.ClearAccount()
|
||||||
return eu
|
return eu
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -198,12 +198,12 @@ func (eu *EmailUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
|||||||
if eu.mutation.ResetCodeCleared() {
|
if eu.mutation.ResetCodeCleared() {
|
||||||
_spec.ClearField(email.FieldResetCode, field.TypeString)
|
_spec.ClearField(email.FieldResetCode, field.TypeString)
|
||||||
}
|
}
|
||||||
if eu.mutation.AccountsCleared() {
|
if eu.mutation.AccountCleared() {
|
||||||
edge := &sqlgraph.EdgeSpec{
|
edge := &sqlgraph.EdgeSpec{
|
||||||
Rel: sqlgraph.M2O,
|
Rel: sqlgraph.M2O,
|
||||||
Inverse: true,
|
Inverse: true,
|
||||||
Table: email.AccountsTable,
|
Table: email.AccountTable,
|
||||||
Columns: []string{email.AccountsColumn},
|
Columns: []string{email.AccountColumn},
|
||||||
Bidi: false,
|
Bidi: false,
|
||||||
Target: &sqlgraph.EdgeTarget{
|
Target: &sqlgraph.EdgeTarget{
|
||||||
IDSpec: sqlgraph.NewFieldSpec(account.FieldID, field.TypeUUID),
|
IDSpec: sqlgraph.NewFieldSpec(account.FieldID, field.TypeUUID),
|
||||||
@ -211,12 +211,12 @@ func (eu *EmailUpdate) sqlSave(ctx context.Context) (n int, err error) {
|
|||||||
}
|
}
|
||||||
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||||
}
|
}
|
||||||
if nodes := eu.mutation.AccountsIDs(); len(nodes) > 0 {
|
if nodes := eu.mutation.AccountIDs(); len(nodes) > 0 {
|
||||||
edge := &sqlgraph.EdgeSpec{
|
edge := &sqlgraph.EdgeSpec{
|
||||||
Rel: sqlgraph.M2O,
|
Rel: sqlgraph.M2O,
|
||||||
Inverse: true,
|
Inverse: true,
|
||||||
Table: email.AccountsTable,
|
Table: email.AccountTable,
|
||||||
Columns: []string{email.AccountsColumn},
|
Columns: []string{email.AccountColumn},
|
||||||
Bidi: false,
|
Bidi: false,
|
||||||
Target: &sqlgraph.EdgeTarget{
|
Target: &sqlgraph.EdgeTarget{
|
||||||
IDSpec: sqlgraph.NewFieldSpec(account.FieldID, field.TypeUUID),
|
IDSpec: sqlgraph.NewFieldSpec(account.FieldID, field.TypeUUID),
|
||||||
@ -329,23 +329,23 @@ func (euo *EmailUpdateOne) ClearResetCode() *EmailUpdateOne {
|
|||||||
return euo
|
return euo
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetAccountsID sets the "accounts" edge to the Account entity by ID.
|
// SetAccountID sets the "account" edge to the Account entity by ID.
|
||||||
func (euo *EmailUpdateOne) SetAccountsID(id uuid.UUID) *EmailUpdateOne {
|
func (euo *EmailUpdateOne) SetAccountID(id uuid.UUID) *EmailUpdateOne {
|
||||||
euo.mutation.SetAccountsID(id)
|
euo.mutation.SetAccountID(id)
|
||||||
return euo
|
return euo
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetNillableAccountsID sets the "accounts" edge to the Account entity by ID if the given value is not nil.
|
// SetNillableAccountID sets the "account" edge to the Account entity by ID if the given value is not nil.
|
||||||
func (euo *EmailUpdateOne) SetNillableAccountsID(id *uuid.UUID) *EmailUpdateOne {
|
func (euo *EmailUpdateOne) SetNillableAccountID(id *uuid.UUID) *EmailUpdateOne {
|
||||||
if id != nil {
|
if id != nil {
|
||||||
euo = euo.SetAccountsID(*id)
|
euo = euo.SetAccountID(*id)
|
||||||
}
|
}
|
||||||
return euo
|
return euo
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetAccounts sets the "accounts" edge to the Account entity.
|
// SetAccount sets the "account" edge to the Account entity.
|
||||||
func (euo *EmailUpdateOne) SetAccounts(a *Account) *EmailUpdateOne {
|
func (euo *EmailUpdateOne) SetAccount(a *Account) *EmailUpdateOne {
|
||||||
return euo.SetAccountsID(a.ID)
|
return euo.SetAccountID(a.ID)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mutation returns the EmailMutation object of the builder.
|
// Mutation returns the EmailMutation object of the builder.
|
||||||
@ -353,9 +353,9 @@ func (euo *EmailUpdateOne) Mutation() *EmailMutation {
|
|||||||
return euo.mutation
|
return euo.mutation
|
||||||
}
|
}
|
||||||
|
|
||||||
// ClearAccounts clears the "accounts" edge to the Account entity.
|
// ClearAccount clears the "account" edge to the Account entity.
|
||||||
func (euo *EmailUpdateOne) ClearAccounts() *EmailUpdateOne {
|
func (euo *EmailUpdateOne) ClearAccount() *EmailUpdateOne {
|
||||||
euo.mutation.ClearAccounts()
|
euo.mutation.ClearAccount()
|
||||||
return euo
|
return euo
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -446,12 +446,12 @@ func (euo *EmailUpdateOne) sqlSave(ctx context.Context) (_node *Email, err error
|
|||||||
if euo.mutation.ResetCodeCleared() {
|
if euo.mutation.ResetCodeCleared() {
|
||||||
_spec.ClearField(email.FieldResetCode, field.TypeString)
|
_spec.ClearField(email.FieldResetCode, field.TypeString)
|
||||||
}
|
}
|
||||||
if euo.mutation.AccountsCleared() {
|
if euo.mutation.AccountCleared() {
|
||||||
edge := &sqlgraph.EdgeSpec{
|
edge := &sqlgraph.EdgeSpec{
|
||||||
Rel: sqlgraph.M2O,
|
Rel: sqlgraph.M2O,
|
||||||
Inverse: true,
|
Inverse: true,
|
||||||
Table: email.AccountsTable,
|
Table: email.AccountTable,
|
||||||
Columns: []string{email.AccountsColumn},
|
Columns: []string{email.AccountColumn},
|
||||||
Bidi: false,
|
Bidi: false,
|
||||||
Target: &sqlgraph.EdgeTarget{
|
Target: &sqlgraph.EdgeTarget{
|
||||||
IDSpec: sqlgraph.NewFieldSpec(account.FieldID, field.TypeUUID),
|
IDSpec: sqlgraph.NewFieldSpec(account.FieldID, field.TypeUUID),
|
||||||
@ -459,12 +459,12 @@ func (euo *EmailUpdateOne) sqlSave(ctx context.Context) (_node *Email, err error
|
|||||||
}
|
}
|
||||||
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
||||||
}
|
}
|
||||||
if nodes := euo.mutation.AccountsIDs(); len(nodes) > 0 {
|
if nodes := euo.mutation.AccountIDs(); len(nodes) > 0 {
|
||||||
edge := &sqlgraph.EdgeSpec{
|
edge := &sqlgraph.EdgeSpec{
|
||||||
Rel: sqlgraph.M2O,
|
Rel: sqlgraph.M2O,
|
||||||
Inverse: true,
|
Inverse: true,
|
||||||
Table: email.AccountsTable,
|
Table: email.AccountTable,
|
||||||
Columns: []string{email.AccountsColumn},
|
Columns: []string{email.AccountColumn},
|
||||||
Bidi: false,
|
Bidi: false,
|
||||||
Target: &sqlgraph.EdgeTarget{
|
Target: &sqlgraph.EdgeTarget{
|
||||||
IDSpec: sqlgraph.NewFieldSpec(account.FieldID, field.TypeUUID),
|
IDSpec: sqlgraph.NewFieldSpec(account.FieldID, field.TypeUUID),
|
||||||
|
@ -13,8 +13,8 @@ var (
|
|||||||
{Name: "id", Type: field.TypeUUID, Unique: true, Default: "gen_random_uuid()"},
|
{Name: "id", Type: field.TypeUUID, Unique: true, Default: "gen_random_uuid()"},
|
||||||
{Name: "created_at", Type: field.TypeTime},
|
{Name: "created_at", Type: field.TypeTime},
|
||||||
{Name: "updated_at", Type: field.TypeTime},
|
{Name: "updated_at", Type: field.TypeTime},
|
||||||
{Name: "nickname", Type: field.TypeString},
|
{Name: "nickname", Type: field.TypeString, Nullable: true},
|
||||||
{Name: "name", Type: field.TypeString},
|
{Name: "name", Type: field.TypeString, Nullable: true},
|
||||||
{Name: "secret", Type: field.TypeBytes},
|
{Name: "secret", Type: field.TypeBytes},
|
||||||
{Name: "aes", Type: field.TypeBytes, Size: 32},
|
{Name: "aes", Type: field.TypeBytes, Size: 32},
|
||||||
{Name: "x509", Type: field.TypeBytes},
|
{Name: "x509", Type: field.TypeBytes},
|
||||||
|
113
ent/mutation.go
113
ent/mutation.go
@ -259,9 +259,22 @@ func (m *AccountMutation) OldNickname(ctx context.Context) (v string, err error)
|
|||||||
return oldValue.Nickname, nil
|
return oldValue.Nickname, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ClearNickname clears the value of the "nickname" field.
|
||||||
|
func (m *AccountMutation) ClearNickname() {
|
||||||
|
m.nickname = nil
|
||||||
|
m.clearedFields[account.FieldNickname] = struct{}{}
|
||||||
|
}
|
||||||
|
|
||||||
|
// NicknameCleared returns if the "nickname" field was cleared in this mutation.
|
||||||
|
func (m *AccountMutation) NicknameCleared() bool {
|
||||||
|
_, ok := m.clearedFields[account.FieldNickname]
|
||||||
|
return ok
|
||||||
|
}
|
||||||
|
|
||||||
// ResetNickname resets all changes to the "nickname" field.
|
// ResetNickname resets all changes to the "nickname" field.
|
||||||
func (m *AccountMutation) ResetNickname() {
|
func (m *AccountMutation) ResetNickname() {
|
||||||
m.nickname = nil
|
m.nickname = nil
|
||||||
|
delete(m.clearedFields, account.FieldNickname)
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetName sets the "name" field.
|
// SetName sets the "name" field.
|
||||||
@ -295,9 +308,22 @@ func (m *AccountMutation) OldName(ctx context.Context) (v string, err error) {
|
|||||||
return oldValue.Name, nil
|
return oldValue.Name, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ClearName clears the value of the "name" field.
|
||||||
|
func (m *AccountMutation) ClearName() {
|
||||||
|
m.name = nil
|
||||||
|
m.clearedFields[account.FieldName] = struct{}{}
|
||||||
|
}
|
||||||
|
|
||||||
|
// NameCleared returns if the "name" field was cleared in this mutation.
|
||||||
|
func (m *AccountMutation) NameCleared() bool {
|
||||||
|
_, ok := m.clearedFields[account.FieldName]
|
||||||
|
return ok
|
||||||
|
}
|
||||||
|
|
||||||
// ResetName resets all changes to the "name" field.
|
// ResetName resets all changes to the "name" field.
|
||||||
func (m *AccountMutation) ResetName() {
|
func (m *AccountMutation) ResetName() {
|
||||||
m.name = nil
|
m.name = nil
|
||||||
|
delete(m.clearedFields, account.FieldName)
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetSecret sets the "secret" field.
|
// SetSecret sets the "secret" field.
|
||||||
@ -650,7 +676,14 @@ func (m *AccountMutation) AddField(name string, value ent.Value) error {
|
|||||||
// ClearedFields returns all nullable fields that were cleared during this
|
// ClearedFields returns all nullable fields that were cleared during this
|
||||||
// mutation.
|
// mutation.
|
||||||
func (m *AccountMutation) ClearedFields() []string {
|
func (m *AccountMutation) ClearedFields() []string {
|
||||||
return nil
|
var fields []string
|
||||||
|
if m.FieldCleared(account.FieldNickname) {
|
||||||
|
fields = append(fields, account.FieldNickname)
|
||||||
|
}
|
||||||
|
if m.FieldCleared(account.FieldName) {
|
||||||
|
fields = append(fields, account.FieldName)
|
||||||
|
}
|
||||||
|
return fields
|
||||||
}
|
}
|
||||||
|
|
||||||
// FieldCleared returns a boolean indicating if a field with the given name was
|
// FieldCleared returns a boolean indicating if a field with the given name was
|
||||||
@ -663,6 +696,14 @@ func (m *AccountMutation) FieldCleared(name string) bool {
|
|||||||
// ClearField clears the value of the field with the given name. It returns an
|
// ClearField clears the value of the field with the given name. It returns an
|
||||||
// error if the field is not defined in the schema.
|
// error if the field is not defined in the schema.
|
||||||
func (m *AccountMutation) ClearField(name string) error {
|
func (m *AccountMutation) ClearField(name string) error {
|
||||||
|
switch name {
|
||||||
|
case account.FieldNickname:
|
||||||
|
m.ClearNickname()
|
||||||
|
return nil
|
||||||
|
case account.FieldName:
|
||||||
|
m.ClearName()
|
||||||
|
return nil
|
||||||
|
}
|
||||||
return fmt.Errorf("unknown Account nullable field %s", name)
|
return fmt.Errorf("unknown Account nullable field %s", name)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -791,8 +832,8 @@ type EmailMutation struct {
|
|||||||
verification_code *string
|
verification_code *string
|
||||||
reset_code *string
|
reset_code *string
|
||||||
clearedFields map[string]struct{}
|
clearedFields map[string]struct{}
|
||||||
accounts *uuid.UUID
|
account *uuid.UUID
|
||||||
clearedaccounts bool
|
clearedaccount bool
|
||||||
done bool
|
done bool
|
||||||
oldValue func(context.Context) (*Email, error)
|
oldValue func(context.Context) (*Email, error)
|
||||||
predicates []predicate.Email
|
predicates []predicate.Email
|
||||||
@ -1108,43 +1149,43 @@ func (m *EmailMutation) ResetResetCode() {
|
|||||||
delete(m.clearedFields, email.FieldResetCode)
|
delete(m.clearedFields, email.FieldResetCode)
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetAccountsID sets the "accounts" edge to the Account entity by id.
|
// SetAccountID sets the "account" edge to the Account entity by id.
|
||||||
func (m *EmailMutation) SetAccountsID(id uuid.UUID) {
|
func (m *EmailMutation) SetAccountID(id uuid.UUID) {
|
||||||
m.accounts = &id
|
m.account = &id
|
||||||
}
|
}
|
||||||
|
|
||||||
// ClearAccounts clears the "accounts" edge to the Account entity.
|
// ClearAccount clears the "account" edge to the Account entity.
|
||||||
func (m *EmailMutation) ClearAccounts() {
|
func (m *EmailMutation) ClearAccount() {
|
||||||
m.clearedaccounts = true
|
m.clearedaccount = true
|
||||||
}
|
}
|
||||||
|
|
||||||
// AccountsCleared reports if the "accounts" edge to the Account entity was cleared.
|
// AccountCleared reports if the "account" edge to the Account entity was cleared.
|
||||||
func (m *EmailMutation) AccountsCleared() bool {
|
func (m *EmailMutation) AccountCleared() bool {
|
||||||
return m.clearedaccounts
|
return m.clearedaccount
|
||||||
}
|
}
|
||||||
|
|
||||||
// AccountsID returns the "accounts" edge ID in the mutation.
|
// AccountID returns the "account" edge ID in the mutation.
|
||||||
func (m *EmailMutation) AccountsID() (id uuid.UUID, exists bool) {
|
func (m *EmailMutation) AccountID() (id uuid.UUID, exists bool) {
|
||||||
if m.accounts != nil {
|
if m.account != nil {
|
||||||
return *m.accounts, true
|
return *m.account, true
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// AccountsIDs returns the "accounts" edge IDs in the mutation.
|
// AccountIDs returns the "account" edge IDs in the mutation.
|
||||||
// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
|
// Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
|
||||||
// AccountsID instead. It exists only for internal usage by the builders.
|
// AccountID instead. It exists only for internal usage by the builders.
|
||||||
func (m *EmailMutation) AccountsIDs() (ids []uuid.UUID) {
|
func (m *EmailMutation) AccountIDs() (ids []uuid.UUID) {
|
||||||
if id := m.accounts; id != nil {
|
if id := m.account; id != nil {
|
||||||
ids = append(ids, *id)
|
ids = append(ids, *id)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// ResetAccounts resets all changes to the "accounts" edge.
|
// ResetAccount resets all changes to the "account" edge.
|
||||||
func (m *EmailMutation) ResetAccounts() {
|
func (m *EmailMutation) ResetAccount() {
|
||||||
m.accounts = nil
|
m.account = nil
|
||||||
m.clearedaccounts = false
|
m.clearedaccount = false
|
||||||
}
|
}
|
||||||
|
|
||||||
// Where appends a list predicates to the EmailMutation builder.
|
// Where appends a list predicates to the EmailMutation builder.
|
||||||
@ -1364,8 +1405,8 @@ func (m *EmailMutation) ResetField(name string) error {
|
|||||||
// AddedEdges returns all edge names that were set/added in this mutation.
|
// AddedEdges returns all edge names that were set/added in this mutation.
|
||||||
func (m *EmailMutation) AddedEdges() []string {
|
func (m *EmailMutation) AddedEdges() []string {
|
||||||
edges := make([]string, 0, 1)
|
edges := make([]string, 0, 1)
|
||||||
if m.accounts != nil {
|
if m.account != nil {
|
||||||
edges = append(edges, email.EdgeAccounts)
|
edges = append(edges, email.EdgeAccount)
|
||||||
}
|
}
|
||||||
return edges
|
return edges
|
||||||
}
|
}
|
||||||
@ -1374,8 +1415,8 @@ func (m *EmailMutation) AddedEdges() []string {
|
|||||||
// name in this mutation.
|
// name in this mutation.
|
||||||
func (m *EmailMutation) AddedIDs(name string) []ent.Value {
|
func (m *EmailMutation) AddedIDs(name string) []ent.Value {
|
||||||
switch name {
|
switch name {
|
||||||
case email.EdgeAccounts:
|
case email.EdgeAccount:
|
||||||
if id := m.accounts; id != nil {
|
if id := m.account; id != nil {
|
||||||
return []ent.Value{*id}
|
return []ent.Value{*id}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1397,8 +1438,8 @@ func (m *EmailMutation) RemovedIDs(name string) []ent.Value {
|
|||||||
// ClearedEdges returns all edge names that were cleared in this mutation.
|
// ClearedEdges returns all edge names that were cleared in this mutation.
|
||||||
func (m *EmailMutation) ClearedEdges() []string {
|
func (m *EmailMutation) ClearedEdges() []string {
|
||||||
edges := make([]string, 0, 1)
|
edges := make([]string, 0, 1)
|
||||||
if m.clearedaccounts {
|
if m.clearedaccount {
|
||||||
edges = append(edges, email.EdgeAccounts)
|
edges = append(edges, email.EdgeAccount)
|
||||||
}
|
}
|
||||||
return edges
|
return edges
|
||||||
}
|
}
|
||||||
@ -1407,8 +1448,8 @@ func (m *EmailMutation) ClearedEdges() []string {
|
|||||||
// was cleared in this mutation.
|
// was cleared in this mutation.
|
||||||
func (m *EmailMutation) EdgeCleared(name string) bool {
|
func (m *EmailMutation) EdgeCleared(name string) bool {
|
||||||
switch name {
|
switch name {
|
||||||
case email.EdgeAccounts:
|
case email.EdgeAccount:
|
||||||
return m.clearedaccounts
|
return m.clearedaccount
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
@ -1417,8 +1458,8 @@ func (m *EmailMutation) EdgeCleared(name string) bool {
|
|||||||
// if that edge is not defined in the schema.
|
// if that edge is not defined in the schema.
|
||||||
func (m *EmailMutation) ClearEdge(name string) error {
|
func (m *EmailMutation) ClearEdge(name string) error {
|
||||||
switch name {
|
switch name {
|
||||||
case email.EdgeAccounts:
|
case email.EdgeAccount:
|
||||||
m.ClearAccounts()
|
m.ClearAccount()
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return fmt.Errorf("unknown Email unique edge %s", name)
|
return fmt.Errorf("unknown Email unique edge %s", name)
|
||||||
@ -1428,8 +1469,8 @@ func (m *EmailMutation) ClearEdge(name string) error {
|
|||||||
// It returns an error if the edge is not defined in the schema.
|
// It returns an error if the edge is not defined in the schema.
|
||||||
func (m *EmailMutation) ResetEdge(name string) error {
|
func (m *EmailMutation) ResetEdge(name string) error {
|
||||||
switch name {
|
switch name {
|
||||||
case email.EdgeAccounts:
|
case email.EdgeAccount:
|
||||||
m.ResetAccounts()
|
m.ResetAccount()
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return fmt.Errorf("unknown Email edge %s", name)
|
return fmt.Errorf("unknown Email edge %s", name)
|
||||||
|
@ -5,6 +5,6 @@ package runtime
|
|||||||
// The schema-stitching logic is generated in code.icod.de/auth/accountserver/ent/runtime.go
|
// The schema-stitching logic is generated in code.icod.de/auth/accountserver/ent/runtime.go
|
||||||
|
|
||||||
const (
|
const (
|
||||||
Version = "v0.14.0" // Version of ent codegen.
|
Version = "v0.14.1" // Version of ent codegen.
|
||||||
Sum = "h1:EO3Z9aZ5bXJatJeGqu/EVdnNr6K4mRq3rWe5owt0MC4=" // Sum of ent codegen.
|
Sum = "h1:fUERL506Pqr92EPHJqr8EYxbPioflJo6PudkrEA8a/s=" // Sum of ent codegen.
|
||||||
)
|
)
|
||||||
|
@ -20,8 +20,8 @@ func (Account) Fields() []ent.Field {
|
|||||||
field.UUID("id", uuid.UUID{}).Unique().Immutable().Annotations(&entsql.Annotation{Default: "gen_random_uuid()"}),
|
field.UUID("id", uuid.UUID{}).Unique().Immutable().Annotations(&entsql.Annotation{Default: "gen_random_uuid()"}),
|
||||||
field.Time("created_at").Default(time.Now).Immutable(),
|
field.Time("created_at").Default(time.Now).Immutable(),
|
||||||
field.Time("updated_at").Default(time.Now).UpdateDefault(time.Now),
|
field.Time("updated_at").Default(time.Now).UpdateDefault(time.Now),
|
||||||
field.String("nickname"),
|
field.String("nickname").Optional(),
|
||||||
field.String("name"),
|
field.String("name").Optional(),
|
||||||
field.Bytes("secret"),
|
field.Bytes("secret"),
|
||||||
field.Bytes("aes").MinLen(16).MaxLen(32),
|
field.Bytes("aes").MinLen(16).MaxLen(32),
|
||||||
field.Bytes("x509"),
|
field.Bytes("x509"),
|
||||||
|
@ -28,6 +28,6 @@ func (Email) Fields() []ent.Field {
|
|||||||
// Edges of the Email.
|
// Edges of the Email.
|
||||||
func (Email) Edges() []ent.Edge {
|
func (Email) Edges() []ent.Edge {
|
||||||
return []ent.Edge{
|
return []ent.Edge{
|
||||||
edge.From("accounts", Account.Type).Ref("emails").Unique(),
|
edge.From("account", Account.Type).Ref("emails").Unique(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
20
go.mod
20
go.mod
@ -3,14 +3,30 @@ module code.icod.de/auth/accountserver
|
|||||||
go 1.23.0
|
go 1.23.0
|
||||||
|
|
||||||
require (
|
require (
|
||||||
entgo.io/ent v0.14.0
|
entgo.io/ent v0.14.1
|
||||||
github.com/google/uuid v1.3.0
|
github.com/google/uuid v1.6.0
|
||||||
github.com/spf13/cobra v1.8.1
|
github.com/spf13/cobra v1.8.1
|
||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
|
ariga.io/atlas v0.27.0 // indirect
|
||||||
|
github.com/agext/levenshtein v1.2.3 // indirect
|
||||||
|
github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect
|
||||||
|
github.com/apparentlymart/go-textseg/v15 v15.0.0 // indirect
|
||||||
|
github.com/go-openapi/inflect v0.21.0 // indirect
|
||||||
|
github.com/google/go-cmp v0.6.0 // indirect
|
||||||
|
github.com/hashicorp/hcl/v2 v2.22.0 // indirect
|
||||||
github.com/idc77/gomail v0.0.0-20240819113050-ac97008b42eb // indirect
|
github.com/idc77/gomail v0.0.0-20240819113050-ac97008b42eb // indirect
|
||||||
github.com/inconshreveable/mousetrap v1.1.0 // indirect
|
github.com/inconshreveable/mousetrap v1.1.0 // indirect
|
||||||
|
github.com/matthewhartstonge/argon2 v1.0.1-0.20240808062706-62179c3b7f7d // indirect
|
||||||
|
github.com/mitchellh/go-wordwrap v1.0.1 // indirect
|
||||||
github.com/spf13/pflag v1.0.5 // indirect
|
github.com/spf13/pflag v1.0.5 // indirect
|
||||||
|
github.com/zclconf/go-cty v1.15.0 // indirect
|
||||||
|
golang.org/x/crypto v0.26.0 // indirect
|
||||||
|
golang.org/x/mod v0.20.0 // indirect
|
||||||
|
golang.org/x/sync v0.8.0 // indirect
|
||||||
|
golang.org/x/sys v0.23.0 // indirect
|
||||||
|
golang.org/x/text v0.17.0 // indirect
|
||||||
|
golang.org/x/tools v0.24.0 // indirect
|
||||||
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc // indirect
|
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc // indirect
|
||||||
)
|
)
|
||||||
|
38
go.sum
38
go.sum
@ -1,30 +1,52 @@
|
|||||||
ariga.io/atlas v0.19.1-0.20240203083654-5948b60a8e43 h1:GwdJbXydHCYPedeeLt4x/lrlIISQ4JTH1mRWuE5ZZ14=
|
ariga.io/atlas v0.19.1-0.20240203083654-5948b60a8e43 h1:GwdJbXydHCYPedeeLt4x/lrlIISQ4JTH1mRWuE5ZZ14=
|
||||||
ariga.io/atlas v0.19.1-0.20240203083654-5948b60a8e43/go.mod h1:uj3pm+hUTVN/X5yfdBexHlZv+1Xu5u5ZbZx7+CDavNU=
|
ariga.io/atlas v0.19.1-0.20240203083654-5948b60a8e43/go.mod h1:uj3pm+hUTVN/X5yfdBexHlZv+1Xu5u5ZbZx7+CDavNU=
|
||||||
|
ariga.io/atlas v0.27.0 h1:UHUQMTRx2Vz8/acJxEfcC/zL2wY739/vkZzt7L8HL8I=
|
||||||
|
ariga.io/atlas v0.27.0/go.mod h1:KPLc7Zj+nzoXfWshrcY1RwlOh94dsATQEy4UPrF2RkM=
|
||||||
entgo.io/ent v0.14.0 h1:EO3Z9aZ5bXJatJeGqu/EVdnNr6K4mRq3rWe5owt0MC4=
|
entgo.io/ent v0.14.0 h1:EO3Z9aZ5bXJatJeGqu/EVdnNr6K4mRq3rWe5owt0MC4=
|
||||||
entgo.io/ent v0.14.0/go.mod h1:qCEmo+biw3ccBn9OyL4ZK5dfpwg++l1Gxwac5B1206A=
|
entgo.io/ent v0.14.0/go.mod h1:qCEmo+biw3ccBn9OyL4ZK5dfpwg++l1Gxwac5B1206A=
|
||||||
|
entgo.io/ent v0.14.1 h1:fUERL506Pqr92EPHJqr8EYxbPioflJo6PudkrEA8a/s=
|
||||||
|
entgo.io/ent v0.14.1/go.mod h1:MH6XLG0KXpkcDQhKiHfANZSzR55TJyPL5IGNpI8wpco=
|
||||||
github.com/agext/levenshtein v1.2.1 h1:QmvMAjj2aEICytGiWzmxoE0x2KZvE0fvmqMOfy2tjT8=
|
github.com/agext/levenshtein v1.2.1 h1:QmvMAjj2aEICytGiWzmxoE0x2KZvE0fvmqMOfy2tjT8=
|
||||||
github.com/agext/levenshtein v1.2.1/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558=
|
github.com/agext/levenshtein v1.2.1/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558=
|
||||||
|
github.com/agext/levenshtein v1.2.3 h1:YB2fHEn0UJagG8T1rrWknE3ZQzWM06O8AMAatNn7lmo=
|
||||||
|
github.com/agext/levenshtein v1.2.3/go.mod h1:JEDfjyjHDjOF/1e4FlBE/PkbqA9OfWu2ki2W0IB5558=
|
||||||
github.com/apparentlymart/go-textseg/v13 v13.0.0 h1:Y+KvPE1NYz0xl601PVImeQfFyEy6iT90AvPUL1NNfNw=
|
github.com/apparentlymart/go-textseg/v13 v13.0.0 h1:Y+KvPE1NYz0xl601PVImeQfFyEy6iT90AvPUL1NNfNw=
|
||||||
github.com/apparentlymart/go-textseg/v13 v13.0.0/go.mod h1:ZK2fH7c4NqDTLtiYLvIkEghdlcqw7yxLeM89kiTRPUo=
|
github.com/apparentlymart/go-textseg/v13 v13.0.0/go.mod h1:ZK2fH7c4NqDTLtiYLvIkEghdlcqw7yxLeM89kiTRPUo=
|
||||||
|
github.com/apparentlymart/go-textseg/v15 v15.0.0 h1:uYvfpb3DyLSCGWnctWKGj857c6ew1u1fNQOlOtuGxQY=
|
||||||
|
github.com/apparentlymart/go-textseg/v15 v15.0.0/go.mod h1:K8XmNZdhEBkdlyDdvbmmsvpAG721bKi0joRfFdHIWJ4=
|
||||||
github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
|
github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
|
||||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/go-openapi/inflect v0.19.0 h1:9jCH9scKIbHeV9m12SmPilScz6krDxKRasNNSNPXu/4=
|
github.com/go-openapi/inflect v0.19.0 h1:9jCH9scKIbHeV9m12SmPilScz6krDxKRasNNSNPXu/4=
|
||||||
github.com/go-openapi/inflect v0.19.0/go.mod h1:lHpZVlpIQqLyKwJ4N+YSc9hchQy/i12fJykb83CRBH4=
|
github.com/go-openapi/inflect v0.19.0/go.mod h1:lHpZVlpIQqLyKwJ4N+YSc9hchQy/i12fJykb83CRBH4=
|
||||||
|
github.com/go-openapi/inflect v0.21.0 h1:FoBjBTQEcbg2cJUWX6uwL9OyIW8eqc9k4KhN4lfbeYk=
|
||||||
|
github.com/go-openapi/inflect v0.21.0/go.mod h1:INezMuUu7SJQc2AyR3WO0DqqYUJSj8Kb4hBd7WtjlAw=
|
||||||
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
|
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
|
||||||
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||||
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
|
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
|
||||||
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||||
|
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
|
||||||
|
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||||
github.com/hashicorp/hcl/v2 v2.13.0 h1:0Apadu1w6M11dyGFxWnmhhcMjkbAiKCv7G1r/2QgCNc=
|
github.com/hashicorp/hcl/v2 v2.13.0 h1:0Apadu1w6M11dyGFxWnmhhcMjkbAiKCv7G1r/2QgCNc=
|
||||||
github.com/hashicorp/hcl/v2 v2.13.0/go.mod h1:e4z5nxYlWNPdDSNYX+ph14EvWYMFm3eP0zIUqPc2jr0=
|
github.com/hashicorp/hcl/v2 v2.13.0/go.mod h1:e4z5nxYlWNPdDSNYX+ph14EvWYMFm3eP0zIUqPc2jr0=
|
||||||
|
github.com/hashicorp/hcl/v2 v2.22.0 h1:hkZ3nCtqeJsDhPRFz5EA9iwcG1hNWGePOTw6oyul12M=
|
||||||
|
github.com/hashicorp/hcl/v2 v2.22.0/go.mod h1:62ZYHrXgPoX8xBnzl8QzbWq4dyDsDtfCRgIq1rbJEvA=
|
||||||
github.com/idc77/gomail v0.0.0-20240819113050-ac97008b42eb h1:eoCCdEgNvIAO3+sb7drW2gV36JOkILxyJllfEUHoo1A=
|
github.com/idc77/gomail v0.0.0-20240819113050-ac97008b42eb h1:eoCCdEgNvIAO3+sb7drW2gV36JOkILxyJllfEUHoo1A=
|
||||||
github.com/idc77/gomail v0.0.0-20240819113050-ac97008b42eb/go.mod h1:iRMDvqBOUICvDAsSzKcIBfFLghLJ1EeXBe6tH7Mmv6U=
|
github.com/idc77/gomail v0.0.0-20240819113050-ac97008b42eb/go.mod h1:iRMDvqBOUICvDAsSzKcIBfFLghLJ1EeXBe6tH7Mmv6U=
|
||||||
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
|
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
|
||||||
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
|
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
|
||||||
|
github.com/matthewhartstonge/argon2 v0.2.1 h1:DFzhPfXcKv4T/ITjoTtEDE/WP1G2eutQBntAzKPtXtc=
|
||||||
|
github.com/matthewhartstonge/argon2 v0.2.1/go.mod h1:k3jqoN+y0w9Z6uJxIKiJDveAMDUaIBJkC/M2m37q6VM=
|
||||||
|
github.com/matthewhartstonge/argon2 v1.0.0 h1:e65fkae6O8Na6YTy2HAccUbXR+GQHOnpQxeWGqWCRIw=
|
||||||
|
github.com/matthewhartstonge/argon2 v1.0.0/go.mod h1:Fm4FHZxdxCM6hg21Jkz3YZVKnU7VnTlqDQ3ghS/Myok=
|
||||||
|
github.com/matthewhartstonge/argon2 v1.0.1-0.20240808062706-62179c3b7f7d h1:hC2uziFpDurWy5AkRw4rvvwWKtCE8bitk8j1hi46u9Q=
|
||||||
|
github.com/matthewhartstonge/argon2 v1.0.1-0.20240808062706-62179c3b7f7d/go.mod h1:n7RqvFKNEe5liRkiltnbmRiKGYUzPkNqzg1pBrmnDIs=
|
||||||
github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/QdE+0=
|
github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/QdE+0=
|
||||||
github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
|
github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
|
||||||
github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7 h1:DpOJ2HYzCv8LZP15IdmG+YdwD2luVPHITV96TkirNBM=
|
github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7 h1:DpOJ2HYzCv8LZP15IdmG+YdwD2luVPHITV96TkirNBM=
|
||||||
github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo=
|
github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo=
|
||||||
|
github.com/mitchellh/go-wordwrap v1.0.1 h1:TLuKupo69TCn6TQSyGxwI1EblZZEsQ0vMlAFQflz0v0=
|
||||||
|
github.com/mitchellh/go-wordwrap v1.0.1/go.mod h1:R62XHJLzvMFRBbcrT7m7WgmE1eOyTSsCt+hzestvNj0=
|
||||||
github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec=
|
github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec=
|
||||||
github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY=
|
github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY=
|
||||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||||
@ -38,14 +60,30 @@ github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ
|
|||||||
github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
||||||
github.com/zclconf/go-cty v1.8.0 h1:s4AvqaeQzJIu3ndv4gVIhplVD0krU+bgrcLSVUnaWuA=
|
github.com/zclconf/go-cty v1.8.0 h1:s4AvqaeQzJIu3ndv4gVIhplVD0krU+bgrcLSVUnaWuA=
|
||||||
github.com/zclconf/go-cty v1.8.0/go.mod h1:vVKLxnk3puL4qRAv72AO+W99LUD4da90g3uUAzyuvAk=
|
github.com/zclconf/go-cty v1.8.0/go.mod h1:vVKLxnk3puL4qRAv72AO+W99LUD4da90g3uUAzyuvAk=
|
||||||
|
github.com/zclconf/go-cty v1.15.0 h1:tTCRWxsexYUmtt/wVxgDClUe+uQusuI443uL6e+5sXQ=
|
||||||
|
github.com/zclconf/go-cty v1.15.0/go.mod h1:VvMs5i0vgZdhYawQNq5kePSpLAoz8u1xvZgrPIxfnZE=
|
||||||
|
golang.org/x/crypto v0.16.0 h1:mMMrFzRSCF0GvB7Ne27XVtVAaXLrPmgPC7/v0tkwHaY=
|
||||||
|
golang.org/x/crypto v0.16.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4=
|
||||||
|
golang.org/x/crypto v0.26.0 h1:RrRspgV4mU+YwB4FYnuBoKsUapNIL5cohGAmSH3azsw=
|
||||||
|
golang.org/x/crypto v0.26.0/go.mod h1:GY7jblb9wI+FOo5y8/S2oY4zWP07AkOJ4+jxCqdqn54=
|
||||||
golang.org/x/mod v0.15.0 h1:SernR4v+D55NyBH2QiEQrlBAnj1ECL6AGrA5+dPaMY8=
|
golang.org/x/mod v0.15.0 h1:SernR4v+D55NyBH2QiEQrlBAnj1ECL6AGrA5+dPaMY8=
|
||||||
golang.org/x/mod v0.15.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
|
golang.org/x/mod v0.15.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
|
||||||
|
golang.org/x/mod v0.20.0 h1:utOm6MM3R3dnawAiJgn0y+xvuYRsm1RKM/4giyfDgV0=
|
||||||
|
golang.org/x/mod v0.20.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
|
||||||
golang.org/x/sync v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ=
|
golang.org/x/sync v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ=
|
||||||
golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
|
golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
|
||||||
|
golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ=
|
||||||
|
golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
|
||||||
|
golang.org/x/sys v0.23.0 h1:YfKFowiIMvtgl1UERQoTPPToxltDeZfbj4H7dVUCwmM=
|
||||||
|
golang.org/x/sys v0.23.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||||
golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k=
|
golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k=
|
||||||
golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
|
golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
|
||||||
|
golang.org/x/text v0.17.0 h1:XtiM5bkSOt+ewxlOE/aE/AKEHibwj/6gvWMl9Rsh0Qc=
|
||||||
|
golang.org/x/text v0.17.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
|
||||||
golang.org/x/tools v0.18.0 h1:k8NLag8AGHnn+PHbl7g43CtqZAwG60vZkLqgyZgIHgQ=
|
golang.org/x/tools v0.18.0 h1:k8NLag8AGHnn+PHbl7g43CtqZAwG60vZkLqgyZgIHgQ=
|
||||||
golang.org/x/tools v0.18.0/go.mod h1:GL7B4CwcLLeo59yx/9UWWuNOW1n3VZ4f5axWfML7Lcg=
|
golang.org/x/tools v0.18.0/go.mod h1:GL7B4CwcLLeo59yx/9UWWuNOW1n3VZ4f5axWfML7Lcg=
|
||||||
|
golang.org/x/tools v0.24.0 h1:J1shsA93PJUEVaUSaay7UXAyE8aimq3GW0pjlolpa24=
|
||||||
|
golang.org/x/tools v0.24.0/go.mod h1:YhNqVBIfWHdzvTLs0d8LCuMhkKUgSUKldakyV7W/WDQ=
|
||||||
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc h1:2gGKlE2+asNV9m7xrywl36YYNnBG5ZQ0r/BOOxqPpmk=
|
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc h1:2gGKlE2+asNV9m7xrywl36YYNnBG5ZQ0r/BOOxqPpmk=
|
||||||
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc/go.mod h1:m7x9LTH6d71AHyAX77c9yqWCCa3UKHcVEj9y7hAtKDk=
|
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc/go.mod h1:m7x9LTH6d71AHyAX77c9yqWCCa3UKHcVEj9y7hAtKDk=
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
|
@ -1,8 +1,60 @@
|
|||||||
package service
|
package service
|
||||||
|
|
||||||
type CreateAccountInput struct{}
|
import (
|
||||||
|
"code.icod.de/auth/accountserver/util"
|
||||||
|
"context"
|
||||||
|
"errors"
|
||||||
|
"github.com/matthewhartstonge/argon2"
|
||||||
|
)
|
||||||
|
|
||||||
|
type CreateAccountInput struct {
|
||||||
|
Name string `json:"name,omitempty"`
|
||||||
|
Nickname string `json:"nickname,omitempty"`
|
||||||
|
Email string `json:"email"`
|
||||||
|
Secret string `json:"secret"`
|
||||||
|
}
|
||||||
|
|
||||||
// CreateAccount creates an account, returns nil if successful or error if not
|
// CreateAccount creates an account, returns nil if successful or error if not
|
||||||
func (s *Service) CreateAccount(in *CreateAccountInput) error {
|
func (s *Service) CreateAccount(in *CreateAccountInput) error {
|
||||||
|
// hash the secret with argon2
|
||||||
|
argon := argon2.DefaultConfig()
|
||||||
|
encoded, e := argon.HashEncoded([]byte(in.Secret))
|
||||||
|
if e != nil {
|
||||||
|
return errors.New("create account: could not encode secret: " + e.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
// generate aes key
|
||||||
|
k := util.GenerateRandomKey(32)
|
||||||
|
|
||||||
|
create := s.client.Account.Create()
|
||||||
|
create = create.SetSecret(encoded)
|
||||||
|
create = create.SetAes(k)
|
||||||
|
if in.Name != "" {
|
||||||
|
create = create.SetName(in.Name)
|
||||||
|
}
|
||||||
|
if in.Nickname != "" {
|
||||||
|
create = create.SetNickname(in.Nickname)
|
||||||
|
}
|
||||||
|
a, e := create.Save(context.Background())
|
||||||
|
if e != nil {
|
||||||
|
return errors.New("create account: could not save account to database" + e.Error())
|
||||||
|
}
|
||||||
|
cei := new(CreateEmailInput)
|
||||||
|
cei.Account = a
|
||||||
|
cei.Email = in.Email
|
||||||
|
cei.Primary = true
|
||||||
|
return s.CreateEmail(cei)
|
||||||
|
}
|
||||||
|
|
||||||
|
type ReplaceAccountInput struct{}
|
||||||
|
|
||||||
|
// ReplaceAccount updates, replaces an account.
|
||||||
|
func (s *Service) ReplaceAccount(input *ReplaceAccountInput) error {
|
||||||
|
panic("implement me")
|
||||||
|
}
|
||||||
|
|
||||||
|
type DeleteAccountInput struct{}
|
||||||
|
|
||||||
|
func (s *Service) DeleteAccount(input *DeleteAccountInput) error {
|
||||||
panic("implement me")
|
panic("implement me")
|
||||||
}
|
}
|
||||||
|
@ -1 +1,25 @@
|
|||||||
package service
|
package service
|
||||||
|
|
||||||
|
import (
|
||||||
|
"code.icod.de/auth/accountserver/ent"
|
||||||
|
"context"
|
||||||
|
"errors"
|
||||||
|
)
|
||||||
|
|
||||||
|
type CreateEmailInput struct {
|
||||||
|
Account *ent.Account
|
||||||
|
Primary bool
|
||||||
|
Email string
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *Service) CreateEmail(in *CreateEmailInput) error {
|
||||||
|
create := s.client.Email.Create()
|
||||||
|
create.SetEmail(in.Email)
|
||||||
|
create.SetPrimary(in.Primary)
|
||||||
|
create.SetAccount(in.Account)
|
||||||
|
_, e := create.Save(context.Background())
|
||||||
|
if e != nil {
|
||||||
|
return errors.New("create email: failed to save to database: " + e.Error())
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
14
util/random.go
Normal file
14
util/random.go
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
package util
|
||||||
|
|
||||||
|
import (
|
||||||
|
"crypto/rand"
|
||||||
|
"io"
|
||||||
|
)
|
||||||
|
|
||||||
|
func GenerateRandomKey(length int) []byte {
|
||||||
|
k := make([]byte, length)
|
||||||
|
if _, err := io.ReadFull(rand.Reader, k); err != nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return k
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user