1179 lines
41 KiB
Go
1179 lines
41 KiB
Go
// Code generated by ent, DO NOT EDIT.
|
|
|
|
package ent
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"fmt"
|
|
"time"
|
|
|
|
"entgo.io/ent/dialect/sql"
|
|
"entgo.io/ent/dialect/sql/sqlgraph"
|
|
"entgo.io/ent/schema/field"
|
|
"github.com/Wei-Shaw/sub2api/ent/identityadoptiondecision"
|
|
"github.com/Wei-Shaw/sub2api/ent/pendingauthsession"
|
|
"github.com/Wei-Shaw/sub2api/ent/predicate"
|
|
"github.com/Wei-Shaw/sub2api/ent/user"
|
|
)
|
|
|
|
// PendingAuthSessionUpdate is the builder for updating PendingAuthSession entities.
|
|
type PendingAuthSessionUpdate struct {
|
|
config
|
|
hooks []Hook
|
|
mutation *PendingAuthSessionMutation
|
|
}
|
|
|
|
// Where appends a list predicates to the PendingAuthSessionUpdate builder.
|
|
func (_u *PendingAuthSessionUpdate) Where(ps ...predicate.PendingAuthSession) *PendingAuthSessionUpdate {
|
|
_u.mutation.Where(ps...)
|
|
return _u
|
|
}
|
|
|
|
// SetUpdatedAt sets the "updated_at" field.
|
|
func (_u *PendingAuthSessionUpdate) SetUpdatedAt(v time.Time) *PendingAuthSessionUpdate {
|
|
_u.mutation.SetUpdatedAt(v)
|
|
return _u
|
|
}
|
|
|
|
// SetSessionToken sets the "session_token" field.
|
|
func (_u *PendingAuthSessionUpdate) SetSessionToken(v string) *PendingAuthSessionUpdate {
|
|
_u.mutation.SetSessionToken(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableSessionToken sets the "session_token" field if the given value is not nil.
|
|
func (_u *PendingAuthSessionUpdate) SetNillableSessionToken(v *string) *PendingAuthSessionUpdate {
|
|
if v != nil {
|
|
_u.SetSessionToken(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetIntent sets the "intent" field.
|
|
func (_u *PendingAuthSessionUpdate) SetIntent(v string) *PendingAuthSessionUpdate {
|
|
_u.mutation.SetIntent(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableIntent sets the "intent" field if the given value is not nil.
|
|
func (_u *PendingAuthSessionUpdate) SetNillableIntent(v *string) *PendingAuthSessionUpdate {
|
|
if v != nil {
|
|
_u.SetIntent(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetProviderType sets the "provider_type" field.
|
|
func (_u *PendingAuthSessionUpdate) SetProviderType(v string) *PendingAuthSessionUpdate {
|
|
_u.mutation.SetProviderType(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableProviderType sets the "provider_type" field if the given value is not nil.
|
|
func (_u *PendingAuthSessionUpdate) SetNillableProviderType(v *string) *PendingAuthSessionUpdate {
|
|
if v != nil {
|
|
_u.SetProviderType(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetProviderKey sets the "provider_key" field.
|
|
func (_u *PendingAuthSessionUpdate) SetProviderKey(v string) *PendingAuthSessionUpdate {
|
|
_u.mutation.SetProviderKey(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableProviderKey sets the "provider_key" field if the given value is not nil.
|
|
func (_u *PendingAuthSessionUpdate) SetNillableProviderKey(v *string) *PendingAuthSessionUpdate {
|
|
if v != nil {
|
|
_u.SetProviderKey(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetProviderSubject sets the "provider_subject" field.
|
|
func (_u *PendingAuthSessionUpdate) SetProviderSubject(v string) *PendingAuthSessionUpdate {
|
|
_u.mutation.SetProviderSubject(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableProviderSubject sets the "provider_subject" field if the given value is not nil.
|
|
func (_u *PendingAuthSessionUpdate) SetNillableProviderSubject(v *string) *PendingAuthSessionUpdate {
|
|
if v != nil {
|
|
_u.SetProviderSubject(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetTargetUserID sets the "target_user_id" field.
|
|
func (_u *PendingAuthSessionUpdate) SetTargetUserID(v int64) *PendingAuthSessionUpdate {
|
|
_u.mutation.SetTargetUserID(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableTargetUserID sets the "target_user_id" field if the given value is not nil.
|
|
func (_u *PendingAuthSessionUpdate) SetNillableTargetUserID(v *int64) *PendingAuthSessionUpdate {
|
|
if v != nil {
|
|
_u.SetTargetUserID(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearTargetUserID clears the value of the "target_user_id" field.
|
|
func (_u *PendingAuthSessionUpdate) ClearTargetUserID() *PendingAuthSessionUpdate {
|
|
_u.mutation.ClearTargetUserID()
|
|
return _u
|
|
}
|
|
|
|
// SetRedirectTo sets the "redirect_to" field.
|
|
func (_u *PendingAuthSessionUpdate) SetRedirectTo(v string) *PendingAuthSessionUpdate {
|
|
_u.mutation.SetRedirectTo(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableRedirectTo sets the "redirect_to" field if the given value is not nil.
|
|
func (_u *PendingAuthSessionUpdate) SetNillableRedirectTo(v *string) *PendingAuthSessionUpdate {
|
|
if v != nil {
|
|
_u.SetRedirectTo(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetResolvedEmail sets the "resolved_email" field.
|
|
func (_u *PendingAuthSessionUpdate) SetResolvedEmail(v string) *PendingAuthSessionUpdate {
|
|
_u.mutation.SetResolvedEmail(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableResolvedEmail sets the "resolved_email" field if the given value is not nil.
|
|
func (_u *PendingAuthSessionUpdate) SetNillableResolvedEmail(v *string) *PendingAuthSessionUpdate {
|
|
if v != nil {
|
|
_u.SetResolvedEmail(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetRegistrationPasswordHash sets the "registration_password_hash" field.
|
|
func (_u *PendingAuthSessionUpdate) SetRegistrationPasswordHash(v string) *PendingAuthSessionUpdate {
|
|
_u.mutation.SetRegistrationPasswordHash(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableRegistrationPasswordHash sets the "registration_password_hash" field if the given value is not nil.
|
|
func (_u *PendingAuthSessionUpdate) SetNillableRegistrationPasswordHash(v *string) *PendingAuthSessionUpdate {
|
|
if v != nil {
|
|
_u.SetRegistrationPasswordHash(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetUpstreamIdentityClaims sets the "upstream_identity_claims" field.
|
|
func (_u *PendingAuthSessionUpdate) SetUpstreamIdentityClaims(v map[string]interface{}) *PendingAuthSessionUpdate {
|
|
_u.mutation.SetUpstreamIdentityClaims(v)
|
|
return _u
|
|
}
|
|
|
|
// SetLocalFlowState sets the "local_flow_state" field.
|
|
func (_u *PendingAuthSessionUpdate) SetLocalFlowState(v map[string]interface{}) *PendingAuthSessionUpdate {
|
|
_u.mutation.SetLocalFlowState(v)
|
|
return _u
|
|
}
|
|
|
|
// SetBrowserSessionKey sets the "browser_session_key" field.
|
|
func (_u *PendingAuthSessionUpdate) SetBrowserSessionKey(v string) *PendingAuthSessionUpdate {
|
|
_u.mutation.SetBrowserSessionKey(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableBrowserSessionKey sets the "browser_session_key" field if the given value is not nil.
|
|
func (_u *PendingAuthSessionUpdate) SetNillableBrowserSessionKey(v *string) *PendingAuthSessionUpdate {
|
|
if v != nil {
|
|
_u.SetBrowserSessionKey(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetCompletionCodeHash sets the "completion_code_hash" field.
|
|
func (_u *PendingAuthSessionUpdate) SetCompletionCodeHash(v string) *PendingAuthSessionUpdate {
|
|
_u.mutation.SetCompletionCodeHash(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableCompletionCodeHash sets the "completion_code_hash" field if the given value is not nil.
|
|
func (_u *PendingAuthSessionUpdate) SetNillableCompletionCodeHash(v *string) *PendingAuthSessionUpdate {
|
|
if v != nil {
|
|
_u.SetCompletionCodeHash(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetCompletionCodeExpiresAt sets the "completion_code_expires_at" field.
|
|
func (_u *PendingAuthSessionUpdate) SetCompletionCodeExpiresAt(v time.Time) *PendingAuthSessionUpdate {
|
|
_u.mutation.SetCompletionCodeExpiresAt(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableCompletionCodeExpiresAt sets the "completion_code_expires_at" field if the given value is not nil.
|
|
func (_u *PendingAuthSessionUpdate) SetNillableCompletionCodeExpiresAt(v *time.Time) *PendingAuthSessionUpdate {
|
|
if v != nil {
|
|
_u.SetCompletionCodeExpiresAt(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearCompletionCodeExpiresAt clears the value of the "completion_code_expires_at" field.
|
|
func (_u *PendingAuthSessionUpdate) ClearCompletionCodeExpiresAt() *PendingAuthSessionUpdate {
|
|
_u.mutation.ClearCompletionCodeExpiresAt()
|
|
return _u
|
|
}
|
|
|
|
// SetEmailVerifiedAt sets the "email_verified_at" field.
|
|
func (_u *PendingAuthSessionUpdate) SetEmailVerifiedAt(v time.Time) *PendingAuthSessionUpdate {
|
|
_u.mutation.SetEmailVerifiedAt(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableEmailVerifiedAt sets the "email_verified_at" field if the given value is not nil.
|
|
func (_u *PendingAuthSessionUpdate) SetNillableEmailVerifiedAt(v *time.Time) *PendingAuthSessionUpdate {
|
|
if v != nil {
|
|
_u.SetEmailVerifiedAt(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearEmailVerifiedAt clears the value of the "email_verified_at" field.
|
|
func (_u *PendingAuthSessionUpdate) ClearEmailVerifiedAt() *PendingAuthSessionUpdate {
|
|
_u.mutation.ClearEmailVerifiedAt()
|
|
return _u
|
|
}
|
|
|
|
// SetPasswordVerifiedAt sets the "password_verified_at" field.
|
|
func (_u *PendingAuthSessionUpdate) SetPasswordVerifiedAt(v time.Time) *PendingAuthSessionUpdate {
|
|
_u.mutation.SetPasswordVerifiedAt(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillablePasswordVerifiedAt sets the "password_verified_at" field if the given value is not nil.
|
|
func (_u *PendingAuthSessionUpdate) SetNillablePasswordVerifiedAt(v *time.Time) *PendingAuthSessionUpdate {
|
|
if v != nil {
|
|
_u.SetPasswordVerifiedAt(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearPasswordVerifiedAt clears the value of the "password_verified_at" field.
|
|
func (_u *PendingAuthSessionUpdate) ClearPasswordVerifiedAt() *PendingAuthSessionUpdate {
|
|
_u.mutation.ClearPasswordVerifiedAt()
|
|
return _u
|
|
}
|
|
|
|
// SetTotpVerifiedAt sets the "totp_verified_at" field.
|
|
func (_u *PendingAuthSessionUpdate) SetTotpVerifiedAt(v time.Time) *PendingAuthSessionUpdate {
|
|
_u.mutation.SetTotpVerifiedAt(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableTotpVerifiedAt sets the "totp_verified_at" field if the given value is not nil.
|
|
func (_u *PendingAuthSessionUpdate) SetNillableTotpVerifiedAt(v *time.Time) *PendingAuthSessionUpdate {
|
|
if v != nil {
|
|
_u.SetTotpVerifiedAt(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearTotpVerifiedAt clears the value of the "totp_verified_at" field.
|
|
func (_u *PendingAuthSessionUpdate) ClearTotpVerifiedAt() *PendingAuthSessionUpdate {
|
|
_u.mutation.ClearTotpVerifiedAt()
|
|
return _u
|
|
}
|
|
|
|
// SetExpiresAt sets the "expires_at" field.
|
|
func (_u *PendingAuthSessionUpdate) SetExpiresAt(v time.Time) *PendingAuthSessionUpdate {
|
|
_u.mutation.SetExpiresAt(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableExpiresAt sets the "expires_at" field if the given value is not nil.
|
|
func (_u *PendingAuthSessionUpdate) SetNillableExpiresAt(v *time.Time) *PendingAuthSessionUpdate {
|
|
if v != nil {
|
|
_u.SetExpiresAt(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetConsumedAt sets the "consumed_at" field.
|
|
func (_u *PendingAuthSessionUpdate) SetConsumedAt(v time.Time) *PendingAuthSessionUpdate {
|
|
_u.mutation.SetConsumedAt(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableConsumedAt sets the "consumed_at" field if the given value is not nil.
|
|
func (_u *PendingAuthSessionUpdate) SetNillableConsumedAt(v *time.Time) *PendingAuthSessionUpdate {
|
|
if v != nil {
|
|
_u.SetConsumedAt(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearConsumedAt clears the value of the "consumed_at" field.
|
|
func (_u *PendingAuthSessionUpdate) ClearConsumedAt() *PendingAuthSessionUpdate {
|
|
_u.mutation.ClearConsumedAt()
|
|
return _u
|
|
}
|
|
|
|
// SetTargetUser sets the "target_user" edge to the User entity.
|
|
func (_u *PendingAuthSessionUpdate) SetTargetUser(v *User) *PendingAuthSessionUpdate {
|
|
return _u.SetTargetUserID(v.ID)
|
|
}
|
|
|
|
// SetAdoptionDecisionID sets the "adoption_decision" edge to the IdentityAdoptionDecision entity by ID.
|
|
func (_u *PendingAuthSessionUpdate) SetAdoptionDecisionID(id int64) *PendingAuthSessionUpdate {
|
|
_u.mutation.SetAdoptionDecisionID(id)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableAdoptionDecisionID sets the "adoption_decision" edge to the IdentityAdoptionDecision entity by ID if the given value is not nil.
|
|
func (_u *PendingAuthSessionUpdate) SetNillableAdoptionDecisionID(id *int64) *PendingAuthSessionUpdate {
|
|
if id != nil {
|
|
_u = _u.SetAdoptionDecisionID(*id)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetAdoptionDecision sets the "adoption_decision" edge to the IdentityAdoptionDecision entity.
|
|
func (_u *PendingAuthSessionUpdate) SetAdoptionDecision(v *IdentityAdoptionDecision) *PendingAuthSessionUpdate {
|
|
return _u.SetAdoptionDecisionID(v.ID)
|
|
}
|
|
|
|
// Mutation returns the PendingAuthSessionMutation object of the builder.
|
|
func (_u *PendingAuthSessionUpdate) Mutation() *PendingAuthSessionMutation {
|
|
return _u.mutation
|
|
}
|
|
|
|
// ClearTargetUser clears the "target_user" edge to the User entity.
|
|
func (_u *PendingAuthSessionUpdate) ClearTargetUser() *PendingAuthSessionUpdate {
|
|
_u.mutation.ClearTargetUser()
|
|
return _u
|
|
}
|
|
|
|
// ClearAdoptionDecision clears the "adoption_decision" edge to the IdentityAdoptionDecision entity.
|
|
func (_u *PendingAuthSessionUpdate) ClearAdoptionDecision() *PendingAuthSessionUpdate {
|
|
_u.mutation.ClearAdoptionDecision()
|
|
return _u
|
|
}
|
|
|
|
// Save executes the query and returns the number of nodes affected by the update operation.
|
|
func (_u *PendingAuthSessionUpdate) Save(ctx context.Context) (int, error) {
|
|
_u.defaults()
|
|
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
|
|
}
|
|
|
|
// SaveX is like Save, but panics if an error occurs.
|
|
func (_u *PendingAuthSessionUpdate) SaveX(ctx context.Context) int {
|
|
affected, err := _u.Save(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return affected
|
|
}
|
|
|
|
// Exec executes the query.
|
|
func (_u *PendingAuthSessionUpdate) Exec(ctx context.Context) error {
|
|
_, err := _u.Save(ctx)
|
|
return err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (_u *PendingAuthSessionUpdate) ExecX(ctx context.Context) {
|
|
if err := _u.Exec(ctx); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
|
|
// defaults sets the default values of the builder before save.
|
|
func (_u *PendingAuthSessionUpdate) defaults() {
|
|
if _, ok := _u.mutation.UpdatedAt(); !ok {
|
|
v := pendingauthsession.UpdateDefaultUpdatedAt()
|
|
_u.mutation.SetUpdatedAt(v)
|
|
}
|
|
}
|
|
|
|
// check runs all checks and user-defined validators on the builder.
|
|
func (_u *PendingAuthSessionUpdate) check() error {
|
|
if v, ok := _u.mutation.SessionToken(); ok {
|
|
if err := pendingauthsession.SessionTokenValidator(v); err != nil {
|
|
return &ValidationError{Name: "session_token", err: fmt.Errorf(`ent: validator failed for field "PendingAuthSession.session_token": %w`, err)}
|
|
}
|
|
}
|
|
if v, ok := _u.mutation.Intent(); ok {
|
|
if err := pendingauthsession.IntentValidator(v); err != nil {
|
|
return &ValidationError{Name: "intent", err: fmt.Errorf(`ent: validator failed for field "PendingAuthSession.intent": %w`, err)}
|
|
}
|
|
}
|
|
if v, ok := _u.mutation.ProviderType(); ok {
|
|
if err := pendingauthsession.ProviderTypeValidator(v); err != nil {
|
|
return &ValidationError{Name: "provider_type", err: fmt.Errorf(`ent: validator failed for field "PendingAuthSession.provider_type": %w`, err)}
|
|
}
|
|
}
|
|
if v, ok := _u.mutation.ProviderKey(); ok {
|
|
if err := pendingauthsession.ProviderKeyValidator(v); err != nil {
|
|
return &ValidationError{Name: "provider_key", err: fmt.Errorf(`ent: validator failed for field "PendingAuthSession.provider_key": %w`, err)}
|
|
}
|
|
}
|
|
if v, ok := _u.mutation.ProviderSubject(); ok {
|
|
if err := pendingauthsession.ProviderSubjectValidator(v); err != nil {
|
|
return &ValidationError{Name: "provider_subject", err: fmt.Errorf(`ent: validator failed for field "PendingAuthSession.provider_subject": %w`, err)}
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (_u *PendingAuthSessionUpdate) sqlSave(ctx context.Context) (_node int, err error) {
|
|
if err := _u.check(); err != nil {
|
|
return _node, err
|
|
}
|
|
_spec := sqlgraph.NewUpdateSpec(pendingauthsession.Table, pendingauthsession.Columns, sqlgraph.NewFieldSpec(pendingauthsession.FieldID, field.TypeInt64))
|
|
if ps := _u.mutation.predicates; len(ps) > 0 {
|
|
_spec.Predicate = func(selector *sql.Selector) {
|
|
for i := range ps {
|
|
ps[i](selector)
|
|
}
|
|
}
|
|
}
|
|
if value, ok := _u.mutation.UpdatedAt(); ok {
|
|
_spec.SetField(pendingauthsession.FieldUpdatedAt, field.TypeTime, value)
|
|
}
|
|
if value, ok := _u.mutation.SessionToken(); ok {
|
|
_spec.SetField(pendingauthsession.FieldSessionToken, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.Intent(); ok {
|
|
_spec.SetField(pendingauthsession.FieldIntent, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.ProviderType(); ok {
|
|
_spec.SetField(pendingauthsession.FieldProviderType, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.ProviderKey(); ok {
|
|
_spec.SetField(pendingauthsession.FieldProviderKey, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.ProviderSubject(); ok {
|
|
_spec.SetField(pendingauthsession.FieldProviderSubject, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.RedirectTo(); ok {
|
|
_spec.SetField(pendingauthsession.FieldRedirectTo, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.ResolvedEmail(); ok {
|
|
_spec.SetField(pendingauthsession.FieldResolvedEmail, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.RegistrationPasswordHash(); ok {
|
|
_spec.SetField(pendingauthsession.FieldRegistrationPasswordHash, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.UpstreamIdentityClaims(); ok {
|
|
_spec.SetField(pendingauthsession.FieldUpstreamIdentityClaims, field.TypeJSON, value)
|
|
}
|
|
if value, ok := _u.mutation.LocalFlowState(); ok {
|
|
_spec.SetField(pendingauthsession.FieldLocalFlowState, field.TypeJSON, value)
|
|
}
|
|
if value, ok := _u.mutation.BrowserSessionKey(); ok {
|
|
_spec.SetField(pendingauthsession.FieldBrowserSessionKey, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.CompletionCodeHash(); ok {
|
|
_spec.SetField(pendingauthsession.FieldCompletionCodeHash, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.CompletionCodeExpiresAt(); ok {
|
|
_spec.SetField(pendingauthsession.FieldCompletionCodeExpiresAt, field.TypeTime, value)
|
|
}
|
|
if _u.mutation.CompletionCodeExpiresAtCleared() {
|
|
_spec.ClearField(pendingauthsession.FieldCompletionCodeExpiresAt, field.TypeTime)
|
|
}
|
|
if value, ok := _u.mutation.EmailVerifiedAt(); ok {
|
|
_spec.SetField(pendingauthsession.FieldEmailVerifiedAt, field.TypeTime, value)
|
|
}
|
|
if _u.mutation.EmailVerifiedAtCleared() {
|
|
_spec.ClearField(pendingauthsession.FieldEmailVerifiedAt, field.TypeTime)
|
|
}
|
|
if value, ok := _u.mutation.PasswordVerifiedAt(); ok {
|
|
_spec.SetField(pendingauthsession.FieldPasswordVerifiedAt, field.TypeTime, value)
|
|
}
|
|
if _u.mutation.PasswordVerifiedAtCleared() {
|
|
_spec.ClearField(pendingauthsession.FieldPasswordVerifiedAt, field.TypeTime)
|
|
}
|
|
if value, ok := _u.mutation.TotpVerifiedAt(); ok {
|
|
_spec.SetField(pendingauthsession.FieldTotpVerifiedAt, field.TypeTime, value)
|
|
}
|
|
if _u.mutation.TotpVerifiedAtCleared() {
|
|
_spec.ClearField(pendingauthsession.FieldTotpVerifiedAt, field.TypeTime)
|
|
}
|
|
if value, ok := _u.mutation.ExpiresAt(); ok {
|
|
_spec.SetField(pendingauthsession.FieldExpiresAt, field.TypeTime, value)
|
|
}
|
|
if value, ok := _u.mutation.ConsumedAt(); ok {
|
|
_spec.SetField(pendingauthsession.FieldConsumedAt, field.TypeTime, value)
|
|
}
|
|
if _u.mutation.ConsumedAtCleared() {
|
|
_spec.ClearField(pendingauthsession.FieldConsumedAt, field.TypeTime)
|
|
}
|
|
if _u.mutation.TargetUserCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: true,
|
|
Table: pendingauthsession.TargetUserTable,
|
|
Columns: []string{pendingauthsession.TargetUserColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt64),
|
|
},
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := _u.mutation.TargetUserIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: true,
|
|
Table: pendingauthsession.TargetUserTable,
|
|
Columns: []string{pendingauthsession.TargetUserColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt64),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
|
}
|
|
if _u.mutation.AdoptionDecisionCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2O,
|
|
Inverse: false,
|
|
Table: pendingauthsession.AdoptionDecisionTable,
|
|
Columns: []string{pendingauthsession.AdoptionDecisionColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(identityadoptiondecision.FieldID, field.TypeInt64),
|
|
},
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := _u.mutation.AdoptionDecisionIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2O,
|
|
Inverse: false,
|
|
Table: pendingauthsession.AdoptionDecisionTable,
|
|
Columns: []string{pendingauthsession.AdoptionDecisionColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(identityadoptiondecision.FieldID, field.TypeInt64),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
|
}
|
|
if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil {
|
|
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
|
err = &NotFoundError{pendingauthsession.Label}
|
|
} else if sqlgraph.IsConstraintError(err) {
|
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
|
}
|
|
return 0, err
|
|
}
|
|
_u.mutation.done = true
|
|
return _node, nil
|
|
}
|
|
|
|
// PendingAuthSessionUpdateOne is the builder for updating a single PendingAuthSession entity.
|
|
type PendingAuthSessionUpdateOne struct {
|
|
config
|
|
fields []string
|
|
hooks []Hook
|
|
mutation *PendingAuthSessionMutation
|
|
}
|
|
|
|
// SetUpdatedAt sets the "updated_at" field.
|
|
func (_u *PendingAuthSessionUpdateOne) SetUpdatedAt(v time.Time) *PendingAuthSessionUpdateOne {
|
|
_u.mutation.SetUpdatedAt(v)
|
|
return _u
|
|
}
|
|
|
|
// SetSessionToken sets the "session_token" field.
|
|
func (_u *PendingAuthSessionUpdateOne) SetSessionToken(v string) *PendingAuthSessionUpdateOne {
|
|
_u.mutation.SetSessionToken(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableSessionToken sets the "session_token" field if the given value is not nil.
|
|
func (_u *PendingAuthSessionUpdateOne) SetNillableSessionToken(v *string) *PendingAuthSessionUpdateOne {
|
|
if v != nil {
|
|
_u.SetSessionToken(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetIntent sets the "intent" field.
|
|
func (_u *PendingAuthSessionUpdateOne) SetIntent(v string) *PendingAuthSessionUpdateOne {
|
|
_u.mutation.SetIntent(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableIntent sets the "intent" field if the given value is not nil.
|
|
func (_u *PendingAuthSessionUpdateOne) SetNillableIntent(v *string) *PendingAuthSessionUpdateOne {
|
|
if v != nil {
|
|
_u.SetIntent(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetProviderType sets the "provider_type" field.
|
|
func (_u *PendingAuthSessionUpdateOne) SetProviderType(v string) *PendingAuthSessionUpdateOne {
|
|
_u.mutation.SetProviderType(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableProviderType sets the "provider_type" field if the given value is not nil.
|
|
func (_u *PendingAuthSessionUpdateOne) SetNillableProviderType(v *string) *PendingAuthSessionUpdateOne {
|
|
if v != nil {
|
|
_u.SetProviderType(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetProviderKey sets the "provider_key" field.
|
|
func (_u *PendingAuthSessionUpdateOne) SetProviderKey(v string) *PendingAuthSessionUpdateOne {
|
|
_u.mutation.SetProviderKey(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableProviderKey sets the "provider_key" field if the given value is not nil.
|
|
func (_u *PendingAuthSessionUpdateOne) SetNillableProviderKey(v *string) *PendingAuthSessionUpdateOne {
|
|
if v != nil {
|
|
_u.SetProviderKey(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetProviderSubject sets the "provider_subject" field.
|
|
func (_u *PendingAuthSessionUpdateOne) SetProviderSubject(v string) *PendingAuthSessionUpdateOne {
|
|
_u.mutation.SetProviderSubject(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableProviderSubject sets the "provider_subject" field if the given value is not nil.
|
|
func (_u *PendingAuthSessionUpdateOne) SetNillableProviderSubject(v *string) *PendingAuthSessionUpdateOne {
|
|
if v != nil {
|
|
_u.SetProviderSubject(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetTargetUserID sets the "target_user_id" field.
|
|
func (_u *PendingAuthSessionUpdateOne) SetTargetUserID(v int64) *PendingAuthSessionUpdateOne {
|
|
_u.mutation.SetTargetUserID(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableTargetUserID sets the "target_user_id" field if the given value is not nil.
|
|
func (_u *PendingAuthSessionUpdateOne) SetNillableTargetUserID(v *int64) *PendingAuthSessionUpdateOne {
|
|
if v != nil {
|
|
_u.SetTargetUserID(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearTargetUserID clears the value of the "target_user_id" field.
|
|
func (_u *PendingAuthSessionUpdateOne) ClearTargetUserID() *PendingAuthSessionUpdateOne {
|
|
_u.mutation.ClearTargetUserID()
|
|
return _u
|
|
}
|
|
|
|
// SetRedirectTo sets the "redirect_to" field.
|
|
func (_u *PendingAuthSessionUpdateOne) SetRedirectTo(v string) *PendingAuthSessionUpdateOne {
|
|
_u.mutation.SetRedirectTo(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableRedirectTo sets the "redirect_to" field if the given value is not nil.
|
|
func (_u *PendingAuthSessionUpdateOne) SetNillableRedirectTo(v *string) *PendingAuthSessionUpdateOne {
|
|
if v != nil {
|
|
_u.SetRedirectTo(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetResolvedEmail sets the "resolved_email" field.
|
|
func (_u *PendingAuthSessionUpdateOne) SetResolvedEmail(v string) *PendingAuthSessionUpdateOne {
|
|
_u.mutation.SetResolvedEmail(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableResolvedEmail sets the "resolved_email" field if the given value is not nil.
|
|
func (_u *PendingAuthSessionUpdateOne) SetNillableResolvedEmail(v *string) *PendingAuthSessionUpdateOne {
|
|
if v != nil {
|
|
_u.SetResolvedEmail(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetRegistrationPasswordHash sets the "registration_password_hash" field.
|
|
func (_u *PendingAuthSessionUpdateOne) SetRegistrationPasswordHash(v string) *PendingAuthSessionUpdateOne {
|
|
_u.mutation.SetRegistrationPasswordHash(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableRegistrationPasswordHash sets the "registration_password_hash" field if the given value is not nil.
|
|
func (_u *PendingAuthSessionUpdateOne) SetNillableRegistrationPasswordHash(v *string) *PendingAuthSessionUpdateOne {
|
|
if v != nil {
|
|
_u.SetRegistrationPasswordHash(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetUpstreamIdentityClaims sets the "upstream_identity_claims" field.
|
|
func (_u *PendingAuthSessionUpdateOne) SetUpstreamIdentityClaims(v map[string]interface{}) *PendingAuthSessionUpdateOne {
|
|
_u.mutation.SetUpstreamIdentityClaims(v)
|
|
return _u
|
|
}
|
|
|
|
// SetLocalFlowState sets the "local_flow_state" field.
|
|
func (_u *PendingAuthSessionUpdateOne) SetLocalFlowState(v map[string]interface{}) *PendingAuthSessionUpdateOne {
|
|
_u.mutation.SetLocalFlowState(v)
|
|
return _u
|
|
}
|
|
|
|
// SetBrowserSessionKey sets the "browser_session_key" field.
|
|
func (_u *PendingAuthSessionUpdateOne) SetBrowserSessionKey(v string) *PendingAuthSessionUpdateOne {
|
|
_u.mutation.SetBrowserSessionKey(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableBrowserSessionKey sets the "browser_session_key" field if the given value is not nil.
|
|
func (_u *PendingAuthSessionUpdateOne) SetNillableBrowserSessionKey(v *string) *PendingAuthSessionUpdateOne {
|
|
if v != nil {
|
|
_u.SetBrowserSessionKey(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetCompletionCodeHash sets the "completion_code_hash" field.
|
|
func (_u *PendingAuthSessionUpdateOne) SetCompletionCodeHash(v string) *PendingAuthSessionUpdateOne {
|
|
_u.mutation.SetCompletionCodeHash(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableCompletionCodeHash sets the "completion_code_hash" field if the given value is not nil.
|
|
func (_u *PendingAuthSessionUpdateOne) SetNillableCompletionCodeHash(v *string) *PendingAuthSessionUpdateOne {
|
|
if v != nil {
|
|
_u.SetCompletionCodeHash(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetCompletionCodeExpiresAt sets the "completion_code_expires_at" field.
|
|
func (_u *PendingAuthSessionUpdateOne) SetCompletionCodeExpiresAt(v time.Time) *PendingAuthSessionUpdateOne {
|
|
_u.mutation.SetCompletionCodeExpiresAt(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableCompletionCodeExpiresAt sets the "completion_code_expires_at" field if the given value is not nil.
|
|
func (_u *PendingAuthSessionUpdateOne) SetNillableCompletionCodeExpiresAt(v *time.Time) *PendingAuthSessionUpdateOne {
|
|
if v != nil {
|
|
_u.SetCompletionCodeExpiresAt(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearCompletionCodeExpiresAt clears the value of the "completion_code_expires_at" field.
|
|
func (_u *PendingAuthSessionUpdateOne) ClearCompletionCodeExpiresAt() *PendingAuthSessionUpdateOne {
|
|
_u.mutation.ClearCompletionCodeExpiresAt()
|
|
return _u
|
|
}
|
|
|
|
// SetEmailVerifiedAt sets the "email_verified_at" field.
|
|
func (_u *PendingAuthSessionUpdateOne) SetEmailVerifiedAt(v time.Time) *PendingAuthSessionUpdateOne {
|
|
_u.mutation.SetEmailVerifiedAt(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableEmailVerifiedAt sets the "email_verified_at" field if the given value is not nil.
|
|
func (_u *PendingAuthSessionUpdateOne) SetNillableEmailVerifiedAt(v *time.Time) *PendingAuthSessionUpdateOne {
|
|
if v != nil {
|
|
_u.SetEmailVerifiedAt(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearEmailVerifiedAt clears the value of the "email_verified_at" field.
|
|
func (_u *PendingAuthSessionUpdateOne) ClearEmailVerifiedAt() *PendingAuthSessionUpdateOne {
|
|
_u.mutation.ClearEmailVerifiedAt()
|
|
return _u
|
|
}
|
|
|
|
// SetPasswordVerifiedAt sets the "password_verified_at" field.
|
|
func (_u *PendingAuthSessionUpdateOne) SetPasswordVerifiedAt(v time.Time) *PendingAuthSessionUpdateOne {
|
|
_u.mutation.SetPasswordVerifiedAt(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillablePasswordVerifiedAt sets the "password_verified_at" field if the given value is not nil.
|
|
func (_u *PendingAuthSessionUpdateOne) SetNillablePasswordVerifiedAt(v *time.Time) *PendingAuthSessionUpdateOne {
|
|
if v != nil {
|
|
_u.SetPasswordVerifiedAt(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearPasswordVerifiedAt clears the value of the "password_verified_at" field.
|
|
func (_u *PendingAuthSessionUpdateOne) ClearPasswordVerifiedAt() *PendingAuthSessionUpdateOne {
|
|
_u.mutation.ClearPasswordVerifiedAt()
|
|
return _u
|
|
}
|
|
|
|
// SetTotpVerifiedAt sets the "totp_verified_at" field.
|
|
func (_u *PendingAuthSessionUpdateOne) SetTotpVerifiedAt(v time.Time) *PendingAuthSessionUpdateOne {
|
|
_u.mutation.SetTotpVerifiedAt(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableTotpVerifiedAt sets the "totp_verified_at" field if the given value is not nil.
|
|
func (_u *PendingAuthSessionUpdateOne) SetNillableTotpVerifiedAt(v *time.Time) *PendingAuthSessionUpdateOne {
|
|
if v != nil {
|
|
_u.SetTotpVerifiedAt(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearTotpVerifiedAt clears the value of the "totp_verified_at" field.
|
|
func (_u *PendingAuthSessionUpdateOne) ClearTotpVerifiedAt() *PendingAuthSessionUpdateOne {
|
|
_u.mutation.ClearTotpVerifiedAt()
|
|
return _u
|
|
}
|
|
|
|
// SetExpiresAt sets the "expires_at" field.
|
|
func (_u *PendingAuthSessionUpdateOne) SetExpiresAt(v time.Time) *PendingAuthSessionUpdateOne {
|
|
_u.mutation.SetExpiresAt(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableExpiresAt sets the "expires_at" field if the given value is not nil.
|
|
func (_u *PendingAuthSessionUpdateOne) SetNillableExpiresAt(v *time.Time) *PendingAuthSessionUpdateOne {
|
|
if v != nil {
|
|
_u.SetExpiresAt(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetConsumedAt sets the "consumed_at" field.
|
|
func (_u *PendingAuthSessionUpdateOne) SetConsumedAt(v time.Time) *PendingAuthSessionUpdateOne {
|
|
_u.mutation.SetConsumedAt(v)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableConsumedAt sets the "consumed_at" field if the given value is not nil.
|
|
func (_u *PendingAuthSessionUpdateOne) SetNillableConsumedAt(v *time.Time) *PendingAuthSessionUpdateOne {
|
|
if v != nil {
|
|
_u.SetConsumedAt(*v)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// ClearConsumedAt clears the value of the "consumed_at" field.
|
|
func (_u *PendingAuthSessionUpdateOne) ClearConsumedAt() *PendingAuthSessionUpdateOne {
|
|
_u.mutation.ClearConsumedAt()
|
|
return _u
|
|
}
|
|
|
|
// SetTargetUser sets the "target_user" edge to the User entity.
|
|
func (_u *PendingAuthSessionUpdateOne) SetTargetUser(v *User) *PendingAuthSessionUpdateOne {
|
|
return _u.SetTargetUserID(v.ID)
|
|
}
|
|
|
|
// SetAdoptionDecisionID sets the "adoption_decision" edge to the IdentityAdoptionDecision entity by ID.
|
|
func (_u *PendingAuthSessionUpdateOne) SetAdoptionDecisionID(id int64) *PendingAuthSessionUpdateOne {
|
|
_u.mutation.SetAdoptionDecisionID(id)
|
|
return _u
|
|
}
|
|
|
|
// SetNillableAdoptionDecisionID sets the "adoption_decision" edge to the IdentityAdoptionDecision entity by ID if the given value is not nil.
|
|
func (_u *PendingAuthSessionUpdateOne) SetNillableAdoptionDecisionID(id *int64) *PendingAuthSessionUpdateOne {
|
|
if id != nil {
|
|
_u = _u.SetAdoptionDecisionID(*id)
|
|
}
|
|
return _u
|
|
}
|
|
|
|
// SetAdoptionDecision sets the "adoption_decision" edge to the IdentityAdoptionDecision entity.
|
|
func (_u *PendingAuthSessionUpdateOne) SetAdoptionDecision(v *IdentityAdoptionDecision) *PendingAuthSessionUpdateOne {
|
|
return _u.SetAdoptionDecisionID(v.ID)
|
|
}
|
|
|
|
// Mutation returns the PendingAuthSessionMutation object of the builder.
|
|
func (_u *PendingAuthSessionUpdateOne) Mutation() *PendingAuthSessionMutation {
|
|
return _u.mutation
|
|
}
|
|
|
|
// ClearTargetUser clears the "target_user" edge to the User entity.
|
|
func (_u *PendingAuthSessionUpdateOne) ClearTargetUser() *PendingAuthSessionUpdateOne {
|
|
_u.mutation.ClearTargetUser()
|
|
return _u
|
|
}
|
|
|
|
// ClearAdoptionDecision clears the "adoption_decision" edge to the IdentityAdoptionDecision entity.
|
|
func (_u *PendingAuthSessionUpdateOne) ClearAdoptionDecision() *PendingAuthSessionUpdateOne {
|
|
_u.mutation.ClearAdoptionDecision()
|
|
return _u
|
|
}
|
|
|
|
// Where appends a list predicates to the PendingAuthSessionUpdate builder.
|
|
func (_u *PendingAuthSessionUpdateOne) Where(ps ...predicate.PendingAuthSession) *PendingAuthSessionUpdateOne {
|
|
_u.mutation.Where(ps...)
|
|
return _u
|
|
}
|
|
|
|
// Select allows selecting one or more fields (columns) of the returned entity.
|
|
// The default is selecting all fields defined in the entity schema.
|
|
func (_u *PendingAuthSessionUpdateOne) Select(field string, fields ...string) *PendingAuthSessionUpdateOne {
|
|
_u.fields = append([]string{field}, fields...)
|
|
return _u
|
|
}
|
|
|
|
// Save executes the query and returns the updated PendingAuthSession entity.
|
|
func (_u *PendingAuthSessionUpdateOne) Save(ctx context.Context) (*PendingAuthSession, error) {
|
|
_u.defaults()
|
|
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
|
|
}
|
|
|
|
// SaveX is like Save, but panics if an error occurs.
|
|
func (_u *PendingAuthSessionUpdateOne) SaveX(ctx context.Context) *PendingAuthSession {
|
|
node, err := _u.Save(ctx)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return node
|
|
}
|
|
|
|
// Exec executes the query on the entity.
|
|
func (_u *PendingAuthSessionUpdateOne) Exec(ctx context.Context) error {
|
|
_, err := _u.Save(ctx)
|
|
return err
|
|
}
|
|
|
|
// ExecX is like Exec, but panics if an error occurs.
|
|
func (_u *PendingAuthSessionUpdateOne) ExecX(ctx context.Context) {
|
|
if err := _u.Exec(ctx); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
|
|
// defaults sets the default values of the builder before save.
|
|
func (_u *PendingAuthSessionUpdateOne) defaults() {
|
|
if _, ok := _u.mutation.UpdatedAt(); !ok {
|
|
v := pendingauthsession.UpdateDefaultUpdatedAt()
|
|
_u.mutation.SetUpdatedAt(v)
|
|
}
|
|
}
|
|
|
|
// check runs all checks and user-defined validators on the builder.
|
|
func (_u *PendingAuthSessionUpdateOne) check() error {
|
|
if v, ok := _u.mutation.SessionToken(); ok {
|
|
if err := pendingauthsession.SessionTokenValidator(v); err != nil {
|
|
return &ValidationError{Name: "session_token", err: fmt.Errorf(`ent: validator failed for field "PendingAuthSession.session_token": %w`, err)}
|
|
}
|
|
}
|
|
if v, ok := _u.mutation.Intent(); ok {
|
|
if err := pendingauthsession.IntentValidator(v); err != nil {
|
|
return &ValidationError{Name: "intent", err: fmt.Errorf(`ent: validator failed for field "PendingAuthSession.intent": %w`, err)}
|
|
}
|
|
}
|
|
if v, ok := _u.mutation.ProviderType(); ok {
|
|
if err := pendingauthsession.ProviderTypeValidator(v); err != nil {
|
|
return &ValidationError{Name: "provider_type", err: fmt.Errorf(`ent: validator failed for field "PendingAuthSession.provider_type": %w`, err)}
|
|
}
|
|
}
|
|
if v, ok := _u.mutation.ProviderKey(); ok {
|
|
if err := pendingauthsession.ProviderKeyValidator(v); err != nil {
|
|
return &ValidationError{Name: "provider_key", err: fmt.Errorf(`ent: validator failed for field "PendingAuthSession.provider_key": %w`, err)}
|
|
}
|
|
}
|
|
if v, ok := _u.mutation.ProviderSubject(); ok {
|
|
if err := pendingauthsession.ProviderSubjectValidator(v); err != nil {
|
|
return &ValidationError{Name: "provider_subject", err: fmt.Errorf(`ent: validator failed for field "PendingAuthSession.provider_subject": %w`, err)}
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (_u *PendingAuthSessionUpdateOne) sqlSave(ctx context.Context) (_node *PendingAuthSession, err error) {
|
|
if err := _u.check(); err != nil {
|
|
return _node, err
|
|
}
|
|
_spec := sqlgraph.NewUpdateSpec(pendingauthsession.Table, pendingauthsession.Columns, sqlgraph.NewFieldSpec(pendingauthsession.FieldID, field.TypeInt64))
|
|
id, ok := _u.mutation.ID()
|
|
if !ok {
|
|
return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "PendingAuthSession.id" for update`)}
|
|
}
|
|
_spec.Node.ID.Value = id
|
|
if fields := _u.fields; len(fields) > 0 {
|
|
_spec.Node.Columns = make([]string, 0, len(fields))
|
|
_spec.Node.Columns = append(_spec.Node.Columns, pendingauthsession.FieldID)
|
|
for _, f := range fields {
|
|
if !pendingauthsession.ValidColumn(f) {
|
|
return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
|
|
}
|
|
if f != pendingauthsession.FieldID {
|
|
_spec.Node.Columns = append(_spec.Node.Columns, f)
|
|
}
|
|
}
|
|
}
|
|
if ps := _u.mutation.predicates; len(ps) > 0 {
|
|
_spec.Predicate = func(selector *sql.Selector) {
|
|
for i := range ps {
|
|
ps[i](selector)
|
|
}
|
|
}
|
|
}
|
|
if value, ok := _u.mutation.UpdatedAt(); ok {
|
|
_spec.SetField(pendingauthsession.FieldUpdatedAt, field.TypeTime, value)
|
|
}
|
|
if value, ok := _u.mutation.SessionToken(); ok {
|
|
_spec.SetField(pendingauthsession.FieldSessionToken, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.Intent(); ok {
|
|
_spec.SetField(pendingauthsession.FieldIntent, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.ProviderType(); ok {
|
|
_spec.SetField(pendingauthsession.FieldProviderType, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.ProviderKey(); ok {
|
|
_spec.SetField(pendingauthsession.FieldProviderKey, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.ProviderSubject(); ok {
|
|
_spec.SetField(pendingauthsession.FieldProviderSubject, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.RedirectTo(); ok {
|
|
_spec.SetField(pendingauthsession.FieldRedirectTo, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.ResolvedEmail(); ok {
|
|
_spec.SetField(pendingauthsession.FieldResolvedEmail, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.RegistrationPasswordHash(); ok {
|
|
_spec.SetField(pendingauthsession.FieldRegistrationPasswordHash, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.UpstreamIdentityClaims(); ok {
|
|
_spec.SetField(pendingauthsession.FieldUpstreamIdentityClaims, field.TypeJSON, value)
|
|
}
|
|
if value, ok := _u.mutation.LocalFlowState(); ok {
|
|
_spec.SetField(pendingauthsession.FieldLocalFlowState, field.TypeJSON, value)
|
|
}
|
|
if value, ok := _u.mutation.BrowserSessionKey(); ok {
|
|
_spec.SetField(pendingauthsession.FieldBrowserSessionKey, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.CompletionCodeHash(); ok {
|
|
_spec.SetField(pendingauthsession.FieldCompletionCodeHash, field.TypeString, value)
|
|
}
|
|
if value, ok := _u.mutation.CompletionCodeExpiresAt(); ok {
|
|
_spec.SetField(pendingauthsession.FieldCompletionCodeExpiresAt, field.TypeTime, value)
|
|
}
|
|
if _u.mutation.CompletionCodeExpiresAtCleared() {
|
|
_spec.ClearField(pendingauthsession.FieldCompletionCodeExpiresAt, field.TypeTime)
|
|
}
|
|
if value, ok := _u.mutation.EmailVerifiedAt(); ok {
|
|
_spec.SetField(pendingauthsession.FieldEmailVerifiedAt, field.TypeTime, value)
|
|
}
|
|
if _u.mutation.EmailVerifiedAtCleared() {
|
|
_spec.ClearField(pendingauthsession.FieldEmailVerifiedAt, field.TypeTime)
|
|
}
|
|
if value, ok := _u.mutation.PasswordVerifiedAt(); ok {
|
|
_spec.SetField(pendingauthsession.FieldPasswordVerifiedAt, field.TypeTime, value)
|
|
}
|
|
if _u.mutation.PasswordVerifiedAtCleared() {
|
|
_spec.ClearField(pendingauthsession.FieldPasswordVerifiedAt, field.TypeTime)
|
|
}
|
|
if value, ok := _u.mutation.TotpVerifiedAt(); ok {
|
|
_spec.SetField(pendingauthsession.FieldTotpVerifiedAt, field.TypeTime, value)
|
|
}
|
|
if _u.mutation.TotpVerifiedAtCleared() {
|
|
_spec.ClearField(pendingauthsession.FieldTotpVerifiedAt, field.TypeTime)
|
|
}
|
|
if value, ok := _u.mutation.ExpiresAt(); ok {
|
|
_spec.SetField(pendingauthsession.FieldExpiresAt, field.TypeTime, value)
|
|
}
|
|
if value, ok := _u.mutation.ConsumedAt(); ok {
|
|
_spec.SetField(pendingauthsession.FieldConsumedAt, field.TypeTime, value)
|
|
}
|
|
if _u.mutation.ConsumedAtCleared() {
|
|
_spec.ClearField(pendingauthsession.FieldConsumedAt, field.TypeTime)
|
|
}
|
|
if _u.mutation.TargetUserCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: true,
|
|
Table: pendingauthsession.TargetUserTable,
|
|
Columns: []string{pendingauthsession.TargetUserColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt64),
|
|
},
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := _u.mutation.TargetUserIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.M2O,
|
|
Inverse: true,
|
|
Table: pendingauthsession.TargetUserTable,
|
|
Columns: []string{pendingauthsession.TargetUserColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(user.FieldID, field.TypeInt64),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
|
}
|
|
if _u.mutation.AdoptionDecisionCleared() {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2O,
|
|
Inverse: false,
|
|
Table: pendingauthsession.AdoptionDecisionTable,
|
|
Columns: []string{pendingauthsession.AdoptionDecisionColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(identityadoptiondecision.FieldID, field.TypeInt64),
|
|
},
|
|
}
|
|
_spec.Edges.Clear = append(_spec.Edges.Clear, edge)
|
|
}
|
|
if nodes := _u.mutation.AdoptionDecisionIDs(); len(nodes) > 0 {
|
|
edge := &sqlgraph.EdgeSpec{
|
|
Rel: sqlgraph.O2O,
|
|
Inverse: false,
|
|
Table: pendingauthsession.AdoptionDecisionTable,
|
|
Columns: []string{pendingauthsession.AdoptionDecisionColumn},
|
|
Bidi: false,
|
|
Target: &sqlgraph.EdgeTarget{
|
|
IDSpec: sqlgraph.NewFieldSpec(identityadoptiondecision.FieldID, field.TypeInt64),
|
|
},
|
|
}
|
|
for _, k := range nodes {
|
|
edge.Target.Nodes = append(edge.Target.Nodes, k)
|
|
}
|
|
_spec.Edges.Add = append(_spec.Edges.Add, edge)
|
|
}
|
|
_node = &PendingAuthSession{config: _u.config}
|
|
_spec.Assign = _node.assignValues
|
|
_spec.ScanValues = _node.scanValues
|
|
if err = sqlgraph.UpdateNode(ctx, _u.driver, _spec); err != nil {
|
|
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
|
err = &NotFoundError{pendingauthsession.Label}
|
|
} else if sqlgraph.IsConstraintError(err) {
|
|
err = &ConstraintError{msg: err.Error(), wrap: err}
|
|
}
|
|
return nil, err
|
|
}
|
|
_u.mutation.done = true
|
|
return _node, nil
|
|
}
|