Files
dex/storage/ent/db/authrequest_update.go
546e66cb5d feat: add WebAuthn support (#4704)
Signed-off-by: maksim.nabokikh <max.nabokih@gmail.com>
Signed-off-by: Maksim Nabokikh <max.nabokih@gmail.com>
Co-authored-by: Alwx <alwxsin@gmail.com>
2026-04-02 11:48:46 +02:00

1126 lines
34 KiB
Go

// Code generated by ent, DO NOT EDIT.
package db
import (
"context"
"errors"
"fmt"
"time"
"entgo.io/ent/dialect/sql"
"entgo.io/ent/dialect/sql/sqlgraph"
"entgo.io/ent/dialect/sql/sqljson"
"entgo.io/ent/schema/field"
"github.com/dexidp/dex/storage/ent/db/authrequest"
"github.com/dexidp/dex/storage/ent/db/predicate"
)
// AuthRequestUpdate is the builder for updating AuthRequest entities.
type AuthRequestUpdate struct {
config
hooks []Hook
mutation *AuthRequestMutation
}
// Where appends a list predicates to the AuthRequestUpdate builder.
func (_u *AuthRequestUpdate) Where(ps ...predicate.AuthRequest) *AuthRequestUpdate {
_u.mutation.Where(ps...)
return _u
}
// SetClientID sets the "client_id" field.
func (_u *AuthRequestUpdate) SetClientID(v string) *AuthRequestUpdate {
_u.mutation.SetClientID(v)
return _u
}
// SetNillableClientID sets the "client_id" field if the given value is not nil.
func (_u *AuthRequestUpdate) SetNillableClientID(v *string) *AuthRequestUpdate {
if v != nil {
_u.SetClientID(*v)
}
return _u
}
// SetScopes sets the "scopes" field.
func (_u *AuthRequestUpdate) SetScopes(v []string) *AuthRequestUpdate {
_u.mutation.SetScopes(v)
return _u
}
// AppendScopes appends value to the "scopes" field.
func (_u *AuthRequestUpdate) AppendScopes(v []string) *AuthRequestUpdate {
_u.mutation.AppendScopes(v)
return _u
}
// ClearScopes clears the value of the "scopes" field.
func (_u *AuthRequestUpdate) ClearScopes() *AuthRequestUpdate {
_u.mutation.ClearScopes()
return _u
}
// SetResponseTypes sets the "response_types" field.
func (_u *AuthRequestUpdate) SetResponseTypes(v []string) *AuthRequestUpdate {
_u.mutation.SetResponseTypes(v)
return _u
}
// AppendResponseTypes appends value to the "response_types" field.
func (_u *AuthRequestUpdate) AppendResponseTypes(v []string) *AuthRequestUpdate {
_u.mutation.AppendResponseTypes(v)
return _u
}
// ClearResponseTypes clears the value of the "response_types" field.
func (_u *AuthRequestUpdate) ClearResponseTypes() *AuthRequestUpdate {
_u.mutation.ClearResponseTypes()
return _u
}
// SetRedirectURI sets the "redirect_uri" field.
func (_u *AuthRequestUpdate) SetRedirectURI(v string) *AuthRequestUpdate {
_u.mutation.SetRedirectURI(v)
return _u
}
// SetNillableRedirectURI sets the "redirect_uri" field if the given value is not nil.
func (_u *AuthRequestUpdate) SetNillableRedirectURI(v *string) *AuthRequestUpdate {
if v != nil {
_u.SetRedirectURI(*v)
}
return _u
}
// SetNonce sets the "nonce" field.
func (_u *AuthRequestUpdate) SetNonce(v string) *AuthRequestUpdate {
_u.mutation.SetNonce(v)
return _u
}
// SetNillableNonce sets the "nonce" field if the given value is not nil.
func (_u *AuthRequestUpdate) SetNillableNonce(v *string) *AuthRequestUpdate {
if v != nil {
_u.SetNonce(*v)
}
return _u
}
// SetState sets the "state" field.
func (_u *AuthRequestUpdate) SetState(v string) *AuthRequestUpdate {
_u.mutation.SetState(v)
return _u
}
// SetNillableState sets the "state" field if the given value is not nil.
func (_u *AuthRequestUpdate) SetNillableState(v *string) *AuthRequestUpdate {
if v != nil {
_u.SetState(*v)
}
return _u
}
// SetForceApprovalPrompt sets the "force_approval_prompt" field.
func (_u *AuthRequestUpdate) SetForceApprovalPrompt(v bool) *AuthRequestUpdate {
_u.mutation.SetForceApprovalPrompt(v)
return _u
}
// SetNillableForceApprovalPrompt sets the "force_approval_prompt" field if the given value is not nil.
func (_u *AuthRequestUpdate) SetNillableForceApprovalPrompt(v *bool) *AuthRequestUpdate {
if v != nil {
_u.SetForceApprovalPrompt(*v)
}
return _u
}
// SetLoggedIn sets the "logged_in" field.
func (_u *AuthRequestUpdate) SetLoggedIn(v bool) *AuthRequestUpdate {
_u.mutation.SetLoggedIn(v)
return _u
}
// SetNillableLoggedIn sets the "logged_in" field if the given value is not nil.
func (_u *AuthRequestUpdate) SetNillableLoggedIn(v *bool) *AuthRequestUpdate {
if v != nil {
_u.SetLoggedIn(*v)
}
return _u
}
// SetClaimsUserID sets the "claims_user_id" field.
func (_u *AuthRequestUpdate) SetClaimsUserID(v string) *AuthRequestUpdate {
_u.mutation.SetClaimsUserID(v)
return _u
}
// SetNillableClaimsUserID sets the "claims_user_id" field if the given value is not nil.
func (_u *AuthRequestUpdate) SetNillableClaimsUserID(v *string) *AuthRequestUpdate {
if v != nil {
_u.SetClaimsUserID(*v)
}
return _u
}
// SetClaimsUsername sets the "claims_username" field.
func (_u *AuthRequestUpdate) SetClaimsUsername(v string) *AuthRequestUpdate {
_u.mutation.SetClaimsUsername(v)
return _u
}
// SetNillableClaimsUsername sets the "claims_username" field if the given value is not nil.
func (_u *AuthRequestUpdate) SetNillableClaimsUsername(v *string) *AuthRequestUpdate {
if v != nil {
_u.SetClaimsUsername(*v)
}
return _u
}
// SetClaimsEmail sets the "claims_email" field.
func (_u *AuthRequestUpdate) SetClaimsEmail(v string) *AuthRequestUpdate {
_u.mutation.SetClaimsEmail(v)
return _u
}
// SetNillableClaimsEmail sets the "claims_email" field if the given value is not nil.
func (_u *AuthRequestUpdate) SetNillableClaimsEmail(v *string) *AuthRequestUpdate {
if v != nil {
_u.SetClaimsEmail(*v)
}
return _u
}
// SetClaimsEmailVerified sets the "claims_email_verified" field.
func (_u *AuthRequestUpdate) SetClaimsEmailVerified(v bool) *AuthRequestUpdate {
_u.mutation.SetClaimsEmailVerified(v)
return _u
}
// SetNillableClaimsEmailVerified sets the "claims_email_verified" field if the given value is not nil.
func (_u *AuthRequestUpdate) SetNillableClaimsEmailVerified(v *bool) *AuthRequestUpdate {
if v != nil {
_u.SetClaimsEmailVerified(*v)
}
return _u
}
// SetClaimsGroups sets the "claims_groups" field.
func (_u *AuthRequestUpdate) SetClaimsGroups(v []string) *AuthRequestUpdate {
_u.mutation.SetClaimsGroups(v)
return _u
}
// AppendClaimsGroups appends value to the "claims_groups" field.
func (_u *AuthRequestUpdate) AppendClaimsGroups(v []string) *AuthRequestUpdate {
_u.mutation.AppendClaimsGroups(v)
return _u
}
// ClearClaimsGroups clears the value of the "claims_groups" field.
func (_u *AuthRequestUpdate) ClearClaimsGroups() *AuthRequestUpdate {
_u.mutation.ClearClaimsGroups()
return _u
}
// SetClaimsPreferredUsername sets the "claims_preferred_username" field.
func (_u *AuthRequestUpdate) SetClaimsPreferredUsername(v string) *AuthRequestUpdate {
_u.mutation.SetClaimsPreferredUsername(v)
return _u
}
// SetNillableClaimsPreferredUsername sets the "claims_preferred_username" field if the given value is not nil.
func (_u *AuthRequestUpdate) SetNillableClaimsPreferredUsername(v *string) *AuthRequestUpdate {
if v != nil {
_u.SetClaimsPreferredUsername(*v)
}
return _u
}
// SetConnectorID sets the "connector_id" field.
func (_u *AuthRequestUpdate) SetConnectorID(v string) *AuthRequestUpdate {
_u.mutation.SetConnectorID(v)
return _u
}
// SetNillableConnectorID sets the "connector_id" field if the given value is not nil.
func (_u *AuthRequestUpdate) SetNillableConnectorID(v *string) *AuthRequestUpdate {
if v != nil {
_u.SetConnectorID(*v)
}
return _u
}
// SetConnectorData sets the "connector_data" field.
func (_u *AuthRequestUpdate) SetConnectorData(v []byte) *AuthRequestUpdate {
_u.mutation.SetConnectorData(v)
return _u
}
// ClearConnectorData clears the value of the "connector_data" field.
func (_u *AuthRequestUpdate) ClearConnectorData() *AuthRequestUpdate {
_u.mutation.ClearConnectorData()
return _u
}
// SetExpiry sets the "expiry" field.
func (_u *AuthRequestUpdate) SetExpiry(v time.Time) *AuthRequestUpdate {
_u.mutation.SetExpiry(v)
return _u
}
// SetNillableExpiry sets the "expiry" field if the given value is not nil.
func (_u *AuthRequestUpdate) SetNillableExpiry(v *time.Time) *AuthRequestUpdate {
if v != nil {
_u.SetExpiry(*v)
}
return _u
}
// SetCodeChallenge sets the "code_challenge" field.
func (_u *AuthRequestUpdate) SetCodeChallenge(v string) *AuthRequestUpdate {
_u.mutation.SetCodeChallenge(v)
return _u
}
// SetNillableCodeChallenge sets the "code_challenge" field if the given value is not nil.
func (_u *AuthRequestUpdate) SetNillableCodeChallenge(v *string) *AuthRequestUpdate {
if v != nil {
_u.SetCodeChallenge(*v)
}
return _u
}
// SetCodeChallengeMethod sets the "code_challenge_method" field.
func (_u *AuthRequestUpdate) SetCodeChallengeMethod(v string) *AuthRequestUpdate {
_u.mutation.SetCodeChallengeMethod(v)
return _u
}
// SetNillableCodeChallengeMethod sets the "code_challenge_method" field if the given value is not nil.
func (_u *AuthRequestUpdate) SetNillableCodeChallengeMethod(v *string) *AuthRequestUpdate {
if v != nil {
_u.SetCodeChallengeMethod(*v)
}
return _u
}
// SetHmacKey sets the "hmac_key" field.
func (_u *AuthRequestUpdate) SetHmacKey(v []byte) *AuthRequestUpdate {
_u.mutation.SetHmacKey(v)
return _u
}
// SetMfaValidated sets the "mfa_validated" field.
func (_u *AuthRequestUpdate) SetMfaValidated(v bool) *AuthRequestUpdate {
_u.mutation.SetMfaValidated(v)
return _u
}
// SetNillableMfaValidated sets the "mfa_validated" field if the given value is not nil.
func (_u *AuthRequestUpdate) SetNillableMfaValidated(v *bool) *AuthRequestUpdate {
if v != nil {
_u.SetMfaValidated(*v)
}
return _u
}
// SetWebauthnSessionData sets the "webauthn_session_data" field.
func (_u *AuthRequestUpdate) SetWebauthnSessionData(v []byte) *AuthRequestUpdate {
_u.mutation.SetWebauthnSessionData(v)
return _u
}
// ClearWebauthnSessionData clears the value of the "webauthn_session_data" field.
func (_u *AuthRequestUpdate) ClearWebauthnSessionData() *AuthRequestUpdate {
_u.mutation.ClearWebauthnSessionData()
return _u
}
// SetPrompt sets the "prompt" field.
func (_u *AuthRequestUpdate) SetPrompt(v string) *AuthRequestUpdate {
_u.mutation.SetPrompt(v)
return _u
}
// SetNillablePrompt sets the "prompt" field if the given value is not nil.
func (_u *AuthRequestUpdate) SetNillablePrompt(v *string) *AuthRequestUpdate {
if v != nil {
_u.SetPrompt(*v)
}
return _u
}
// SetMaxAge sets the "max_age" field.
func (_u *AuthRequestUpdate) SetMaxAge(v int) *AuthRequestUpdate {
_u.mutation.ResetMaxAge()
_u.mutation.SetMaxAge(v)
return _u
}
// SetNillableMaxAge sets the "max_age" field if the given value is not nil.
func (_u *AuthRequestUpdate) SetNillableMaxAge(v *int) *AuthRequestUpdate {
if v != nil {
_u.SetMaxAge(*v)
}
return _u
}
// AddMaxAge adds value to the "max_age" field.
func (_u *AuthRequestUpdate) AddMaxAge(v int) *AuthRequestUpdate {
_u.mutation.AddMaxAge(v)
return _u
}
// SetAuthTime sets the "auth_time" field.
func (_u *AuthRequestUpdate) SetAuthTime(v time.Time) *AuthRequestUpdate {
_u.mutation.SetAuthTime(v)
return _u
}
// SetNillableAuthTime sets the "auth_time" field if the given value is not nil.
func (_u *AuthRequestUpdate) SetNillableAuthTime(v *time.Time) *AuthRequestUpdate {
if v != nil {
_u.SetAuthTime(*v)
}
return _u
}
// ClearAuthTime clears the value of the "auth_time" field.
func (_u *AuthRequestUpdate) ClearAuthTime() *AuthRequestUpdate {
_u.mutation.ClearAuthTime()
return _u
}
// Mutation returns the AuthRequestMutation object of the builder.
func (_u *AuthRequestUpdate) Mutation() *AuthRequestMutation {
return _u.mutation
}
// Save executes the query and returns the number of nodes affected by the update operation.
func (_u *AuthRequestUpdate) Save(ctx context.Context) (int, error) {
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
}
// SaveX is like Save, but panics if an error occurs.
func (_u *AuthRequestUpdate) SaveX(ctx context.Context) int {
affected, err := _u.Save(ctx)
if err != nil {
panic(err)
}
return affected
}
// Exec executes the query.
func (_u *AuthRequestUpdate) Exec(ctx context.Context) error {
_, err := _u.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (_u *AuthRequestUpdate) ExecX(ctx context.Context) {
if err := _u.Exec(ctx); err != nil {
panic(err)
}
}
func (_u *AuthRequestUpdate) sqlSave(ctx context.Context) (_node int, err error) {
_spec := sqlgraph.NewUpdateSpec(authrequest.Table, authrequest.Columns, sqlgraph.NewFieldSpec(authrequest.FieldID, field.TypeString))
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.ClientID(); ok {
_spec.SetField(authrequest.FieldClientID, field.TypeString, value)
}
if value, ok := _u.mutation.Scopes(); ok {
_spec.SetField(authrequest.FieldScopes, field.TypeJSON, value)
}
if value, ok := _u.mutation.AppendedScopes(); ok {
_spec.AddModifier(func(u *sql.UpdateBuilder) {
sqljson.Append(u, authrequest.FieldScopes, value)
})
}
if _u.mutation.ScopesCleared() {
_spec.ClearField(authrequest.FieldScopes, field.TypeJSON)
}
if value, ok := _u.mutation.ResponseTypes(); ok {
_spec.SetField(authrequest.FieldResponseTypes, field.TypeJSON, value)
}
if value, ok := _u.mutation.AppendedResponseTypes(); ok {
_spec.AddModifier(func(u *sql.UpdateBuilder) {
sqljson.Append(u, authrequest.FieldResponseTypes, value)
})
}
if _u.mutation.ResponseTypesCleared() {
_spec.ClearField(authrequest.FieldResponseTypes, field.TypeJSON)
}
if value, ok := _u.mutation.RedirectURI(); ok {
_spec.SetField(authrequest.FieldRedirectURI, field.TypeString, value)
}
if value, ok := _u.mutation.Nonce(); ok {
_spec.SetField(authrequest.FieldNonce, field.TypeString, value)
}
if value, ok := _u.mutation.State(); ok {
_spec.SetField(authrequest.FieldState, field.TypeString, value)
}
if value, ok := _u.mutation.ForceApprovalPrompt(); ok {
_spec.SetField(authrequest.FieldForceApprovalPrompt, field.TypeBool, value)
}
if value, ok := _u.mutation.LoggedIn(); ok {
_spec.SetField(authrequest.FieldLoggedIn, field.TypeBool, value)
}
if value, ok := _u.mutation.ClaimsUserID(); ok {
_spec.SetField(authrequest.FieldClaimsUserID, field.TypeString, value)
}
if value, ok := _u.mutation.ClaimsUsername(); ok {
_spec.SetField(authrequest.FieldClaimsUsername, field.TypeString, value)
}
if value, ok := _u.mutation.ClaimsEmail(); ok {
_spec.SetField(authrequest.FieldClaimsEmail, field.TypeString, value)
}
if value, ok := _u.mutation.ClaimsEmailVerified(); ok {
_spec.SetField(authrequest.FieldClaimsEmailVerified, field.TypeBool, value)
}
if value, ok := _u.mutation.ClaimsGroups(); ok {
_spec.SetField(authrequest.FieldClaimsGroups, field.TypeJSON, value)
}
if value, ok := _u.mutation.AppendedClaimsGroups(); ok {
_spec.AddModifier(func(u *sql.UpdateBuilder) {
sqljson.Append(u, authrequest.FieldClaimsGroups, value)
})
}
if _u.mutation.ClaimsGroupsCleared() {
_spec.ClearField(authrequest.FieldClaimsGroups, field.TypeJSON)
}
if value, ok := _u.mutation.ClaimsPreferredUsername(); ok {
_spec.SetField(authrequest.FieldClaimsPreferredUsername, field.TypeString, value)
}
if value, ok := _u.mutation.ConnectorID(); ok {
_spec.SetField(authrequest.FieldConnectorID, field.TypeString, value)
}
if value, ok := _u.mutation.ConnectorData(); ok {
_spec.SetField(authrequest.FieldConnectorData, field.TypeBytes, value)
}
if _u.mutation.ConnectorDataCleared() {
_spec.ClearField(authrequest.FieldConnectorData, field.TypeBytes)
}
if value, ok := _u.mutation.Expiry(); ok {
_spec.SetField(authrequest.FieldExpiry, field.TypeTime, value)
}
if value, ok := _u.mutation.CodeChallenge(); ok {
_spec.SetField(authrequest.FieldCodeChallenge, field.TypeString, value)
}
if value, ok := _u.mutation.CodeChallengeMethod(); ok {
_spec.SetField(authrequest.FieldCodeChallengeMethod, field.TypeString, value)
}
if value, ok := _u.mutation.HmacKey(); ok {
_spec.SetField(authrequest.FieldHmacKey, field.TypeBytes, value)
}
if value, ok := _u.mutation.MfaValidated(); ok {
_spec.SetField(authrequest.FieldMfaValidated, field.TypeBool, value)
}
if value, ok := _u.mutation.WebauthnSessionData(); ok {
_spec.SetField(authrequest.FieldWebauthnSessionData, field.TypeBytes, value)
}
if _u.mutation.WebauthnSessionDataCleared() {
_spec.ClearField(authrequest.FieldWebauthnSessionData, field.TypeBytes)
}
if value, ok := _u.mutation.Prompt(); ok {
_spec.SetField(authrequest.FieldPrompt, field.TypeString, value)
}
if value, ok := _u.mutation.MaxAge(); ok {
_spec.SetField(authrequest.FieldMaxAge, field.TypeInt, value)
}
if value, ok := _u.mutation.AddedMaxAge(); ok {
_spec.AddField(authrequest.FieldMaxAge, field.TypeInt, value)
}
if value, ok := _u.mutation.AuthTime(); ok {
_spec.SetField(authrequest.FieldAuthTime, field.TypeTime, value)
}
if _u.mutation.AuthTimeCleared() {
_spec.ClearField(authrequest.FieldAuthTime, field.TypeTime)
}
if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil {
if _, ok := err.(*sqlgraph.NotFoundError); ok {
err = &NotFoundError{authrequest.Label}
} else if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return 0, err
}
_u.mutation.done = true
return _node, nil
}
// AuthRequestUpdateOne is the builder for updating a single AuthRequest entity.
type AuthRequestUpdateOne struct {
config
fields []string
hooks []Hook
mutation *AuthRequestMutation
}
// SetClientID sets the "client_id" field.
func (_u *AuthRequestUpdateOne) SetClientID(v string) *AuthRequestUpdateOne {
_u.mutation.SetClientID(v)
return _u
}
// SetNillableClientID sets the "client_id" field if the given value is not nil.
func (_u *AuthRequestUpdateOne) SetNillableClientID(v *string) *AuthRequestUpdateOne {
if v != nil {
_u.SetClientID(*v)
}
return _u
}
// SetScopes sets the "scopes" field.
func (_u *AuthRequestUpdateOne) SetScopes(v []string) *AuthRequestUpdateOne {
_u.mutation.SetScopes(v)
return _u
}
// AppendScopes appends value to the "scopes" field.
func (_u *AuthRequestUpdateOne) AppendScopes(v []string) *AuthRequestUpdateOne {
_u.mutation.AppendScopes(v)
return _u
}
// ClearScopes clears the value of the "scopes" field.
func (_u *AuthRequestUpdateOne) ClearScopes() *AuthRequestUpdateOne {
_u.mutation.ClearScopes()
return _u
}
// SetResponseTypes sets the "response_types" field.
func (_u *AuthRequestUpdateOne) SetResponseTypes(v []string) *AuthRequestUpdateOne {
_u.mutation.SetResponseTypes(v)
return _u
}
// AppendResponseTypes appends value to the "response_types" field.
func (_u *AuthRequestUpdateOne) AppendResponseTypes(v []string) *AuthRequestUpdateOne {
_u.mutation.AppendResponseTypes(v)
return _u
}
// ClearResponseTypes clears the value of the "response_types" field.
func (_u *AuthRequestUpdateOne) ClearResponseTypes() *AuthRequestUpdateOne {
_u.mutation.ClearResponseTypes()
return _u
}
// SetRedirectURI sets the "redirect_uri" field.
func (_u *AuthRequestUpdateOne) SetRedirectURI(v string) *AuthRequestUpdateOne {
_u.mutation.SetRedirectURI(v)
return _u
}
// SetNillableRedirectURI sets the "redirect_uri" field if the given value is not nil.
func (_u *AuthRequestUpdateOne) SetNillableRedirectURI(v *string) *AuthRequestUpdateOne {
if v != nil {
_u.SetRedirectURI(*v)
}
return _u
}
// SetNonce sets the "nonce" field.
func (_u *AuthRequestUpdateOne) SetNonce(v string) *AuthRequestUpdateOne {
_u.mutation.SetNonce(v)
return _u
}
// SetNillableNonce sets the "nonce" field if the given value is not nil.
func (_u *AuthRequestUpdateOne) SetNillableNonce(v *string) *AuthRequestUpdateOne {
if v != nil {
_u.SetNonce(*v)
}
return _u
}
// SetState sets the "state" field.
func (_u *AuthRequestUpdateOne) SetState(v string) *AuthRequestUpdateOne {
_u.mutation.SetState(v)
return _u
}
// SetNillableState sets the "state" field if the given value is not nil.
func (_u *AuthRequestUpdateOne) SetNillableState(v *string) *AuthRequestUpdateOne {
if v != nil {
_u.SetState(*v)
}
return _u
}
// SetForceApprovalPrompt sets the "force_approval_prompt" field.
func (_u *AuthRequestUpdateOne) SetForceApprovalPrompt(v bool) *AuthRequestUpdateOne {
_u.mutation.SetForceApprovalPrompt(v)
return _u
}
// SetNillableForceApprovalPrompt sets the "force_approval_prompt" field if the given value is not nil.
func (_u *AuthRequestUpdateOne) SetNillableForceApprovalPrompt(v *bool) *AuthRequestUpdateOne {
if v != nil {
_u.SetForceApprovalPrompt(*v)
}
return _u
}
// SetLoggedIn sets the "logged_in" field.
func (_u *AuthRequestUpdateOne) SetLoggedIn(v bool) *AuthRequestUpdateOne {
_u.mutation.SetLoggedIn(v)
return _u
}
// SetNillableLoggedIn sets the "logged_in" field if the given value is not nil.
func (_u *AuthRequestUpdateOne) SetNillableLoggedIn(v *bool) *AuthRequestUpdateOne {
if v != nil {
_u.SetLoggedIn(*v)
}
return _u
}
// SetClaimsUserID sets the "claims_user_id" field.
func (_u *AuthRequestUpdateOne) SetClaimsUserID(v string) *AuthRequestUpdateOne {
_u.mutation.SetClaimsUserID(v)
return _u
}
// SetNillableClaimsUserID sets the "claims_user_id" field if the given value is not nil.
func (_u *AuthRequestUpdateOne) SetNillableClaimsUserID(v *string) *AuthRequestUpdateOne {
if v != nil {
_u.SetClaimsUserID(*v)
}
return _u
}
// SetClaimsUsername sets the "claims_username" field.
func (_u *AuthRequestUpdateOne) SetClaimsUsername(v string) *AuthRequestUpdateOne {
_u.mutation.SetClaimsUsername(v)
return _u
}
// SetNillableClaimsUsername sets the "claims_username" field if the given value is not nil.
func (_u *AuthRequestUpdateOne) SetNillableClaimsUsername(v *string) *AuthRequestUpdateOne {
if v != nil {
_u.SetClaimsUsername(*v)
}
return _u
}
// SetClaimsEmail sets the "claims_email" field.
func (_u *AuthRequestUpdateOne) SetClaimsEmail(v string) *AuthRequestUpdateOne {
_u.mutation.SetClaimsEmail(v)
return _u
}
// SetNillableClaimsEmail sets the "claims_email" field if the given value is not nil.
func (_u *AuthRequestUpdateOne) SetNillableClaimsEmail(v *string) *AuthRequestUpdateOne {
if v != nil {
_u.SetClaimsEmail(*v)
}
return _u
}
// SetClaimsEmailVerified sets the "claims_email_verified" field.
func (_u *AuthRequestUpdateOne) SetClaimsEmailVerified(v bool) *AuthRequestUpdateOne {
_u.mutation.SetClaimsEmailVerified(v)
return _u
}
// SetNillableClaimsEmailVerified sets the "claims_email_verified" field if the given value is not nil.
func (_u *AuthRequestUpdateOne) SetNillableClaimsEmailVerified(v *bool) *AuthRequestUpdateOne {
if v != nil {
_u.SetClaimsEmailVerified(*v)
}
return _u
}
// SetClaimsGroups sets the "claims_groups" field.
func (_u *AuthRequestUpdateOne) SetClaimsGroups(v []string) *AuthRequestUpdateOne {
_u.mutation.SetClaimsGroups(v)
return _u
}
// AppendClaimsGroups appends value to the "claims_groups" field.
func (_u *AuthRequestUpdateOne) AppendClaimsGroups(v []string) *AuthRequestUpdateOne {
_u.mutation.AppendClaimsGroups(v)
return _u
}
// ClearClaimsGroups clears the value of the "claims_groups" field.
func (_u *AuthRequestUpdateOne) ClearClaimsGroups() *AuthRequestUpdateOne {
_u.mutation.ClearClaimsGroups()
return _u
}
// SetClaimsPreferredUsername sets the "claims_preferred_username" field.
func (_u *AuthRequestUpdateOne) SetClaimsPreferredUsername(v string) *AuthRequestUpdateOne {
_u.mutation.SetClaimsPreferredUsername(v)
return _u
}
// SetNillableClaimsPreferredUsername sets the "claims_preferred_username" field if the given value is not nil.
func (_u *AuthRequestUpdateOne) SetNillableClaimsPreferredUsername(v *string) *AuthRequestUpdateOne {
if v != nil {
_u.SetClaimsPreferredUsername(*v)
}
return _u
}
// SetConnectorID sets the "connector_id" field.
func (_u *AuthRequestUpdateOne) SetConnectorID(v string) *AuthRequestUpdateOne {
_u.mutation.SetConnectorID(v)
return _u
}
// SetNillableConnectorID sets the "connector_id" field if the given value is not nil.
func (_u *AuthRequestUpdateOne) SetNillableConnectorID(v *string) *AuthRequestUpdateOne {
if v != nil {
_u.SetConnectorID(*v)
}
return _u
}
// SetConnectorData sets the "connector_data" field.
func (_u *AuthRequestUpdateOne) SetConnectorData(v []byte) *AuthRequestUpdateOne {
_u.mutation.SetConnectorData(v)
return _u
}
// ClearConnectorData clears the value of the "connector_data" field.
func (_u *AuthRequestUpdateOne) ClearConnectorData() *AuthRequestUpdateOne {
_u.mutation.ClearConnectorData()
return _u
}
// SetExpiry sets the "expiry" field.
func (_u *AuthRequestUpdateOne) SetExpiry(v time.Time) *AuthRequestUpdateOne {
_u.mutation.SetExpiry(v)
return _u
}
// SetNillableExpiry sets the "expiry" field if the given value is not nil.
func (_u *AuthRequestUpdateOne) SetNillableExpiry(v *time.Time) *AuthRequestUpdateOne {
if v != nil {
_u.SetExpiry(*v)
}
return _u
}
// SetCodeChallenge sets the "code_challenge" field.
func (_u *AuthRequestUpdateOne) SetCodeChallenge(v string) *AuthRequestUpdateOne {
_u.mutation.SetCodeChallenge(v)
return _u
}
// SetNillableCodeChallenge sets the "code_challenge" field if the given value is not nil.
func (_u *AuthRequestUpdateOne) SetNillableCodeChallenge(v *string) *AuthRequestUpdateOne {
if v != nil {
_u.SetCodeChallenge(*v)
}
return _u
}
// SetCodeChallengeMethod sets the "code_challenge_method" field.
func (_u *AuthRequestUpdateOne) SetCodeChallengeMethod(v string) *AuthRequestUpdateOne {
_u.mutation.SetCodeChallengeMethod(v)
return _u
}
// SetNillableCodeChallengeMethod sets the "code_challenge_method" field if the given value is not nil.
func (_u *AuthRequestUpdateOne) SetNillableCodeChallengeMethod(v *string) *AuthRequestUpdateOne {
if v != nil {
_u.SetCodeChallengeMethod(*v)
}
return _u
}
// SetHmacKey sets the "hmac_key" field.
func (_u *AuthRequestUpdateOne) SetHmacKey(v []byte) *AuthRequestUpdateOne {
_u.mutation.SetHmacKey(v)
return _u
}
// SetMfaValidated sets the "mfa_validated" field.
func (_u *AuthRequestUpdateOne) SetMfaValidated(v bool) *AuthRequestUpdateOne {
_u.mutation.SetMfaValidated(v)
return _u
}
// SetNillableMfaValidated sets the "mfa_validated" field if the given value is not nil.
func (_u *AuthRequestUpdateOne) SetNillableMfaValidated(v *bool) *AuthRequestUpdateOne {
if v != nil {
_u.SetMfaValidated(*v)
}
return _u
}
// SetWebauthnSessionData sets the "webauthn_session_data" field.
func (_u *AuthRequestUpdateOne) SetWebauthnSessionData(v []byte) *AuthRequestUpdateOne {
_u.mutation.SetWebauthnSessionData(v)
return _u
}
// ClearWebauthnSessionData clears the value of the "webauthn_session_data" field.
func (_u *AuthRequestUpdateOne) ClearWebauthnSessionData() *AuthRequestUpdateOne {
_u.mutation.ClearWebauthnSessionData()
return _u
}
// SetPrompt sets the "prompt" field.
func (_u *AuthRequestUpdateOne) SetPrompt(v string) *AuthRequestUpdateOne {
_u.mutation.SetPrompt(v)
return _u
}
// SetNillablePrompt sets the "prompt" field if the given value is not nil.
func (_u *AuthRequestUpdateOne) SetNillablePrompt(v *string) *AuthRequestUpdateOne {
if v != nil {
_u.SetPrompt(*v)
}
return _u
}
// SetMaxAge sets the "max_age" field.
func (_u *AuthRequestUpdateOne) SetMaxAge(v int) *AuthRequestUpdateOne {
_u.mutation.ResetMaxAge()
_u.mutation.SetMaxAge(v)
return _u
}
// SetNillableMaxAge sets the "max_age" field if the given value is not nil.
func (_u *AuthRequestUpdateOne) SetNillableMaxAge(v *int) *AuthRequestUpdateOne {
if v != nil {
_u.SetMaxAge(*v)
}
return _u
}
// AddMaxAge adds value to the "max_age" field.
func (_u *AuthRequestUpdateOne) AddMaxAge(v int) *AuthRequestUpdateOne {
_u.mutation.AddMaxAge(v)
return _u
}
// SetAuthTime sets the "auth_time" field.
func (_u *AuthRequestUpdateOne) SetAuthTime(v time.Time) *AuthRequestUpdateOne {
_u.mutation.SetAuthTime(v)
return _u
}
// SetNillableAuthTime sets the "auth_time" field if the given value is not nil.
func (_u *AuthRequestUpdateOne) SetNillableAuthTime(v *time.Time) *AuthRequestUpdateOne {
if v != nil {
_u.SetAuthTime(*v)
}
return _u
}
// ClearAuthTime clears the value of the "auth_time" field.
func (_u *AuthRequestUpdateOne) ClearAuthTime() *AuthRequestUpdateOne {
_u.mutation.ClearAuthTime()
return _u
}
// Mutation returns the AuthRequestMutation object of the builder.
func (_u *AuthRequestUpdateOne) Mutation() *AuthRequestMutation {
return _u.mutation
}
// Where appends a list predicates to the AuthRequestUpdate builder.
func (_u *AuthRequestUpdateOne) Where(ps ...predicate.AuthRequest) *AuthRequestUpdateOne {
_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 *AuthRequestUpdateOne) Select(field string, fields ...string) *AuthRequestUpdateOne {
_u.fields = append([]string{field}, fields...)
return _u
}
// Save executes the query and returns the updated AuthRequest entity.
func (_u *AuthRequestUpdateOne) Save(ctx context.Context) (*AuthRequest, error) {
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
}
// SaveX is like Save, but panics if an error occurs.
func (_u *AuthRequestUpdateOne) SaveX(ctx context.Context) *AuthRequest {
node, err := _u.Save(ctx)
if err != nil {
panic(err)
}
return node
}
// Exec executes the query on the entity.
func (_u *AuthRequestUpdateOne) Exec(ctx context.Context) error {
_, err := _u.Save(ctx)
return err
}
// ExecX is like Exec, but panics if an error occurs.
func (_u *AuthRequestUpdateOne) ExecX(ctx context.Context) {
if err := _u.Exec(ctx); err != nil {
panic(err)
}
}
func (_u *AuthRequestUpdateOne) sqlSave(ctx context.Context) (_node *AuthRequest, err error) {
_spec := sqlgraph.NewUpdateSpec(authrequest.Table, authrequest.Columns, sqlgraph.NewFieldSpec(authrequest.FieldID, field.TypeString))
id, ok := _u.mutation.ID()
if !ok {
return nil, &ValidationError{Name: "id", err: errors.New(`db: missing "AuthRequest.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, authrequest.FieldID)
for _, f := range fields {
if !authrequest.ValidColumn(f) {
return nil, &ValidationError{Name: f, err: fmt.Errorf("db: invalid field %q for query", f)}
}
if f != authrequest.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.ClientID(); ok {
_spec.SetField(authrequest.FieldClientID, field.TypeString, value)
}
if value, ok := _u.mutation.Scopes(); ok {
_spec.SetField(authrequest.FieldScopes, field.TypeJSON, value)
}
if value, ok := _u.mutation.AppendedScopes(); ok {
_spec.AddModifier(func(u *sql.UpdateBuilder) {
sqljson.Append(u, authrequest.FieldScopes, value)
})
}
if _u.mutation.ScopesCleared() {
_spec.ClearField(authrequest.FieldScopes, field.TypeJSON)
}
if value, ok := _u.mutation.ResponseTypes(); ok {
_spec.SetField(authrequest.FieldResponseTypes, field.TypeJSON, value)
}
if value, ok := _u.mutation.AppendedResponseTypes(); ok {
_spec.AddModifier(func(u *sql.UpdateBuilder) {
sqljson.Append(u, authrequest.FieldResponseTypes, value)
})
}
if _u.mutation.ResponseTypesCleared() {
_spec.ClearField(authrequest.FieldResponseTypes, field.TypeJSON)
}
if value, ok := _u.mutation.RedirectURI(); ok {
_spec.SetField(authrequest.FieldRedirectURI, field.TypeString, value)
}
if value, ok := _u.mutation.Nonce(); ok {
_spec.SetField(authrequest.FieldNonce, field.TypeString, value)
}
if value, ok := _u.mutation.State(); ok {
_spec.SetField(authrequest.FieldState, field.TypeString, value)
}
if value, ok := _u.mutation.ForceApprovalPrompt(); ok {
_spec.SetField(authrequest.FieldForceApprovalPrompt, field.TypeBool, value)
}
if value, ok := _u.mutation.LoggedIn(); ok {
_spec.SetField(authrequest.FieldLoggedIn, field.TypeBool, value)
}
if value, ok := _u.mutation.ClaimsUserID(); ok {
_spec.SetField(authrequest.FieldClaimsUserID, field.TypeString, value)
}
if value, ok := _u.mutation.ClaimsUsername(); ok {
_spec.SetField(authrequest.FieldClaimsUsername, field.TypeString, value)
}
if value, ok := _u.mutation.ClaimsEmail(); ok {
_spec.SetField(authrequest.FieldClaimsEmail, field.TypeString, value)
}
if value, ok := _u.mutation.ClaimsEmailVerified(); ok {
_spec.SetField(authrequest.FieldClaimsEmailVerified, field.TypeBool, value)
}
if value, ok := _u.mutation.ClaimsGroups(); ok {
_spec.SetField(authrequest.FieldClaimsGroups, field.TypeJSON, value)
}
if value, ok := _u.mutation.AppendedClaimsGroups(); ok {
_spec.AddModifier(func(u *sql.UpdateBuilder) {
sqljson.Append(u, authrequest.FieldClaimsGroups, value)
})
}
if _u.mutation.ClaimsGroupsCleared() {
_spec.ClearField(authrequest.FieldClaimsGroups, field.TypeJSON)
}
if value, ok := _u.mutation.ClaimsPreferredUsername(); ok {
_spec.SetField(authrequest.FieldClaimsPreferredUsername, field.TypeString, value)
}
if value, ok := _u.mutation.ConnectorID(); ok {
_spec.SetField(authrequest.FieldConnectorID, field.TypeString, value)
}
if value, ok := _u.mutation.ConnectorData(); ok {
_spec.SetField(authrequest.FieldConnectorData, field.TypeBytes, value)
}
if _u.mutation.ConnectorDataCleared() {
_spec.ClearField(authrequest.FieldConnectorData, field.TypeBytes)
}
if value, ok := _u.mutation.Expiry(); ok {
_spec.SetField(authrequest.FieldExpiry, field.TypeTime, value)
}
if value, ok := _u.mutation.CodeChallenge(); ok {
_spec.SetField(authrequest.FieldCodeChallenge, field.TypeString, value)
}
if value, ok := _u.mutation.CodeChallengeMethod(); ok {
_spec.SetField(authrequest.FieldCodeChallengeMethod, field.TypeString, value)
}
if value, ok := _u.mutation.HmacKey(); ok {
_spec.SetField(authrequest.FieldHmacKey, field.TypeBytes, value)
}
if value, ok := _u.mutation.MfaValidated(); ok {
_spec.SetField(authrequest.FieldMfaValidated, field.TypeBool, value)
}
if value, ok := _u.mutation.WebauthnSessionData(); ok {
_spec.SetField(authrequest.FieldWebauthnSessionData, field.TypeBytes, value)
}
if _u.mutation.WebauthnSessionDataCleared() {
_spec.ClearField(authrequest.FieldWebauthnSessionData, field.TypeBytes)
}
if value, ok := _u.mutation.Prompt(); ok {
_spec.SetField(authrequest.FieldPrompt, field.TypeString, value)
}
if value, ok := _u.mutation.MaxAge(); ok {
_spec.SetField(authrequest.FieldMaxAge, field.TypeInt, value)
}
if value, ok := _u.mutation.AddedMaxAge(); ok {
_spec.AddField(authrequest.FieldMaxAge, field.TypeInt, value)
}
if value, ok := _u.mutation.AuthTime(); ok {
_spec.SetField(authrequest.FieldAuthTime, field.TypeTime, value)
}
if _u.mutation.AuthTimeCleared() {
_spec.ClearField(authrequest.FieldAuthTime, field.TypeTime)
}
_node = &AuthRequest{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{authrequest.Label}
} else if sqlgraph.IsConstraintError(err) {
err = &ConstraintError{msg: err.Error(), wrap: err}
}
return nil, err
}
_u.mutation.done = true
return _node, nil
}