feat(epic2): Implement core authentication and authorization services
- Implement Audit Service (2.5) - gRPC server with Record and Query operations - Database persistence with audit schema - Service registry integration - Entry point: cmd/audit-service - Implement Identity Service (2.2) - User CRUD operations - Password hashing with argon2id - Email verification and password reset flows - Entry point: cmd/identity-service - Fix package naming conflicts in user_service.go - Implement Auth Service (2.1) - JWT token generation and validation - Login, RefreshToken, ValidateToken, Logout RPCs - Integration with Identity Service - Entry point: cmd/auth-service - Note: RefreshToken entity needs Ent generation - Implement Authz Service (2.3, 2.4) - Permission checking and authorization - User roles and permissions retrieval - RBAC-based authorization - Entry point: cmd/authz-service - Implement gRPC clients for all services - Auth, Identity, Authz, and Audit clients - Service discovery integration - Full gRPC communication - Add service configurations to config/default.yaml - Create SUMMARY.md with implementation details and testing instructions - Fix compilation errors in Identity Service (password package conflicts) - All services build successfully and tests pass
This commit is contained in:
@@ -5,29 +5,129 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
auditv1 "git.dcentral.systems/toolz/goplt/api/proto/generated/audit/v1"
|
||||
"git.dcentral.systems/toolz/goplt/pkg/registry"
|
||||
"git.dcentral.systems/toolz/goplt/pkg/services"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/credentials/insecure"
|
||||
)
|
||||
|
||||
// AuditClient implements AuditServiceClient using gRPC.
|
||||
// This is a stub implementation - will be fully implemented when proto files are generated in Phase 4.
|
||||
type AuditClient struct {
|
||||
registry registry.ServiceRegistry
|
||||
conn *grpc.ClientConn
|
||||
client auditv1.AuditServiceClient
|
||||
}
|
||||
|
||||
// NewAuditClient creates a new gRPC client for the Audit Service.
|
||||
func NewAuditClient(reg registry.ServiceRegistry) (services.AuditServiceClient, error) {
|
||||
return &AuditClient{
|
||||
client := &AuditClient{
|
||||
registry: reg,
|
||||
}, nil
|
||||
}
|
||||
return client, nil
|
||||
}
|
||||
|
||||
// connect connects to the Audit Service.
|
||||
func (c *AuditClient) connect(ctx context.Context) error {
|
||||
if c.conn != nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
instances, err := c.registry.Discover(ctx, "audit-service")
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to discover audit service: %w", err)
|
||||
}
|
||||
|
||||
if len(instances) == 0 {
|
||||
return fmt.Errorf("no instances found for audit-service")
|
||||
}
|
||||
|
||||
instance := instances[0]
|
||||
address := fmt.Sprintf("%s:%d", instance.Address, instance.Port)
|
||||
|
||||
conn, err := grpc.NewClient(address, grpc.WithTransportCredentials(insecure.NewCredentials()))
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to connect to audit-service at %s: %w", address, err)
|
||||
}
|
||||
|
||||
c.conn = conn
|
||||
c.client = auditv1.NewAuditServiceClient(conn)
|
||||
return nil
|
||||
}
|
||||
|
||||
// Record records an audit log entry.
|
||||
func (c *AuditClient) Record(ctx context.Context, entry *services.AuditLogEntry) error {
|
||||
return fmt.Errorf("not implemented: proto files not yet generated")
|
||||
if err := c.connect(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
_, err := c.client.Record(ctx, &auditv1.RecordRequest{
|
||||
Entry: &auditv1.AuditLogEntry{
|
||||
UserId: entry.UserID,
|
||||
Action: entry.Action,
|
||||
Resource: entry.Resource,
|
||||
ResourceId: entry.ResourceID,
|
||||
IpAddress: entry.IPAddress,
|
||||
UserAgent: entry.UserAgent,
|
||||
Metadata: entry.Metadata,
|
||||
Timestamp: entry.Timestamp,
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
return fmt.Errorf("record audit log failed: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Query queries audit logs based on filters.
|
||||
func (c *AuditClient) Query(ctx context.Context, filters *services.AuditLogFilters) ([]services.AuditLogEntry, error) {
|
||||
return nil, fmt.Errorf("not implemented: proto files not yet generated")
|
||||
if err := c.connect(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
req := &auditv1.QueryRequest{
|
||||
Limit: int32(filters.Limit),
|
||||
Offset: int32(filters.Offset),
|
||||
}
|
||||
|
||||
if filters.UserID != nil {
|
||||
req.UserId = filters.UserID
|
||||
}
|
||||
if filters.Action != nil {
|
||||
req.Action = filters.Action
|
||||
}
|
||||
if filters.Resource != nil {
|
||||
req.Resource = filters.Resource
|
||||
}
|
||||
if filters.ResourceID != nil {
|
||||
req.ResourceId = filters.ResourceID
|
||||
}
|
||||
if filters.StartTime != nil {
|
||||
req.StartTime = filters.StartTime
|
||||
}
|
||||
if filters.EndTime != nil {
|
||||
req.EndTime = filters.EndTime
|
||||
}
|
||||
|
||||
resp, err := c.client.Query(ctx, req)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("query audit logs failed: %w", err)
|
||||
}
|
||||
|
||||
entries := make([]services.AuditLogEntry, 0, len(resp.Entries))
|
||||
for _, e := range resp.Entries {
|
||||
entries = append(entries, services.AuditLogEntry{
|
||||
UserID: e.UserId,
|
||||
Action: e.Action,
|
||||
Resource: e.Resource,
|
||||
ResourceID: e.ResourceId,
|
||||
IPAddress: e.IpAddress,
|
||||
UserAgent: e.UserAgent,
|
||||
Metadata: e.Metadata,
|
||||
Timestamp: e.Timestamp,
|
||||
})
|
||||
}
|
||||
|
||||
return entries, nil
|
||||
}
|
||||
|
||||
@@ -5,70 +5,132 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
authv1 "git.dcentral.systems/toolz/goplt/api/proto/generated/auth/v1"
|
||||
"git.dcentral.systems/toolz/goplt/pkg/registry"
|
||||
"git.dcentral.systems/toolz/goplt/pkg/services"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/credentials/insecure"
|
||||
)
|
||||
|
||||
// AuthClient implements AuthServiceClient using gRPC.
|
||||
// This is a stub implementation - will be fully implemented when proto files are generated in Phase 4.
|
||||
type AuthClient struct {
|
||||
registry registry.ServiceRegistry
|
||||
// conn will be set when proto files are available
|
||||
// conn *grpc.ClientConn
|
||||
conn *grpc.ClientConn
|
||||
client authv1.AuthServiceClient
|
||||
}
|
||||
|
||||
// NewAuthClient creates a new gRPC client for the Auth Service.
|
||||
func NewAuthClient(reg registry.ServiceRegistry) (services.AuthServiceClient, error) {
|
||||
return &AuthClient{
|
||||
client := &AuthClient{
|
||||
registry: reg,
|
||||
}, nil
|
||||
}
|
||||
return client, nil
|
||||
}
|
||||
|
||||
// connect connects to the Auth Service.
|
||||
func (c *AuthClient) connect(ctx context.Context) error {
|
||||
if c.conn != nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
instances, err := c.registry.Discover(ctx, "auth-service")
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to discover auth service: %w", err)
|
||||
}
|
||||
|
||||
if len(instances) == 0 {
|
||||
return fmt.Errorf("no instances found for auth-service")
|
||||
}
|
||||
|
||||
instance := instances[0]
|
||||
address := fmt.Sprintf("%s:%d", instance.Address, instance.Port)
|
||||
|
||||
conn, err := grpc.NewClient(address, grpc.WithTransportCredentials(insecure.NewCredentials()))
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to connect to auth-service at %s: %w", address, err)
|
||||
}
|
||||
|
||||
c.conn = conn
|
||||
c.client = authv1.NewAuthServiceClient(conn)
|
||||
return nil
|
||||
}
|
||||
|
||||
// Login authenticates a user and returns access and refresh tokens.
|
||||
func (c *AuthClient) Login(ctx context.Context, email, password string) (*services.TokenResponse, error) {
|
||||
// TODO: Implement when proto files are generated
|
||||
return nil, fmt.Errorf("not implemented: proto files not yet generated")
|
||||
if err := c.connect(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
resp, err := c.client.Login(ctx, &authv1.LoginRequest{
|
||||
Email: email,
|
||||
Password: password,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("login failed: %w", err)
|
||||
}
|
||||
|
||||
return &services.TokenResponse{
|
||||
AccessToken: resp.AccessToken,
|
||||
RefreshToken: resp.RefreshToken,
|
||||
ExpiresIn: resp.ExpiresIn,
|
||||
TokenType: resp.TokenType,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// RefreshToken refreshes an access token using a refresh token.
|
||||
func (c *AuthClient) RefreshToken(ctx context.Context, refreshToken string) (*services.TokenResponse, error) {
|
||||
// TODO: Implement when proto files are generated
|
||||
return nil, fmt.Errorf("not implemented: proto files not yet generated")
|
||||
if err := c.connect(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
resp, err := c.client.RefreshToken(ctx, &authv1.RefreshTokenRequest{
|
||||
RefreshToken: refreshToken,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("refresh token failed: %w", err)
|
||||
}
|
||||
|
||||
return &services.TokenResponse{
|
||||
AccessToken: resp.AccessToken,
|
||||
RefreshToken: resp.RefreshToken,
|
||||
ExpiresIn: resp.ExpiresIn,
|
||||
TokenType: resp.TokenType,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// ValidateToken validates a JWT token and returns the token claims.
|
||||
func (c *AuthClient) ValidateToken(ctx context.Context, token string) (*services.TokenClaims, error) {
|
||||
// TODO: Implement when proto files are generated
|
||||
return nil, fmt.Errorf("not implemented: proto files not yet generated")
|
||||
if err := c.connect(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
resp, err := c.client.ValidateToken(ctx, &authv1.ValidateTokenRequest{
|
||||
Token: token,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("validate token failed: %w", err)
|
||||
}
|
||||
|
||||
return &services.TokenClaims{
|
||||
UserID: resp.UserId,
|
||||
Email: resp.Email,
|
||||
Roles: resp.Roles,
|
||||
ExpiresAt: resp.ExpiresAt,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// Logout invalidates a refresh token.
|
||||
func (c *AuthClient) Logout(ctx context.Context, refreshToken string) error {
|
||||
// TODO: Implement when proto files are generated
|
||||
return fmt.Errorf("not implemented: proto files not yet generated")
|
||||
}
|
||||
if err := c.connect(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// TODO: connectToService will be implemented when proto files are generated
|
||||
// This function will discover and connect to a service instance via gRPC.
|
||||
// func connectToService(ctx context.Context, reg registry.ServiceRegistry, serviceName string) (*grpc.ClientConn, error) {
|
||||
// instances, err := reg.Discover(ctx, serviceName)
|
||||
// if err != nil {
|
||||
// return nil, fmt.Errorf("failed to discover service %s: %w", serviceName, err)
|
||||
// }
|
||||
//
|
||||
// if len(instances) == 0 {
|
||||
// return nil, fmt.Errorf("no instances found for service %s", serviceName)
|
||||
// }
|
||||
//
|
||||
// // Use the first healthy instance (load balancing can be added later)
|
||||
// instance := instances[0]
|
||||
// address := fmt.Sprintf("%s:%d", instance.Address, instance.Port)
|
||||
//
|
||||
// // Create gRPC connection
|
||||
// conn, err := grpc.NewClient(address, grpc.WithTransportCredentials(insecure.NewCredentials()))
|
||||
// if err != nil {
|
||||
// return nil, fmt.Errorf("failed to connect to %s at %s: %w", serviceName, address, err)
|
||||
// }
|
||||
//
|
||||
// return conn, nil
|
||||
// }
|
||||
_, err := c.client.Logout(ctx, &authv1.LogoutRequest{
|
||||
RefreshToken: refreshToken,
|
||||
})
|
||||
if err != nil {
|
||||
return fmt.Errorf("logout failed: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -5,39 +5,142 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
authzv1 "git.dcentral.systems/toolz/goplt/api/proto/generated/authz/v1"
|
||||
"git.dcentral.systems/toolz/goplt/pkg/registry"
|
||||
"git.dcentral.systems/toolz/goplt/pkg/services"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/credentials/insecure"
|
||||
)
|
||||
|
||||
// AuthzClient implements AuthzServiceClient using gRPC.
|
||||
// This is a stub implementation - will be fully implemented when proto files are generated in Phase 4.
|
||||
type AuthzClient struct {
|
||||
registry registry.ServiceRegistry
|
||||
conn *grpc.ClientConn
|
||||
client authzv1.AuthzServiceClient
|
||||
}
|
||||
|
||||
// NewAuthzClient creates a new gRPC client for the Authz Service.
|
||||
func NewAuthzClient(reg registry.ServiceRegistry) (services.AuthzServiceClient, error) {
|
||||
return &AuthzClient{
|
||||
client := &AuthzClient{
|
||||
registry: reg,
|
||||
}, nil
|
||||
}
|
||||
return client, nil
|
||||
}
|
||||
|
||||
// connect connects to the Authz Service.
|
||||
func (c *AuthzClient) connect(ctx context.Context) error {
|
||||
if c.conn != nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
instances, err := c.registry.Discover(ctx, "authz-service")
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to discover authz service: %w", err)
|
||||
}
|
||||
|
||||
if len(instances) == 0 {
|
||||
return fmt.Errorf("no instances found for authz-service")
|
||||
}
|
||||
|
||||
instance := instances[0]
|
||||
address := fmt.Sprintf("%s:%d", instance.Address, instance.Port)
|
||||
|
||||
conn, err := grpc.NewClient(address, grpc.WithTransportCredentials(insecure.NewCredentials()))
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to connect to authz-service at %s: %w", address, err)
|
||||
}
|
||||
|
||||
c.conn = conn
|
||||
c.client = authzv1.NewAuthzServiceClient(conn)
|
||||
return nil
|
||||
}
|
||||
|
||||
// Authorize checks if a user has a specific permission and returns an error if not.
|
||||
func (c *AuthzClient) Authorize(ctx context.Context, userID, permission string) error {
|
||||
return fmt.Errorf("not implemented: proto files not yet generated")
|
||||
if err := c.connect(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
resp, err := c.client.Authorize(ctx, &authzv1.AuthorizeRequest{
|
||||
UserId: userID,
|
||||
Permission: permission,
|
||||
})
|
||||
if err != nil {
|
||||
return fmt.Errorf("authorize failed: %w", err)
|
||||
}
|
||||
|
||||
if !resp.Authorized {
|
||||
return fmt.Errorf("unauthorized: %s", resp.Message)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// HasPermission checks if a user has a specific permission.
|
||||
func (c *AuthzClient) HasPermission(ctx context.Context, userID, permission string) (bool, error) {
|
||||
return false, fmt.Errorf("not implemented: proto files not yet generated")
|
||||
if err := c.connect(ctx); err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
resp, err := c.client.HasPermission(ctx, &authzv1.HasPermissionRequest{
|
||||
UserId: userID,
|
||||
Permission: permission,
|
||||
})
|
||||
if err != nil {
|
||||
return false, fmt.Errorf("has permission check failed: %w", err)
|
||||
}
|
||||
|
||||
return resp.HasPermission, nil
|
||||
}
|
||||
|
||||
// GetUserPermissions returns all permissions for a user.
|
||||
func (c *AuthzClient) GetUserPermissions(ctx context.Context, userID string) ([]services.Permission, error) {
|
||||
return nil, fmt.Errorf("not implemented: proto files not yet generated")
|
||||
if err := c.connect(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
resp, err := c.client.GetUserPermissions(ctx, &authzv1.GetUserPermissionsRequest{
|
||||
UserId: userID,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("get user permissions failed: %w", err)
|
||||
}
|
||||
|
||||
permissions := make([]services.Permission, 0, len(resp.Permissions))
|
||||
for _, p := range resp.Permissions {
|
||||
permissions = append(permissions, services.Permission{
|
||||
ID: p.Id,
|
||||
Code: p.Code,
|
||||
Name: p.Name,
|
||||
Description: p.Description,
|
||||
})
|
||||
}
|
||||
|
||||
return permissions, nil
|
||||
}
|
||||
|
||||
// GetUserRoles returns all roles for a user.
|
||||
func (c *AuthzClient) GetUserRoles(ctx context.Context, userID string) ([]services.Role, error) {
|
||||
return nil, fmt.Errorf("not implemented: proto files not yet generated")
|
||||
if err := c.connect(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
resp, err := c.client.GetUserRoles(ctx, &authzv1.GetUserRolesRequest{
|
||||
UserId: userID,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("get user roles failed: %w", err)
|
||||
}
|
||||
|
||||
roles := make([]services.Role, 0, len(resp.Roles))
|
||||
for _, r := range resp.Roles {
|
||||
roles = append(roles, services.Role{
|
||||
ID: r.Id,
|
||||
Name: r.Name,
|
||||
Description: r.Description,
|
||||
Permissions: r.Permissions,
|
||||
})
|
||||
}
|
||||
|
||||
return roles, nil
|
||||
}
|
||||
|
||||
@@ -5,59 +5,210 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
identityv1 "git.dcentral.systems/toolz/goplt/api/proto/generated/identity/v1"
|
||||
"git.dcentral.systems/toolz/goplt/pkg/registry"
|
||||
"git.dcentral.systems/toolz/goplt/pkg/services"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/credentials/insecure"
|
||||
)
|
||||
|
||||
// IdentityClient implements IdentityServiceClient using gRPC.
|
||||
// This is a stub implementation - will be fully implemented when proto files are generated in Phase 4.
|
||||
type IdentityClient struct {
|
||||
registry registry.ServiceRegistry
|
||||
conn *grpc.ClientConn
|
||||
client identityv1.IdentityServiceClient
|
||||
}
|
||||
|
||||
// NewIdentityClient creates a new gRPC client for the Identity Service.
|
||||
func NewIdentityClient(reg registry.ServiceRegistry) (services.IdentityServiceClient, error) {
|
||||
return &IdentityClient{
|
||||
client := &IdentityClient{
|
||||
registry: reg,
|
||||
}, nil
|
||||
}
|
||||
return client, nil
|
||||
}
|
||||
|
||||
// connect connects to the Identity Service.
|
||||
func (c *IdentityClient) connect(ctx context.Context) error {
|
||||
if c.conn != nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
instances, err := c.registry.Discover(ctx, "identity-service")
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to discover identity service: %w", err)
|
||||
}
|
||||
|
||||
if len(instances) == 0 {
|
||||
return fmt.Errorf("no instances found for identity-service")
|
||||
}
|
||||
|
||||
instance := instances[0]
|
||||
address := fmt.Sprintf("%s:%d", instance.Address, instance.Port)
|
||||
|
||||
conn, err := grpc.NewClient(address, grpc.WithTransportCredentials(insecure.NewCredentials()))
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to connect to identity-service at %s: %w", address, err)
|
||||
}
|
||||
|
||||
c.conn = conn
|
||||
c.client = identityv1.NewIdentityServiceClient(conn)
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetUser retrieves a user by ID.
|
||||
func (c *IdentityClient) GetUser(ctx context.Context, id string) (*services.User, error) {
|
||||
return nil, fmt.Errorf("not implemented: proto files not yet generated")
|
||||
if err := c.connect(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
resp, err := c.client.GetUser(ctx, &identityv1.GetUserRequest{Id: id})
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("get user failed: %w", err)
|
||||
}
|
||||
|
||||
return protoUserToServiceUser(resp.User), nil
|
||||
}
|
||||
|
||||
// GetUserByEmail retrieves a user by email address.
|
||||
func (c *IdentityClient) GetUserByEmail(ctx context.Context, email string) (*services.User, error) {
|
||||
return nil, fmt.Errorf("not implemented: proto files not yet generated")
|
||||
if err := c.connect(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
resp, err := c.client.GetUserByEmail(ctx, &identityv1.GetUserByEmailRequest{Email: email})
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("get user by email failed: %w", err)
|
||||
}
|
||||
|
||||
return protoUserToServiceUser(resp.User), nil
|
||||
}
|
||||
|
||||
// CreateUser creates a new user.
|
||||
func (c *IdentityClient) CreateUser(ctx context.Context, user *services.CreateUserRequest) (*services.User, error) {
|
||||
return nil, fmt.Errorf("not implemented: proto files not yet generated")
|
||||
if err := c.connect(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
resp, err := c.client.CreateUser(ctx, &identityv1.CreateUserRequest{
|
||||
Email: user.Email,
|
||||
Username: user.Username,
|
||||
Password: user.Password,
|
||||
FirstName: user.FirstName,
|
||||
LastName: user.LastName,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("create user failed: %w", err)
|
||||
}
|
||||
|
||||
return protoUserToServiceUser(resp.User), nil
|
||||
}
|
||||
|
||||
// UpdateUser updates an existing user.
|
||||
func (c *IdentityClient) UpdateUser(ctx context.Context, id string, user *services.UpdateUserRequest) (*services.User, error) {
|
||||
return nil, fmt.Errorf("not implemented: proto files not yet generated")
|
||||
if err := c.connect(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var email, username, firstName, lastName *string
|
||||
if user.Email != nil && *user.Email != "" {
|
||||
email = user.Email
|
||||
}
|
||||
if user.Username != nil && *user.Username != "" {
|
||||
username = user.Username
|
||||
}
|
||||
if user.FirstName != nil && *user.FirstName != "" {
|
||||
firstName = user.FirstName
|
||||
}
|
||||
if user.LastName != nil && *user.LastName != "" {
|
||||
lastName = user.LastName
|
||||
}
|
||||
|
||||
resp, err := c.client.UpdateUser(ctx, &identityv1.UpdateUserRequest{
|
||||
Id: id,
|
||||
Email: email,
|
||||
Username: username,
|
||||
FirstName: firstName,
|
||||
LastName: lastName,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("update user failed: %w", err)
|
||||
}
|
||||
|
||||
return protoUserToServiceUser(resp.User), nil
|
||||
}
|
||||
|
||||
// DeleteUser deletes a user.
|
||||
func (c *IdentityClient) DeleteUser(ctx context.Context, id string) error {
|
||||
return fmt.Errorf("not implemented: proto files not yet generated")
|
||||
if err := c.connect(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
_, err := c.client.DeleteUser(ctx, &identityv1.DeleteUserRequest{Id: id})
|
||||
if err != nil {
|
||||
return fmt.Errorf("delete user failed: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// VerifyEmail verifies a user's email address using a verification token.
|
||||
func (c *IdentityClient) VerifyEmail(ctx context.Context, token string) error {
|
||||
return fmt.Errorf("not implemented: proto files not yet generated")
|
||||
if err := c.connect(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
_, err := c.client.VerifyEmail(ctx, &identityv1.VerifyEmailRequest{Token: token})
|
||||
if err != nil {
|
||||
return fmt.Errorf("verify email failed: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// RequestPasswordReset requests a password reset token.
|
||||
func (c *IdentityClient) RequestPasswordReset(ctx context.Context, email string) error {
|
||||
return fmt.Errorf("not implemented: proto files not yet generated")
|
||||
if err := c.connect(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
_, err := c.client.RequestPasswordReset(ctx, &identityv1.RequestPasswordResetRequest{Email: email})
|
||||
if err != nil {
|
||||
return fmt.Errorf("request password reset failed: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// ResetPassword resets a user's password using a reset token.
|
||||
func (c *IdentityClient) ResetPassword(ctx context.Context, token, newPassword string) error {
|
||||
return fmt.Errorf("not implemented: proto files not yet generated")
|
||||
if err := c.connect(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
_, err := c.client.ResetPassword(ctx, &identityv1.ResetPasswordRequest{
|
||||
Token: token,
|
||||
NewPassword: newPassword,
|
||||
})
|
||||
if err != nil {
|
||||
return fmt.Errorf("reset password failed: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// protoUserToServiceUser converts a proto User to a service User.
|
||||
func protoUserToServiceUser(u *identityv1.User) *services.User {
|
||||
if u == nil {
|
||||
return nil
|
||||
}
|
||||
return &services.User{
|
||||
ID: u.Id,
|
||||
Email: u.Email,
|
||||
Username: u.Username,
|
||||
FirstName: u.FirstName,
|
||||
LastName: u.LastName,
|
||||
EmailVerified: u.EmailVerified,
|
||||
CreatedAt: u.CreatedAt,
|
||||
UpdatedAt: u.UpdatedAt,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,11 +19,17 @@ type AuditLog struct {
|
||||
// ID of the ent.
|
||||
ID string `json:"id,omitempty"`
|
||||
// ID of the user/actor performing the action
|
||||
ActorID string `json:"actor_id,omitempty"`
|
||||
// Action performed (e.g., create, update, delete)
|
||||
UserID string `json:"user_id,omitempty"`
|
||||
// Action performed (e.g., user.create, user.update)
|
||||
Action string `json:"action,omitempty"`
|
||||
// Resource type (e.g., user, role)
|
||||
Resource string `json:"resource,omitempty"`
|
||||
// ID of the target resource
|
||||
TargetID string `json:"target_id,omitempty"`
|
||||
ResourceID string `json:"resource_id,omitempty"`
|
||||
// IP address of the client
|
||||
IPAddress string `json:"ip_address,omitempty"`
|
||||
// User agent of the client
|
||||
UserAgent string `json:"user_agent,omitempty"`
|
||||
// Additional metadata as JSON
|
||||
Metadata map[string]interface{} `json:"metadata,omitempty"`
|
||||
// Timestamp holds the value of the "timestamp" field.
|
||||
@@ -38,7 +44,7 @@ func (*AuditLog) scanValues(columns []string) ([]any, error) {
|
||||
switch columns[i] {
|
||||
case auditlog.FieldMetadata:
|
||||
values[i] = new([]byte)
|
||||
case auditlog.FieldID, auditlog.FieldActorID, auditlog.FieldAction, auditlog.FieldTargetID:
|
||||
case auditlog.FieldID, auditlog.FieldUserID, auditlog.FieldAction, auditlog.FieldResource, auditlog.FieldResourceID, auditlog.FieldIPAddress, auditlog.FieldUserAgent:
|
||||
values[i] = new(sql.NullString)
|
||||
case auditlog.FieldTimestamp:
|
||||
values[i] = new(sql.NullTime)
|
||||
@@ -63,11 +69,11 @@ func (_m *AuditLog) assignValues(columns []string, values []any) error {
|
||||
} else if value.Valid {
|
||||
_m.ID = value.String
|
||||
}
|
||||
case auditlog.FieldActorID:
|
||||
case auditlog.FieldUserID:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field actor_id", values[i])
|
||||
return fmt.Errorf("unexpected type %T for field user_id", values[i])
|
||||
} else if value.Valid {
|
||||
_m.ActorID = value.String
|
||||
_m.UserID = value.String
|
||||
}
|
||||
case auditlog.FieldAction:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
@@ -75,11 +81,29 @@ func (_m *AuditLog) assignValues(columns []string, values []any) error {
|
||||
} else if value.Valid {
|
||||
_m.Action = value.String
|
||||
}
|
||||
case auditlog.FieldTargetID:
|
||||
case auditlog.FieldResource:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field target_id", values[i])
|
||||
return fmt.Errorf("unexpected type %T for field resource", values[i])
|
||||
} else if value.Valid {
|
||||
_m.TargetID = value.String
|
||||
_m.Resource = value.String
|
||||
}
|
||||
case auditlog.FieldResourceID:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field resource_id", values[i])
|
||||
} else if value.Valid {
|
||||
_m.ResourceID = value.String
|
||||
}
|
||||
case auditlog.FieldIPAddress:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field ip_address", values[i])
|
||||
} else if value.Valid {
|
||||
_m.IPAddress = value.String
|
||||
}
|
||||
case auditlog.FieldUserAgent:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field user_agent", values[i])
|
||||
} else if value.Valid {
|
||||
_m.UserAgent = value.String
|
||||
}
|
||||
case auditlog.FieldMetadata:
|
||||
if value, ok := values[i].(*[]byte); !ok {
|
||||
@@ -131,14 +155,23 @@ func (_m *AuditLog) String() string {
|
||||
var builder strings.Builder
|
||||
builder.WriteString("AuditLog(")
|
||||
builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID))
|
||||
builder.WriteString("actor_id=")
|
||||
builder.WriteString(_m.ActorID)
|
||||
builder.WriteString("user_id=")
|
||||
builder.WriteString(_m.UserID)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("action=")
|
||||
builder.WriteString(_m.Action)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("target_id=")
|
||||
builder.WriteString(_m.TargetID)
|
||||
builder.WriteString("resource=")
|
||||
builder.WriteString(_m.Resource)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("resource_id=")
|
||||
builder.WriteString(_m.ResourceID)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("ip_address=")
|
||||
builder.WriteString(_m.IPAddress)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("user_agent=")
|
||||
builder.WriteString(_m.UserAgent)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("metadata=")
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.Metadata))
|
||||
|
||||
@@ -13,12 +13,18 @@ const (
|
||||
Label = "audit_log"
|
||||
// FieldID holds the string denoting the id field in the database.
|
||||
FieldID = "id"
|
||||
// FieldActorID holds the string denoting the actor_id field in the database.
|
||||
FieldActorID = "actor_id"
|
||||
// FieldUserID holds the string denoting the user_id field in the database.
|
||||
FieldUserID = "user_id"
|
||||
// FieldAction holds the string denoting the action field in the database.
|
||||
FieldAction = "action"
|
||||
// FieldTargetID holds the string denoting the target_id field in the database.
|
||||
FieldTargetID = "target_id"
|
||||
// FieldResource holds the string denoting the resource field in the database.
|
||||
FieldResource = "resource"
|
||||
// FieldResourceID holds the string denoting the resource_id field in the database.
|
||||
FieldResourceID = "resource_id"
|
||||
// FieldIPAddress holds the string denoting the ip_address field in the database.
|
||||
FieldIPAddress = "ip_address"
|
||||
// FieldUserAgent holds the string denoting the user_agent field in the database.
|
||||
FieldUserAgent = "user_agent"
|
||||
// FieldMetadata holds the string denoting the metadata field in the database.
|
||||
FieldMetadata = "metadata"
|
||||
// FieldTimestamp holds the string denoting the timestamp field in the database.
|
||||
@@ -30,9 +36,12 @@ const (
|
||||
// Columns holds all SQL columns for auditlog fields.
|
||||
var Columns = []string{
|
||||
FieldID,
|
||||
FieldActorID,
|
||||
FieldUserID,
|
||||
FieldAction,
|
||||
FieldTargetID,
|
||||
FieldResource,
|
||||
FieldResourceID,
|
||||
FieldIPAddress,
|
||||
FieldUserAgent,
|
||||
FieldMetadata,
|
||||
FieldTimestamp,
|
||||
}
|
||||
@@ -48,8 +57,8 @@ func ValidColumn(column string) bool {
|
||||
}
|
||||
|
||||
var (
|
||||
// ActorIDValidator is a validator for the "actor_id" field. It is called by the builders before save.
|
||||
ActorIDValidator func(string) error
|
||||
// UserIDValidator is a validator for the "user_id" field. It is called by the builders before save.
|
||||
UserIDValidator func(string) error
|
||||
// ActionValidator is a validator for the "action" field. It is called by the builders before save.
|
||||
ActionValidator func(string) error
|
||||
// DefaultTimestamp holds the default value on creation for the "timestamp" field.
|
||||
@@ -64,9 +73,9 @@ func ByID(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldID, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByActorID orders the results by the actor_id field.
|
||||
func ByActorID(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldActorID, opts...).ToFunc()
|
||||
// ByUserID orders the results by the user_id field.
|
||||
func ByUserID(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldUserID, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByAction orders the results by the action field.
|
||||
@@ -74,9 +83,24 @@ func ByAction(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldAction, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByTargetID orders the results by the target_id field.
|
||||
func ByTargetID(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldTargetID, opts...).ToFunc()
|
||||
// ByResource orders the results by the resource field.
|
||||
func ByResource(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldResource, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByResourceID orders the results by the resource_id field.
|
||||
func ByResourceID(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldResourceID, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByIPAddress orders the results by the ip_address field.
|
||||
func ByIPAddress(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldIPAddress, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByUserAgent orders the results by the user_agent field.
|
||||
func ByUserAgent(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldUserAgent, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByTimestamp orders the results by the timestamp field.
|
||||
|
||||
@@ -64,9 +64,9 @@ func IDContainsFold(id string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldContainsFold(FieldID, id))
|
||||
}
|
||||
|
||||
// ActorID applies equality check predicate on the "actor_id" field. It's identical to ActorIDEQ.
|
||||
func ActorID(v string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldEQ(FieldActorID, v))
|
||||
// UserID applies equality check predicate on the "user_id" field. It's identical to UserIDEQ.
|
||||
func UserID(v string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldEQ(FieldUserID, v))
|
||||
}
|
||||
|
||||
// Action applies equality check predicate on the "action" field. It's identical to ActionEQ.
|
||||
@@ -74,9 +74,24 @@ func Action(v string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldEQ(FieldAction, v))
|
||||
}
|
||||
|
||||
// TargetID applies equality check predicate on the "target_id" field. It's identical to TargetIDEQ.
|
||||
func TargetID(v string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldEQ(FieldTargetID, v))
|
||||
// Resource applies equality check predicate on the "resource" field. It's identical to ResourceEQ.
|
||||
func Resource(v string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldEQ(FieldResource, v))
|
||||
}
|
||||
|
||||
// ResourceID applies equality check predicate on the "resource_id" field. It's identical to ResourceIDEQ.
|
||||
func ResourceID(v string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldEQ(FieldResourceID, v))
|
||||
}
|
||||
|
||||
// IPAddress applies equality check predicate on the "ip_address" field. It's identical to IPAddressEQ.
|
||||
func IPAddress(v string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldEQ(FieldIPAddress, v))
|
||||
}
|
||||
|
||||
// UserAgent applies equality check predicate on the "user_agent" field. It's identical to UserAgentEQ.
|
||||
func UserAgent(v string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldEQ(FieldUserAgent, v))
|
||||
}
|
||||
|
||||
// Timestamp applies equality check predicate on the "timestamp" field. It's identical to TimestampEQ.
|
||||
@@ -84,69 +99,69 @@ func Timestamp(v time.Time) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldEQ(FieldTimestamp, v))
|
||||
}
|
||||
|
||||
// ActorIDEQ applies the EQ predicate on the "actor_id" field.
|
||||
func ActorIDEQ(v string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldEQ(FieldActorID, v))
|
||||
// UserIDEQ applies the EQ predicate on the "user_id" field.
|
||||
func UserIDEQ(v string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldEQ(FieldUserID, v))
|
||||
}
|
||||
|
||||
// ActorIDNEQ applies the NEQ predicate on the "actor_id" field.
|
||||
func ActorIDNEQ(v string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldNEQ(FieldActorID, v))
|
||||
// UserIDNEQ applies the NEQ predicate on the "user_id" field.
|
||||
func UserIDNEQ(v string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldNEQ(FieldUserID, v))
|
||||
}
|
||||
|
||||
// ActorIDIn applies the In predicate on the "actor_id" field.
|
||||
func ActorIDIn(vs ...string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldIn(FieldActorID, vs...))
|
||||
// UserIDIn applies the In predicate on the "user_id" field.
|
||||
func UserIDIn(vs ...string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldIn(FieldUserID, vs...))
|
||||
}
|
||||
|
||||
// ActorIDNotIn applies the NotIn predicate on the "actor_id" field.
|
||||
func ActorIDNotIn(vs ...string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldNotIn(FieldActorID, vs...))
|
||||
// UserIDNotIn applies the NotIn predicate on the "user_id" field.
|
||||
func UserIDNotIn(vs ...string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldNotIn(FieldUserID, vs...))
|
||||
}
|
||||
|
||||
// ActorIDGT applies the GT predicate on the "actor_id" field.
|
||||
func ActorIDGT(v string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldGT(FieldActorID, v))
|
||||
// UserIDGT applies the GT predicate on the "user_id" field.
|
||||
func UserIDGT(v string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldGT(FieldUserID, v))
|
||||
}
|
||||
|
||||
// ActorIDGTE applies the GTE predicate on the "actor_id" field.
|
||||
func ActorIDGTE(v string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldGTE(FieldActorID, v))
|
||||
// UserIDGTE applies the GTE predicate on the "user_id" field.
|
||||
func UserIDGTE(v string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldGTE(FieldUserID, v))
|
||||
}
|
||||
|
||||
// ActorIDLT applies the LT predicate on the "actor_id" field.
|
||||
func ActorIDLT(v string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldLT(FieldActorID, v))
|
||||
// UserIDLT applies the LT predicate on the "user_id" field.
|
||||
func UserIDLT(v string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldLT(FieldUserID, v))
|
||||
}
|
||||
|
||||
// ActorIDLTE applies the LTE predicate on the "actor_id" field.
|
||||
func ActorIDLTE(v string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldLTE(FieldActorID, v))
|
||||
// UserIDLTE applies the LTE predicate on the "user_id" field.
|
||||
func UserIDLTE(v string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldLTE(FieldUserID, v))
|
||||
}
|
||||
|
||||
// ActorIDContains applies the Contains predicate on the "actor_id" field.
|
||||
func ActorIDContains(v string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldContains(FieldActorID, v))
|
||||
// UserIDContains applies the Contains predicate on the "user_id" field.
|
||||
func UserIDContains(v string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldContains(FieldUserID, v))
|
||||
}
|
||||
|
||||
// ActorIDHasPrefix applies the HasPrefix predicate on the "actor_id" field.
|
||||
func ActorIDHasPrefix(v string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldHasPrefix(FieldActorID, v))
|
||||
// UserIDHasPrefix applies the HasPrefix predicate on the "user_id" field.
|
||||
func UserIDHasPrefix(v string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldHasPrefix(FieldUserID, v))
|
||||
}
|
||||
|
||||
// ActorIDHasSuffix applies the HasSuffix predicate on the "actor_id" field.
|
||||
func ActorIDHasSuffix(v string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldHasSuffix(FieldActorID, v))
|
||||
// UserIDHasSuffix applies the HasSuffix predicate on the "user_id" field.
|
||||
func UserIDHasSuffix(v string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldHasSuffix(FieldUserID, v))
|
||||
}
|
||||
|
||||
// ActorIDEqualFold applies the EqualFold predicate on the "actor_id" field.
|
||||
func ActorIDEqualFold(v string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldEqualFold(FieldActorID, v))
|
||||
// UserIDEqualFold applies the EqualFold predicate on the "user_id" field.
|
||||
func UserIDEqualFold(v string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldEqualFold(FieldUserID, v))
|
||||
}
|
||||
|
||||
// ActorIDContainsFold applies the ContainsFold predicate on the "actor_id" field.
|
||||
func ActorIDContainsFold(v string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldContainsFold(FieldActorID, v))
|
||||
// UserIDContainsFold applies the ContainsFold predicate on the "user_id" field.
|
||||
func UserIDContainsFold(v string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldContainsFold(FieldUserID, v))
|
||||
}
|
||||
|
||||
// ActionEQ applies the EQ predicate on the "action" field.
|
||||
@@ -214,79 +229,304 @@ func ActionContainsFold(v string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldContainsFold(FieldAction, v))
|
||||
}
|
||||
|
||||
// TargetIDEQ applies the EQ predicate on the "target_id" field.
|
||||
func TargetIDEQ(v string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldEQ(FieldTargetID, v))
|
||||
// ResourceEQ applies the EQ predicate on the "resource" field.
|
||||
func ResourceEQ(v string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldEQ(FieldResource, v))
|
||||
}
|
||||
|
||||
// TargetIDNEQ applies the NEQ predicate on the "target_id" field.
|
||||
func TargetIDNEQ(v string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldNEQ(FieldTargetID, v))
|
||||
// ResourceNEQ applies the NEQ predicate on the "resource" field.
|
||||
func ResourceNEQ(v string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldNEQ(FieldResource, v))
|
||||
}
|
||||
|
||||
// TargetIDIn applies the In predicate on the "target_id" field.
|
||||
func TargetIDIn(vs ...string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldIn(FieldTargetID, vs...))
|
||||
// ResourceIn applies the In predicate on the "resource" field.
|
||||
func ResourceIn(vs ...string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldIn(FieldResource, vs...))
|
||||
}
|
||||
|
||||
// TargetIDNotIn applies the NotIn predicate on the "target_id" field.
|
||||
func TargetIDNotIn(vs ...string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldNotIn(FieldTargetID, vs...))
|
||||
// ResourceNotIn applies the NotIn predicate on the "resource" field.
|
||||
func ResourceNotIn(vs ...string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldNotIn(FieldResource, vs...))
|
||||
}
|
||||
|
||||
// TargetIDGT applies the GT predicate on the "target_id" field.
|
||||
func TargetIDGT(v string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldGT(FieldTargetID, v))
|
||||
// ResourceGT applies the GT predicate on the "resource" field.
|
||||
func ResourceGT(v string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldGT(FieldResource, v))
|
||||
}
|
||||
|
||||
// TargetIDGTE applies the GTE predicate on the "target_id" field.
|
||||
func TargetIDGTE(v string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldGTE(FieldTargetID, v))
|
||||
// ResourceGTE applies the GTE predicate on the "resource" field.
|
||||
func ResourceGTE(v string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldGTE(FieldResource, v))
|
||||
}
|
||||
|
||||
// TargetIDLT applies the LT predicate on the "target_id" field.
|
||||
func TargetIDLT(v string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldLT(FieldTargetID, v))
|
||||
// ResourceLT applies the LT predicate on the "resource" field.
|
||||
func ResourceLT(v string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldLT(FieldResource, v))
|
||||
}
|
||||
|
||||
// TargetIDLTE applies the LTE predicate on the "target_id" field.
|
||||
func TargetIDLTE(v string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldLTE(FieldTargetID, v))
|
||||
// ResourceLTE applies the LTE predicate on the "resource" field.
|
||||
func ResourceLTE(v string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldLTE(FieldResource, v))
|
||||
}
|
||||
|
||||
// TargetIDContains applies the Contains predicate on the "target_id" field.
|
||||
func TargetIDContains(v string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldContains(FieldTargetID, v))
|
||||
// ResourceContains applies the Contains predicate on the "resource" field.
|
||||
func ResourceContains(v string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldContains(FieldResource, v))
|
||||
}
|
||||
|
||||
// TargetIDHasPrefix applies the HasPrefix predicate on the "target_id" field.
|
||||
func TargetIDHasPrefix(v string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldHasPrefix(FieldTargetID, v))
|
||||
// ResourceHasPrefix applies the HasPrefix predicate on the "resource" field.
|
||||
func ResourceHasPrefix(v string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldHasPrefix(FieldResource, v))
|
||||
}
|
||||
|
||||
// TargetIDHasSuffix applies the HasSuffix predicate on the "target_id" field.
|
||||
func TargetIDHasSuffix(v string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldHasSuffix(FieldTargetID, v))
|
||||
// ResourceHasSuffix applies the HasSuffix predicate on the "resource" field.
|
||||
func ResourceHasSuffix(v string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldHasSuffix(FieldResource, v))
|
||||
}
|
||||
|
||||
// TargetIDIsNil applies the IsNil predicate on the "target_id" field.
|
||||
func TargetIDIsNil() predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldIsNull(FieldTargetID))
|
||||
// ResourceIsNil applies the IsNil predicate on the "resource" field.
|
||||
func ResourceIsNil() predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldIsNull(FieldResource))
|
||||
}
|
||||
|
||||
// TargetIDNotNil applies the NotNil predicate on the "target_id" field.
|
||||
func TargetIDNotNil() predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldNotNull(FieldTargetID))
|
||||
// ResourceNotNil applies the NotNil predicate on the "resource" field.
|
||||
func ResourceNotNil() predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldNotNull(FieldResource))
|
||||
}
|
||||
|
||||
// TargetIDEqualFold applies the EqualFold predicate on the "target_id" field.
|
||||
func TargetIDEqualFold(v string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldEqualFold(FieldTargetID, v))
|
||||
// ResourceEqualFold applies the EqualFold predicate on the "resource" field.
|
||||
func ResourceEqualFold(v string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldEqualFold(FieldResource, v))
|
||||
}
|
||||
|
||||
// TargetIDContainsFold applies the ContainsFold predicate on the "target_id" field.
|
||||
func TargetIDContainsFold(v string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldContainsFold(FieldTargetID, v))
|
||||
// ResourceContainsFold applies the ContainsFold predicate on the "resource" field.
|
||||
func ResourceContainsFold(v string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldContainsFold(FieldResource, v))
|
||||
}
|
||||
|
||||
// ResourceIDEQ applies the EQ predicate on the "resource_id" field.
|
||||
func ResourceIDEQ(v string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldEQ(FieldResourceID, v))
|
||||
}
|
||||
|
||||
// ResourceIDNEQ applies the NEQ predicate on the "resource_id" field.
|
||||
func ResourceIDNEQ(v string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldNEQ(FieldResourceID, v))
|
||||
}
|
||||
|
||||
// ResourceIDIn applies the In predicate on the "resource_id" field.
|
||||
func ResourceIDIn(vs ...string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldIn(FieldResourceID, vs...))
|
||||
}
|
||||
|
||||
// ResourceIDNotIn applies the NotIn predicate on the "resource_id" field.
|
||||
func ResourceIDNotIn(vs ...string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldNotIn(FieldResourceID, vs...))
|
||||
}
|
||||
|
||||
// ResourceIDGT applies the GT predicate on the "resource_id" field.
|
||||
func ResourceIDGT(v string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldGT(FieldResourceID, v))
|
||||
}
|
||||
|
||||
// ResourceIDGTE applies the GTE predicate on the "resource_id" field.
|
||||
func ResourceIDGTE(v string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldGTE(FieldResourceID, v))
|
||||
}
|
||||
|
||||
// ResourceIDLT applies the LT predicate on the "resource_id" field.
|
||||
func ResourceIDLT(v string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldLT(FieldResourceID, v))
|
||||
}
|
||||
|
||||
// ResourceIDLTE applies the LTE predicate on the "resource_id" field.
|
||||
func ResourceIDLTE(v string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldLTE(FieldResourceID, v))
|
||||
}
|
||||
|
||||
// ResourceIDContains applies the Contains predicate on the "resource_id" field.
|
||||
func ResourceIDContains(v string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldContains(FieldResourceID, v))
|
||||
}
|
||||
|
||||
// ResourceIDHasPrefix applies the HasPrefix predicate on the "resource_id" field.
|
||||
func ResourceIDHasPrefix(v string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldHasPrefix(FieldResourceID, v))
|
||||
}
|
||||
|
||||
// ResourceIDHasSuffix applies the HasSuffix predicate on the "resource_id" field.
|
||||
func ResourceIDHasSuffix(v string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldHasSuffix(FieldResourceID, v))
|
||||
}
|
||||
|
||||
// ResourceIDIsNil applies the IsNil predicate on the "resource_id" field.
|
||||
func ResourceIDIsNil() predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldIsNull(FieldResourceID))
|
||||
}
|
||||
|
||||
// ResourceIDNotNil applies the NotNil predicate on the "resource_id" field.
|
||||
func ResourceIDNotNil() predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldNotNull(FieldResourceID))
|
||||
}
|
||||
|
||||
// ResourceIDEqualFold applies the EqualFold predicate on the "resource_id" field.
|
||||
func ResourceIDEqualFold(v string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldEqualFold(FieldResourceID, v))
|
||||
}
|
||||
|
||||
// ResourceIDContainsFold applies the ContainsFold predicate on the "resource_id" field.
|
||||
func ResourceIDContainsFold(v string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldContainsFold(FieldResourceID, v))
|
||||
}
|
||||
|
||||
// IPAddressEQ applies the EQ predicate on the "ip_address" field.
|
||||
func IPAddressEQ(v string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldEQ(FieldIPAddress, v))
|
||||
}
|
||||
|
||||
// IPAddressNEQ applies the NEQ predicate on the "ip_address" field.
|
||||
func IPAddressNEQ(v string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldNEQ(FieldIPAddress, v))
|
||||
}
|
||||
|
||||
// IPAddressIn applies the In predicate on the "ip_address" field.
|
||||
func IPAddressIn(vs ...string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldIn(FieldIPAddress, vs...))
|
||||
}
|
||||
|
||||
// IPAddressNotIn applies the NotIn predicate on the "ip_address" field.
|
||||
func IPAddressNotIn(vs ...string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldNotIn(FieldIPAddress, vs...))
|
||||
}
|
||||
|
||||
// IPAddressGT applies the GT predicate on the "ip_address" field.
|
||||
func IPAddressGT(v string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldGT(FieldIPAddress, v))
|
||||
}
|
||||
|
||||
// IPAddressGTE applies the GTE predicate on the "ip_address" field.
|
||||
func IPAddressGTE(v string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldGTE(FieldIPAddress, v))
|
||||
}
|
||||
|
||||
// IPAddressLT applies the LT predicate on the "ip_address" field.
|
||||
func IPAddressLT(v string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldLT(FieldIPAddress, v))
|
||||
}
|
||||
|
||||
// IPAddressLTE applies the LTE predicate on the "ip_address" field.
|
||||
func IPAddressLTE(v string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldLTE(FieldIPAddress, v))
|
||||
}
|
||||
|
||||
// IPAddressContains applies the Contains predicate on the "ip_address" field.
|
||||
func IPAddressContains(v string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldContains(FieldIPAddress, v))
|
||||
}
|
||||
|
||||
// IPAddressHasPrefix applies the HasPrefix predicate on the "ip_address" field.
|
||||
func IPAddressHasPrefix(v string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldHasPrefix(FieldIPAddress, v))
|
||||
}
|
||||
|
||||
// IPAddressHasSuffix applies the HasSuffix predicate on the "ip_address" field.
|
||||
func IPAddressHasSuffix(v string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldHasSuffix(FieldIPAddress, v))
|
||||
}
|
||||
|
||||
// IPAddressIsNil applies the IsNil predicate on the "ip_address" field.
|
||||
func IPAddressIsNil() predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldIsNull(FieldIPAddress))
|
||||
}
|
||||
|
||||
// IPAddressNotNil applies the NotNil predicate on the "ip_address" field.
|
||||
func IPAddressNotNil() predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldNotNull(FieldIPAddress))
|
||||
}
|
||||
|
||||
// IPAddressEqualFold applies the EqualFold predicate on the "ip_address" field.
|
||||
func IPAddressEqualFold(v string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldEqualFold(FieldIPAddress, v))
|
||||
}
|
||||
|
||||
// IPAddressContainsFold applies the ContainsFold predicate on the "ip_address" field.
|
||||
func IPAddressContainsFold(v string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldContainsFold(FieldIPAddress, v))
|
||||
}
|
||||
|
||||
// UserAgentEQ applies the EQ predicate on the "user_agent" field.
|
||||
func UserAgentEQ(v string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldEQ(FieldUserAgent, v))
|
||||
}
|
||||
|
||||
// UserAgentNEQ applies the NEQ predicate on the "user_agent" field.
|
||||
func UserAgentNEQ(v string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldNEQ(FieldUserAgent, v))
|
||||
}
|
||||
|
||||
// UserAgentIn applies the In predicate on the "user_agent" field.
|
||||
func UserAgentIn(vs ...string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldIn(FieldUserAgent, vs...))
|
||||
}
|
||||
|
||||
// UserAgentNotIn applies the NotIn predicate on the "user_agent" field.
|
||||
func UserAgentNotIn(vs ...string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldNotIn(FieldUserAgent, vs...))
|
||||
}
|
||||
|
||||
// UserAgentGT applies the GT predicate on the "user_agent" field.
|
||||
func UserAgentGT(v string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldGT(FieldUserAgent, v))
|
||||
}
|
||||
|
||||
// UserAgentGTE applies the GTE predicate on the "user_agent" field.
|
||||
func UserAgentGTE(v string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldGTE(FieldUserAgent, v))
|
||||
}
|
||||
|
||||
// UserAgentLT applies the LT predicate on the "user_agent" field.
|
||||
func UserAgentLT(v string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldLT(FieldUserAgent, v))
|
||||
}
|
||||
|
||||
// UserAgentLTE applies the LTE predicate on the "user_agent" field.
|
||||
func UserAgentLTE(v string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldLTE(FieldUserAgent, v))
|
||||
}
|
||||
|
||||
// UserAgentContains applies the Contains predicate on the "user_agent" field.
|
||||
func UserAgentContains(v string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldContains(FieldUserAgent, v))
|
||||
}
|
||||
|
||||
// UserAgentHasPrefix applies the HasPrefix predicate on the "user_agent" field.
|
||||
func UserAgentHasPrefix(v string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldHasPrefix(FieldUserAgent, v))
|
||||
}
|
||||
|
||||
// UserAgentHasSuffix applies the HasSuffix predicate on the "user_agent" field.
|
||||
func UserAgentHasSuffix(v string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldHasSuffix(FieldUserAgent, v))
|
||||
}
|
||||
|
||||
// UserAgentIsNil applies the IsNil predicate on the "user_agent" field.
|
||||
func UserAgentIsNil() predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldIsNull(FieldUserAgent))
|
||||
}
|
||||
|
||||
// UserAgentNotNil applies the NotNil predicate on the "user_agent" field.
|
||||
func UserAgentNotNil() predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldNotNull(FieldUserAgent))
|
||||
}
|
||||
|
||||
// UserAgentEqualFold applies the EqualFold predicate on the "user_agent" field.
|
||||
func UserAgentEqualFold(v string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldEqualFold(FieldUserAgent, v))
|
||||
}
|
||||
|
||||
// UserAgentContainsFold applies the ContainsFold predicate on the "user_agent" field.
|
||||
func UserAgentContainsFold(v string) predicate.AuditLog {
|
||||
return predicate.AuditLog(sql.FieldContainsFold(FieldUserAgent, v))
|
||||
}
|
||||
|
||||
// MetadataIsNil applies the IsNil predicate on the "metadata" field.
|
||||
|
||||
@@ -20,9 +20,9 @@ type AuditLogCreate struct {
|
||||
hooks []Hook
|
||||
}
|
||||
|
||||
// SetActorID sets the "actor_id" field.
|
||||
func (_c *AuditLogCreate) SetActorID(v string) *AuditLogCreate {
|
||||
_c.mutation.SetActorID(v)
|
||||
// SetUserID sets the "user_id" field.
|
||||
func (_c *AuditLogCreate) SetUserID(v string) *AuditLogCreate {
|
||||
_c.mutation.SetUserID(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
@@ -32,16 +32,58 @@ func (_c *AuditLogCreate) SetAction(v string) *AuditLogCreate {
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetTargetID sets the "target_id" field.
|
||||
func (_c *AuditLogCreate) SetTargetID(v string) *AuditLogCreate {
|
||||
_c.mutation.SetTargetID(v)
|
||||
// SetResource sets the "resource" field.
|
||||
func (_c *AuditLogCreate) SetResource(v string) *AuditLogCreate {
|
||||
_c.mutation.SetResource(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableTargetID sets the "target_id" field if the given value is not nil.
|
||||
func (_c *AuditLogCreate) SetNillableTargetID(v *string) *AuditLogCreate {
|
||||
// SetNillableResource sets the "resource" field if the given value is not nil.
|
||||
func (_c *AuditLogCreate) SetNillableResource(v *string) *AuditLogCreate {
|
||||
if v != nil {
|
||||
_c.SetTargetID(*v)
|
||||
_c.SetResource(*v)
|
||||
}
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetResourceID sets the "resource_id" field.
|
||||
func (_c *AuditLogCreate) SetResourceID(v string) *AuditLogCreate {
|
||||
_c.mutation.SetResourceID(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableResourceID sets the "resource_id" field if the given value is not nil.
|
||||
func (_c *AuditLogCreate) SetNillableResourceID(v *string) *AuditLogCreate {
|
||||
if v != nil {
|
||||
_c.SetResourceID(*v)
|
||||
}
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetIPAddress sets the "ip_address" field.
|
||||
func (_c *AuditLogCreate) SetIPAddress(v string) *AuditLogCreate {
|
||||
_c.mutation.SetIPAddress(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableIPAddress sets the "ip_address" field if the given value is not nil.
|
||||
func (_c *AuditLogCreate) SetNillableIPAddress(v *string) *AuditLogCreate {
|
||||
if v != nil {
|
||||
_c.SetIPAddress(*v)
|
||||
}
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetUserAgent sets the "user_agent" field.
|
||||
func (_c *AuditLogCreate) SetUserAgent(v string) *AuditLogCreate {
|
||||
_c.mutation.SetUserAgent(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableUserAgent sets the "user_agent" field if the given value is not nil.
|
||||
func (_c *AuditLogCreate) SetNillableUserAgent(v *string) *AuditLogCreate {
|
||||
if v != nil {
|
||||
_c.SetUserAgent(*v)
|
||||
}
|
||||
return _c
|
||||
}
|
||||
@@ -115,12 +157,12 @@ func (_c *AuditLogCreate) defaults() {
|
||||
|
||||
// check runs all checks and user-defined validators on the builder.
|
||||
func (_c *AuditLogCreate) check() error {
|
||||
if _, ok := _c.mutation.ActorID(); !ok {
|
||||
return &ValidationError{Name: "actor_id", err: errors.New(`ent: missing required field "AuditLog.actor_id"`)}
|
||||
if _, ok := _c.mutation.UserID(); !ok {
|
||||
return &ValidationError{Name: "user_id", err: errors.New(`ent: missing required field "AuditLog.user_id"`)}
|
||||
}
|
||||
if v, ok := _c.mutation.ActorID(); ok {
|
||||
if err := auditlog.ActorIDValidator(v); err != nil {
|
||||
return &ValidationError{Name: "actor_id", err: fmt.Errorf(`ent: validator failed for field "AuditLog.actor_id": %w`, err)}
|
||||
if v, ok := _c.mutation.UserID(); ok {
|
||||
if err := auditlog.UserIDValidator(v); err != nil {
|
||||
return &ValidationError{Name: "user_id", err: fmt.Errorf(`ent: validator failed for field "AuditLog.user_id": %w`, err)}
|
||||
}
|
||||
}
|
||||
if _, ok := _c.mutation.Action(); !ok {
|
||||
@@ -169,17 +211,29 @@ func (_c *AuditLogCreate) createSpec() (*AuditLog, *sqlgraph.CreateSpec) {
|
||||
_node.ID = id
|
||||
_spec.ID.Value = id
|
||||
}
|
||||
if value, ok := _c.mutation.ActorID(); ok {
|
||||
_spec.SetField(auditlog.FieldActorID, field.TypeString, value)
|
||||
_node.ActorID = value
|
||||
if value, ok := _c.mutation.UserID(); ok {
|
||||
_spec.SetField(auditlog.FieldUserID, field.TypeString, value)
|
||||
_node.UserID = value
|
||||
}
|
||||
if value, ok := _c.mutation.Action(); ok {
|
||||
_spec.SetField(auditlog.FieldAction, field.TypeString, value)
|
||||
_node.Action = value
|
||||
}
|
||||
if value, ok := _c.mutation.TargetID(); ok {
|
||||
_spec.SetField(auditlog.FieldTargetID, field.TypeString, value)
|
||||
_node.TargetID = value
|
||||
if value, ok := _c.mutation.Resource(); ok {
|
||||
_spec.SetField(auditlog.FieldResource, field.TypeString, value)
|
||||
_node.Resource = value
|
||||
}
|
||||
if value, ok := _c.mutation.ResourceID(); ok {
|
||||
_spec.SetField(auditlog.FieldResourceID, field.TypeString, value)
|
||||
_node.ResourceID = value
|
||||
}
|
||||
if value, ok := _c.mutation.IPAddress(); ok {
|
||||
_spec.SetField(auditlog.FieldIPAddress, field.TypeString, value)
|
||||
_node.IPAddress = value
|
||||
}
|
||||
if value, ok := _c.mutation.UserAgent(); ok {
|
||||
_spec.SetField(auditlog.FieldUserAgent, field.TypeString, value)
|
||||
_node.UserAgent = value
|
||||
}
|
||||
if value, ok := _c.mutation.Metadata(); ok {
|
||||
_spec.SetField(auditlog.FieldMetadata, field.TypeJSON, value)
|
||||
|
||||
@@ -262,12 +262,12 @@ func (_q *AuditLogQuery) Clone() *AuditLogQuery {
|
||||
// Example:
|
||||
//
|
||||
// var v []struct {
|
||||
// ActorID string `json:"actor_id,omitempty"`
|
||||
// UserID string `json:"user_id,omitempty"`
|
||||
// Count int `json:"count,omitempty"`
|
||||
// }
|
||||
//
|
||||
// client.AuditLog.Query().
|
||||
// GroupBy(auditlog.FieldActorID).
|
||||
// GroupBy(auditlog.FieldUserID).
|
||||
// Aggregate(ent.Count()).
|
||||
// Scan(ctx, &v)
|
||||
func (_q *AuditLogQuery) GroupBy(field string, fields ...string) *AuditLogGroupBy {
|
||||
@@ -285,11 +285,11 @@ func (_q *AuditLogQuery) GroupBy(field string, fields ...string) *AuditLogGroupB
|
||||
// Example:
|
||||
//
|
||||
// var v []struct {
|
||||
// ActorID string `json:"actor_id,omitempty"`
|
||||
// UserID string `json:"user_id,omitempty"`
|
||||
// }
|
||||
//
|
||||
// client.AuditLog.Query().
|
||||
// Select(auditlog.FieldActorID).
|
||||
// Select(auditlog.FieldUserID).
|
||||
// Scan(ctx, &v)
|
||||
func (_q *AuditLogQuery) Select(fields ...string) *AuditLogSelect {
|
||||
_q.ctx.Fields = append(_q.ctx.Fields, fields...)
|
||||
|
||||
@@ -27,16 +27,16 @@ func (_u *AuditLogUpdate) Where(ps ...predicate.AuditLog) *AuditLogUpdate {
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetActorID sets the "actor_id" field.
|
||||
func (_u *AuditLogUpdate) SetActorID(v string) *AuditLogUpdate {
|
||||
_u.mutation.SetActorID(v)
|
||||
// SetUserID sets the "user_id" field.
|
||||
func (_u *AuditLogUpdate) SetUserID(v string) *AuditLogUpdate {
|
||||
_u.mutation.SetUserID(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableActorID sets the "actor_id" field if the given value is not nil.
|
||||
func (_u *AuditLogUpdate) SetNillableActorID(v *string) *AuditLogUpdate {
|
||||
// SetNillableUserID sets the "user_id" field if the given value is not nil.
|
||||
func (_u *AuditLogUpdate) SetNillableUserID(v *string) *AuditLogUpdate {
|
||||
if v != nil {
|
||||
_u.SetActorID(*v)
|
||||
_u.SetUserID(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
@@ -55,23 +55,83 @@ func (_u *AuditLogUpdate) SetNillableAction(v *string) *AuditLogUpdate {
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetTargetID sets the "target_id" field.
|
||||
func (_u *AuditLogUpdate) SetTargetID(v string) *AuditLogUpdate {
|
||||
_u.mutation.SetTargetID(v)
|
||||
// SetResource sets the "resource" field.
|
||||
func (_u *AuditLogUpdate) SetResource(v string) *AuditLogUpdate {
|
||||
_u.mutation.SetResource(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableTargetID sets the "target_id" field if the given value is not nil.
|
||||
func (_u *AuditLogUpdate) SetNillableTargetID(v *string) *AuditLogUpdate {
|
||||
// SetNillableResource sets the "resource" field if the given value is not nil.
|
||||
func (_u *AuditLogUpdate) SetNillableResource(v *string) *AuditLogUpdate {
|
||||
if v != nil {
|
||||
_u.SetTargetID(*v)
|
||||
_u.SetResource(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// ClearTargetID clears the value of the "target_id" field.
|
||||
func (_u *AuditLogUpdate) ClearTargetID() *AuditLogUpdate {
|
||||
_u.mutation.ClearTargetID()
|
||||
// ClearResource clears the value of the "resource" field.
|
||||
func (_u *AuditLogUpdate) ClearResource() *AuditLogUpdate {
|
||||
_u.mutation.ClearResource()
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetResourceID sets the "resource_id" field.
|
||||
func (_u *AuditLogUpdate) SetResourceID(v string) *AuditLogUpdate {
|
||||
_u.mutation.SetResourceID(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableResourceID sets the "resource_id" field if the given value is not nil.
|
||||
func (_u *AuditLogUpdate) SetNillableResourceID(v *string) *AuditLogUpdate {
|
||||
if v != nil {
|
||||
_u.SetResourceID(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// ClearResourceID clears the value of the "resource_id" field.
|
||||
func (_u *AuditLogUpdate) ClearResourceID() *AuditLogUpdate {
|
||||
_u.mutation.ClearResourceID()
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetIPAddress sets the "ip_address" field.
|
||||
func (_u *AuditLogUpdate) SetIPAddress(v string) *AuditLogUpdate {
|
||||
_u.mutation.SetIPAddress(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableIPAddress sets the "ip_address" field if the given value is not nil.
|
||||
func (_u *AuditLogUpdate) SetNillableIPAddress(v *string) *AuditLogUpdate {
|
||||
if v != nil {
|
||||
_u.SetIPAddress(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// ClearIPAddress clears the value of the "ip_address" field.
|
||||
func (_u *AuditLogUpdate) ClearIPAddress() *AuditLogUpdate {
|
||||
_u.mutation.ClearIPAddress()
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetUserAgent sets the "user_agent" field.
|
||||
func (_u *AuditLogUpdate) SetUserAgent(v string) *AuditLogUpdate {
|
||||
_u.mutation.SetUserAgent(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableUserAgent sets the "user_agent" field if the given value is not nil.
|
||||
func (_u *AuditLogUpdate) SetNillableUserAgent(v *string) *AuditLogUpdate {
|
||||
if v != nil {
|
||||
_u.SetUserAgent(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// ClearUserAgent clears the value of the "user_agent" field.
|
||||
func (_u *AuditLogUpdate) ClearUserAgent() *AuditLogUpdate {
|
||||
_u.mutation.ClearUserAgent()
|
||||
return _u
|
||||
}
|
||||
|
||||
@@ -121,9 +181,9 @@ func (_u *AuditLogUpdate) ExecX(ctx context.Context) {
|
||||
|
||||
// check runs all checks and user-defined validators on the builder.
|
||||
func (_u *AuditLogUpdate) check() error {
|
||||
if v, ok := _u.mutation.ActorID(); ok {
|
||||
if err := auditlog.ActorIDValidator(v); err != nil {
|
||||
return &ValidationError{Name: "actor_id", err: fmt.Errorf(`ent: validator failed for field "AuditLog.actor_id": %w`, err)}
|
||||
if v, ok := _u.mutation.UserID(); ok {
|
||||
if err := auditlog.UserIDValidator(v); err != nil {
|
||||
return &ValidationError{Name: "user_id", err: fmt.Errorf(`ent: validator failed for field "AuditLog.user_id": %w`, err)}
|
||||
}
|
||||
}
|
||||
if v, ok := _u.mutation.Action(); ok {
|
||||
@@ -146,17 +206,35 @@ func (_u *AuditLogUpdate) sqlSave(ctx context.Context) (_node int, err error) {
|
||||
}
|
||||
}
|
||||
}
|
||||
if value, ok := _u.mutation.ActorID(); ok {
|
||||
_spec.SetField(auditlog.FieldActorID, field.TypeString, value)
|
||||
if value, ok := _u.mutation.UserID(); ok {
|
||||
_spec.SetField(auditlog.FieldUserID, field.TypeString, value)
|
||||
}
|
||||
if value, ok := _u.mutation.Action(); ok {
|
||||
_spec.SetField(auditlog.FieldAction, field.TypeString, value)
|
||||
}
|
||||
if value, ok := _u.mutation.TargetID(); ok {
|
||||
_spec.SetField(auditlog.FieldTargetID, field.TypeString, value)
|
||||
if value, ok := _u.mutation.Resource(); ok {
|
||||
_spec.SetField(auditlog.FieldResource, field.TypeString, value)
|
||||
}
|
||||
if _u.mutation.TargetIDCleared() {
|
||||
_spec.ClearField(auditlog.FieldTargetID, field.TypeString)
|
||||
if _u.mutation.ResourceCleared() {
|
||||
_spec.ClearField(auditlog.FieldResource, field.TypeString)
|
||||
}
|
||||
if value, ok := _u.mutation.ResourceID(); ok {
|
||||
_spec.SetField(auditlog.FieldResourceID, field.TypeString, value)
|
||||
}
|
||||
if _u.mutation.ResourceIDCleared() {
|
||||
_spec.ClearField(auditlog.FieldResourceID, field.TypeString)
|
||||
}
|
||||
if value, ok := _u.mutation.IPAddress(); ok {
|
||||
_spec.SetField(auditlog.FieldIPAddress, field.TypeString, value)
|
||||
}
|
||||
if _u.mutation.IPAddressCleared() {
|
||||
_spec.ClearField(auditlog.FieldIPAddress, field.TypeString)
|
||||
}
|
||||
if value, ok := _u.mutation.UserAgent(); ok {
|
||||
_spec.SetField(auditlog.FieldUserAgent, field.TypeString, value)
|
||||
}
|
||||
if _u.mutation.UserAgentCleared() {
|
||||
_spec.ClearField(auditlog.FieldUserAgent, field.TypeString)
|
||||
}
|
||||
if value, ok := _u.mutation.Metadata(); ok {
|
||||
_spec.SetField(auditlog.FieldMetadata, field.TypeJSON, value)
|
||||
@@ -184,16 +262,16 @@ type AuditLogUpdateOne struct {
|
||||
mutation *AuditLogMutation
|
||||
}
|
||||
|
||||
// SetActorID sets the "actor_id" field.
|
||||
func (_u *AuditLogUpdateOne) SetActorID(v string) *AuditLogUpdateOne {
|
||||
_u.mutation.SetActorID(v)
|
||||
// SetUserID sets the "user_id" field.
|
||||
func (_u *AuditLogUpdateOne) SetUserID(v string) *AuditLogUpdateOne {
|
||||
_u.mutation.SetUserID(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableActorID sets the "actor_id" field if the given value is not nil.
|
||||
func (_u *AuditLogUpdateOne) SetNillableActorID(v *string) *AuditLogUpdateOne {
|
||||
// SetNillableUserID sets the "user_id" field if the given value is not nil.
|
||||
func (_u *AuditLogUpdateOne) SetNillableUserID(v *string) *AuditLogUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetActorID(*v)
|
||||
_u.SetUserID(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
@@ -212,23 +290,83 @@ func (_u *AuditLogUpdateOne) SetNillableAction(v *string) *AuditLogUpdateOne {
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetTargetID sets the "target_id" field.
|
||||
func (_u *AuditLogUpdateOne) SetTargetID(v string) *AuditLogUpdateOne {
|
||||
_u.mutation.SetTargetID(v)
|
||||
// SetResource sets the "resource" field.
|
||||
func (_u *AuditLogUpdateOne) SetResource(v string) *AuditLogUpdateOne {
|
||||
_u.mutation.SetResource(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableTargetID sets the "target_id" field if the given value is not nil.
|
||||
func (_u *AuditLogUpdateOne) SetNillableTargetID(v *string) *AuditLogUpdateOne {
|
||||
// SetNillableResource sets the "resource" field if the given value is not nil.
|
||||
func (_u *AuditLogUpdateOne) SetNillableResource(v *string) *AuditLogUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetTargetID(*v)
|
||||
_u.SetResource(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// ClearTargetID clears the value of the "target_id" field.
|
||||
func (_u *AuditLogUpdateOne) ClearTargetID() *AuditLogUpdateOne {
|
||||
_u.mutation.ClearTargetID()
|
||||
// ClearResource clears the value of the "resource" field.
|
||||
func (_u *AuditLogUpdateOne) ClearResource() *AuditLogUpdateOne {
|
||||
_u.mutation.ClearResource()
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetResourceID sets the "resource_id" field.
|
||||
func (_u *AuditLogUpdateOne) SetResourceID(v string) *AuditLogUpdateOne {
|
||||
_u.mutation.SetResourceID(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableResourceID sets the "resource_id" field if the given value is not nil.
|
||||
func (_u *AuditLogUpdateOne) SetNillableResourceID(v *string) *AuditLogUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetResourceID(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// ClearResourceID clears the value of the "resource_id" field.
|
||||
func (_u *AuditLogUpdateOne) ClearResourceID() *AuditLogUpdateOne {
|
||||
_u.mutation.ClearResourceID()
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetIPAddress sets the "ip_address" field.
|
||||
func (_u *AuditLogUpdateOne) SetIPAddress(v string) *AuditLogUpdateOne {
|
||||
_u.mutation.SetIPAddress(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableIPAddress sets the "ip_address" field if the given value is not nil.
|
||||
func (_u *AuditLogUpdateOne) SetNillableIPAddress(v *string) *AuditLogUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetIPAddress(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// ClearIPAddress clears the value of the "ip_address" field.
|
||||
func (_u *AuditLogUpdateOne) ClearIPAddress() *AuditLogUpdateOne {
|
||||
_u.mutation.ClearIPAddress()
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetUserAgent sets the "user_agent" field.
|
||||
func (_u *AuditLogUpdateOne) SetUserAgent(v string) *AuditLogUpdateOne {
|
||||
_u.mutation.SetUserAgent(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableUserAgent sets the "user_agent" field if the given value is not nil.
|
||||
func (_u *AuditLogUpdateOne) SetNillableUserAgent(v *string) *AuditLogUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetUserAgent(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// ClearUserAgent clears the value of the "user_agent" field.
|
||||
func (_u *AuditLogUpdateOne) ClearUserAgent() *AuditLogUpdateOne {
|
||||
_u.mutation.ClearUserAgent()
|
||||
return _u
|
||||
}
|
||||
|
||||
@@ -291,9 +429,9 @@ func (_u *AuditLogUpdateOne) ExecX(ctx context.Context) {
|
||||
|
||||
// check runs all checks and user-defined validators on the builder.
|
||||
func (_u *AuditLogUpdateOne) check() error {
|
||||
if v, ok := _u.mutation.ActorID(); ok {
|
||||
if err := auditlog.ActorIDValidator(v); err != nil {
|
||||
return &ValidationError{Name: "actor_id", err: fmt.Errorf(`ent: validator failed for field "AuditLog.actor_id": %w`, err)}
|
||||
if v, ok := _u.mutation.UserID(); ok {
|
||||
if err := auditlog.UserIDValidator(v); err != nil {
|
||||
return &ValidationError{Name: "user_id", err: fmt.Errorf(`ent: validator failed for field "AuditLog.user_id": %w`, err)}
|
||||
}
|
||||
}
|
||||
if v, ok := _u.mutation.Action(); ok {
|
||||
@@ -333,17 +471,35 @@ func (_u *AuditLogUpdateOne) sqlSave(ctx context.Context) (_node *AuditLog, err
|
||||
}
|
||||
}
|
||||
}
|
||||
if value, ok := _u.mutation.ActorID(); ok {
|
||||
_spec.SetField(auditlog.FieldActorID, field.TypeString, value)
|
||||
if value, ok := _u.mutation.UserID(); ok {
|
||||
_spec.SetField(auditlog.FieldUserID, field.TypeString, value)
|
||||
}
|
||||
if value, ok := _u.mutation.Action(); ok {
|
||||
_spec.SetField(auditlog.FieldAction, field.TypeString, value)
|
||||
}
|
||||
if value, ok := _u.mutation.TargetID(); ok {
|
||||
_spec.SetField(auditlog.FieldTargetID, field.TypeString, value)
|
||||
if value, ok := _u.mutation.Resource(); ok {
|
||||
_spec.SetField(auditlog.FieldResource, field.TypeString, value)
|
||||
}
|
||||
if _u.mutation.TargetIDCleared() {
|
||||
_spec.ClearField(auditlog.FieldTargetID, field.TypeString)
|
||||
if _u.mutation.ResourceCleared() {
|
||||
_spec.ClearField(auditlog.FieldResource, field.TypeString)
|
||||
}
|
||||
if value, ok := _u.mutation.ResourceID(); ok {
|
||||
_spec.SetField(auditlog.FieldResourceID, field.TypeString, value)
|
||||
}
|
||||
if _u.mutation.ResourceIDCleared() {
|
||||
_spec.ClearField(auditlog.FieldResourceID, field.TypeString)
|
||||
}
|
||||
if value, ok := _u.mutation.IPAddress(); ok {
|
||||
_spec.SetField(auditlog.FieldIPAddress, field.TypeString, value)
|
||||
}
|
||||
if _u.mutation.IPAddressCleared() {
|
||||
_spec.ClearField(auditlog.FieldIPAddress, field.TypeString)
|
||||
}
|
||||
if value, ok := _u.mutation.UserAgent(); ok {
|
||||
_spec.SetField(auditlog.FieldUserAgent, field.TypeString, value)
|
||||
}
|
||||
if _u.mutation.UserAgentCleared() {
|
||||
_spec.ClearField(auditlog.FieldUserAgent, field.TypeString)
|
||||
}
|
||||
if value, ok := _u.mutation.Metadata(); ok {
|
||||
_spec.SetField(auditlog.FieldMetadata, field.TypeJSON, value)
|
||||
|
||||
@@ -11,9 +11,12 @@ var (
|
||||
// AuditLogsColumns holds the columns for the "audit_logs" table.
|
||||
AuditLogsColumns = []*schema.Column{
|
||||
{Name: "id", Type: field.TypeString, Unique: true},
|
||||
{Name: "actor_id", Type: field.TypeString},
|
||||
{Name: "user_id", Type: field.TypeString},
|
||||
{Name: "action", Type: field.TypeString},
|
||||
{Name: "target_id", Type: field.TypeString, Nullable: true},
|
||||
{Name: "resource", Type: field.TypeString, Nullable: true},
|
||||
{Name: "resource_id", Type: field.TypeString, Nullable: true},
|
||||
{Name: "ip_address", Type: field.TypeString, Nullable: true},
|
||||
{Name: "user_agent", Type: field.TypeString, Nullable: true},
|
||||
{Name: "metadata", Type: field.TypeJSON, Nullable: true},
|
||||
{Name: "timestamp", Type: field.TypeTime},
|
||||
}
|
||||
@@ -24,25 +27,30 @@ var (
|
||||
PrimaryKey: []*schema.Column{AuditLogsColumns[0]},
|
||||
Indexes: []*schema.Index{
|
||||
{
|
||||
Name: "auditlog_actor_id",
|
||||
Name: "auditlog_user_id",
|
||||
Unique: false,
|
||||
Columns: []*schema.Column{AuditLogsColumns[1]},
|
||||
},
|
||||
{
|
||||
Name: "auditlog_target_id",
|
||||
Name: "auditlog_resource_id",
|
||||
Unique: false,
|
||||
Columns: []*schema.Column{AuditLogsColumns[3]},
|
||||
Columns: []*schema.Column{AuditLogsColumns[4]},
|
||||
},
|
||||
{
|
||||
Name: "auditlog_timestamp",
|
||||
Unique: false,
|
||||
Columns: []*schema.Column{AuditLogsColumns[5]},
|
||||
Columns: []*schema.Column{AuditLogsColumns[8]},
|
||||
},
|
||||
{
|
||||
Name: "auditlog_action",
|
||||
Unique: false,
|
||||
Columns: []*schema.Column{AuditLogsColumns[2]},
|
||||
},
|
||||
{
|
||||
Name: "auditlog_resource",
|
||||
Unique: false,
|
||||
Columns: []*schema.Column{AuditLogsColumns[3]},
|
||||
},
|
||||
},
|
||||
}
|
||||
// PermissionsColumns holds the columns for the "permissions" table.
|
||||
@@ -113,8 +121,14 @@ var (
|
||||
UsersColumns = []*schema.Column{
|
||||
{Name: "id", Type: field.TypeString, Unique: true},
|
||||
{Name: "email", Type: field.TypeString, Unique: true},
|
||||
{Name: "username", Type: field.TypeString, Nullable: true},
|
||||
{Name: "first_name", Type: field.TypeString, Nullable: true},
|
||||
{Name: "last_name", Type: field.TypeString, Nullable: true},
|
||||
{Name: "password_hash", Type: field.TypeString},
|
||||
{Name: "verified", Type: field.TypeBool, Default: false},
|
||||
{Name: "email_verification_token", Type: field.TypeString, Nullable: true},
|
||||
{Name: "password_reset_token", Type: field.TypeString, Nullable: true},
|
||||
{Name: "password_reset_expires_at", Type: field.TypeTime, Nullable: true},
|
||||
{Name: "created_at", Type: field.TypeTime},
|
||||
{Name: "updated_at", Type: field.TypeTime},
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -18,16 +18,16 @@ import (
|
||||
func init() {
|
||||
auditlogFields := schema.AuditLog{}.Fields()
|
||||
_ = auditlogFields
|
||||
// auditlogDescActorID is the schema descriptor for actor_id field.
|
||||
auditlogDescActorID := auditlogFields[1].Descriptor()
|
||||
// auditlog.ActorIDValidator is a validator for the "actor_id" field. It is called by the builders before save.
|
||||
auditlog.ActorIDValidator = auditlogDescActorID.Validators[0].(func(string) error)
|
||||
// auditlogDescUserID is the schema descriptor for user_id field.
|
||||
auditlogDescUserID := auditlogFields[1].Descriptor()
|
||||
// auditlog.UserIDValidator is a validator for the "user_id" field. It is called by the builders before save.
|
||||
auditlog.UserIDValidator = auditlogDescUserID.Validators[0].(func(string) error)
|
||||
// auditlogDescAction is the schema descriptor for action field.
|
||||
auditlogDescAction := auditlogFields[2].Descriptor()
|
||||
// auditlog.ActionValidator is a validator for the "action" field. It is called by the builders before save.
|
||||
auditlog.ActionValidator = auditlogDescAction.Validators[0].(func(string) error)
|
||||
// auditlogDescTimestamp is the schema descriptor for timestamp field.
|
||||
auditlogDescTimestamp := auditlogFields[5].Descriptor()
|
||||
auditlogDescTimestamp := auditlogFields[8].Descriptor()
|
||||
// auditlog.DefaultTimestamp holds the default value on creation for the timestamp field.
|
||||
auditlog.DefaultTimestamp = auditlogDescTimestamp.Default.(func() time.Time)
|
||||
permissionFields := schema.Permission{}.Fields()
|
||||
@@ -53,19 +53,19 @@ func init() {
|
||||
// user.EmailValidator is a validator for the "email" field. It is called by the builders before save.
|
||||
user.EmailValidator = userDescEmail.Validators[0].(func(string) error)
|
||||
// userDescPasswordHash is the schema descriptor for password_hash field.
|
||||
userDescPasswordHash := userFields[2].Descriptor()
|
||||
userDescPasswordHash := userFields[5].Descriptor()
|
||||
// user.PasswordHashValidator is a validator for the "password_hash" field. It is called by the builders before save.
|
||||
user.PasswordHashValidator = userDescPasswordHash.Validators[0].(func(string) error)
|
||||
// userDescVerified is the schema descriptor for verified field.
|
||||
userDescVerified := userFields[3].Descriptor()
|
||||
userDescVerified := userFields[6].Descriptor()
|
||||
// user.DefaultVerified holds the default value on creation for the verified field.
|
||||
user.DefaultVerified = userDescVerified.Default.(bool)
|
||||
// userDescCreatedAt is the schema descriptor for created_at field.
|
||||
userDescCreatedAt := userFields[4].Descriptor()
|
||||
userDescCreatedAt := userFields[10].Descriptor()
|
||||
// user.DefaultCreatedAt holds the default value on creation for the created_at field.
|
||||
user.DefaultCreatedAt = userDescCreatedAt.Default.(func() time.Time)
|
||||
// userDescUpdatedAt is the schema descriptor for updated_at field.
|
||||
userDescUpdatedAt := userFields[5].Descriptor()
|
||||
userDescUpdatedAt := userFields[11].Descriptor()
|
||||
// user.DefaultUpdatedAt holds the default value on creation for the updated_at field.
|
||||
user.DefaultUpdatedAt = userDescUpdatedAt.Default.(func() time.Time)
|
||||
// user.UpdateDefaultUpdatedAt holds the default value on update for the updated_at field.
|
||||
|
||||
@@ -20,15 +20,24 @@ func (AuditLog) Fields() []ent.Field {
|
||||
field.String("id").
|
||||
Unique().
|
||||
Immutable(),
|
||||
field.String("actor_id").
|
||||
field.String("user_id").
|
||||
NotEmpty().
|
||||
Comment("ID of the user/actor performing the action"),
|
||||
field.String("action").
|
||||
NotEmpty().
|
||||
Comment("Action performed (e.g., create, update, delete)"),
|
||||
field.String("target_id").
|
||||
Comment("Action performed (e.g., user.create, user.update)"),
|
||||
field.String("resource").
|
||||
Optional().
|
||||
Comment("Resource type (e.g., user, role)"),
|
||||
field.String("resource_id").
|
||||
Optional().
|
||||
Comment("ID of the target resource"),
|
||||
field.String("ip_address").
|
||||
Optional().
|
||||
Comment("IP address of the client"),
|
||||
field.String("user_agent").
|
||||
Optional().
|
||||
Comment("User agent of the client"),
|
||||
field.JSON("metadata", map[string]interface{}{}).
|
||||
Optional().
|
||||
Comment("Additional metadata as JSON"),
|
||||
@@ -41,9 +50,10 @@ func (AuditLog) Fields() []ent.Field {
|
||||
// Indexes of the AuditLog.
|
||||
func (AuditLog) Indexes() []ent.Index {
|
||||
return []ent.Index{
|
||||
index.Fields("actor_id"),
|
||||
index.Fields("target_id"),
|
||||
index.Fields("user_id"),
|
||||
index.Fields("resource_id"),
|
||||
index.Fields("timestamp"),
|
||||
index.Fields("action"),
|
||||
index.Fields("resource"),
|
||||
}
|
||||
}
|
||||
|
||||
44
internal/ent/schema/refresh_token.go
Normal file
44
internal/ent/schema/refresh_token.go
Normal file
@@ -0,0 +1,44 @@
|
||||
package schema
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/schema/field"
|
||||
"entgo.io/ent/schema/index"
|
||||
)
|
||||
|
||||
// RefreshToken holds the schema definition for the RefreshToken entity.
|
||||
type RefreshToken struct {
|
||||
ent.Schema
|
||||
}
|
||||
|
||||
// Fields of the RefreshToken.
|
||||
func (RefreshToken) Fields() []ent.Field {
|
||||
return []ent.Field{
|
||||
field.String("id").
|
||||
Unique().
|
||||
Immutable(),
|
||||
field.String("user_id").
|
||||
NotEmpty().
|
||||
Comment("ID of the user who owns this refresh token"),
|
||||
field.String("token_hash").
|
||||
NotEmpty().
|
||||
Sensitive().
|
||||
Comment("SHA256 hash of the refresh token"),
|
||||
field.Time("expires_at").
|
||||
Comment("When the refresh token expires"),
|
||||
field.Time("created_at").
|
||||
Default(time.Now).
|
||||
Immutable(),
|
||||
}
|
||||
}
|
||||
|
||||
// Indexes of the RefreshToken.
|
||||
func (RefreshToken) Indexes() []ent.Index {
|
||||
return []ent.Index{
|
||||
index.Fields("user_id"),
|
||||
index.Fields("token_hash"),
|
||||
index.Fields("expires_at"),
|
||||
}
|
||||
}
|
||||
@@ -22,10 +22,24 @@ func (User) Fields() []ent.Field {
|
||||
field.String("email").
|
||||
Unique().
|
||||
NotEmpty(),
|
||||
field.String("username").
|
||||
Optional(),
|
||||
field.String("first_name").
|
||||
Optional(),
|
||||
field.String("last_name").
|
||||
Optional(),
|
||||
field.String("password_hash").
|
||||
NotEmpty(),
|
||||
field.Bool("verified").
|
||||
Default(false),
|
||||
field.String("email_verification_token").
|
||||
Optional().
|
||||
Sensitive(),
|
||||
field.String("password_reset_token").
|
||||
Optional().
|
||||
Sensitive(),
|
||||
field.Time("password_reset_expires_at").
|
||||
Optional(),
|
||||
field.Time("created_at").
|
||||
Default(time.Now).
|
||||
Immutable(),
|
||||
|
||||
@@ -19,10 +19,22 @@ type User struct {
|
||||
ID string `json:"id,omitempty"`
|
||||
// Email holds the value of the "email" field.
|
||||
Email string `json:"email,omitempty"`
|
||||
// Username holds the value of the "username" field.
|
||||
Username string `json:"username,omitempty"`
|
||||
// FirstName holds the value of the "first_name" field.
|
||||
FirstName string `json:"first_name,omitempty"`
|
||||
// LastName holds the value of the "last_name" field.
|
||||
LastName string `json:"last_name,omitempty"`
|
||||
// PasswordHash holds the value of the "password_hash" field.
|
||||
PasswordHash string `json:"password_hash,omitempty"`
|
||||
// Verified holds the value of the "verified" field.
|
||||
Verified bool `json:"verified,omitempty"`
|
||||
// EmailVerificationToken holds the value of the "email_verification_token" field.
|
||||
EmailVerificationToken string `json:"-"`
|
||||
// PasswordResetToken holds the value of the "password_reset_token" field.
|
||||
PasswordResetToken string `json:"-"`
|
||||
// PasswordResetExpiresAt holds the value of the "password_reset_expires_at" field.
|
||||
PasswordResetExpiresAt time.Time `json:"password_reset_expires_at,omitempty"`
|
||||
// CreatedAt holds the value of the "created_at" field.
|
||||
CreatedAt time.Time `json:"created_at,omitempty"`
|
||||
// UpdatedAt holds the value of the "updated_at" field.
|
||||
@@ -58,9 +70,9 @@ func (*User) scanValues(columns []string) ([]any, error) {
|
||||
switch columns[i] {
|
||||
case user.FieldVerified:
|
||||
values[i] = new(sql.NullBool)
|
||||
case user.FieldID, user.FieldEmail, user.FieldPasswordHash:
|
||||
case user.FieldID, user.FieldEmail, user.FieldUsername, user.FieldFirstName, user.FieldLastName, user.FieldPasswordHash, user.FieldEmailVerificationToken, user.FieldPasswordResetToken:
|
||||
values[i] = new(sql.NullString)
|
||||
case user.FieldCreatedAt, user.FieldUpdatedAt:
|
||||
case user.FieldPasswordResetExpiresAt, user.FieldCreatedAt, user.FieldUpdatedAt:
|
||||
values[i] = new(sql.NullTime)
|
||||
default:
|
||||
values[i] = new(sql.UnknownType)
|
||||
@@ -89,6 +101,24 @@ func (_m *User) assignValues(columns []string, values []any) error {
|
||||
} else if value.Valid {
|
||||
_m.Email = value.String
|
||||
}
|
||||
case user.FieldUsername:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field username", values[i])
|
||||
} else if value.Valid {
|
||||
_m.Username = value.String
|
||||
}
|
||||
case user.FieldFirstName:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field first_name", values[i])
|
||||
} else if value.Valid {
|
||||
_m.FirstName = value.String
|
||||
}
|
||||
case user.FieldLastName:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field last_name", values[i])
|
||||
} else if value.Valid {
|
||||
_m.LastName = value.String
|
||||
}
|
||||
case user.FieldPasswordHash:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field password_hash", values[i])
|
||||
@@ -101,6 +131,24 @@ func (_m *User) assignValues(columns []string, values []any) error {
|
||||
} else if value.Valid {
|
||||
_m.Verified = value.Bool
|
||||
}
|
||||
case user.FieldEmailVerificationToken:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field email_verification_token", values[i])
|
||||
} else if value.Valid {
|
||||
_m.EmailVerificationToken = value.String
|
||||
}
|
||||
case user.FieldPasswordResetToken:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field password_reset_token", values[i])
|
||||
} else if value.Valid {
|
||||
_m.PasswordResetToken = value.String
|
||||
}
|
||||
case user.FieldPasswordResetExpiresAt:
|
||||
if value, ok := values[i].(*sql.NullTime); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field password_reset_expires_at", values[i])
|
||||
} else if value.Valid {
|
||||
_m.PasswordResetExpiresAt = value.Time
|
||||
}
|
||||
case user.FieldCreatedAt:
|
||||
if value, ok := values[i].(*sql.NullTime); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field created_at", values[i])
|
||||
@@ -157,12 +205,28 @@ func (_m *User) String() string {
|
||||
builder.WriteString("email=")
|
||||
builder.WriteString(_m.Email)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("username=")
|
||||
builder.WriteString(_m.Username)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("first_name=")
|
||||
builder.WriteString(_m.FirstName)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("last_name=")
|
||||
builder.WriteString(_m.LastName)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("password_hash=")
|
||||
builder.WriteString(_m.PasswordHash)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("verified=")
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.Verified))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("email_verification_token=<sensitive>")
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("password_reset_token=<sensitive>")
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("password_reset_expires_at=")
|
||||
builder.WriteString(_m.PasswordResetExpiresAt.Format(time.ANSIC))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("created_at=")
|
||||
builder.WriteString(_m.CreatedAt.Format(time.ANSIC))
|
||||
builder.WriteString(", ")
|
||||
|
||||
@@ -16,10 +16,22 @@ const (
|
||||
FieldID = "id"
|
||||
// FieldEmail holds the string denoting the email field in the database.
|
||||
FieldEmail = "email"
|
||||
// FieldUsername holds the string denoting the username field in the database.
|
||||
FieldUsername = "username"
|
||||
// FieldFirstName holds the string denoting the first_name field in the database.
|
||||
FieldFirstName = "first_name"
|
||||
// FieldLastName holds the string denoting the last_name field in the database.
|
||||
FieldLastName = "last_name"
|
||||
// FieldPasswordHash holds the string denoting the password_hash field in the database.
|
||||
FieldPasswordHash = "password_hash"
|
||||
// FieldVerified holds the string denoting the verified field in the database.
|
||||
FieldVerified = "verified"
|
||||
// FieldEmailVerificationToken holds the string denoting the email_verification_token field in the database.
|
||||
FieldEmailVerificationToken = "email_verification_token"
|
||||
// FieldPasswordResetToken holds the string denoting the password_reset_token field in the database.
|
||||
FieldPasswordResetToken = "password_reset_token"
|
||||
// FieldPasswordResetExpiresAt holds the string denoting the password_reset_expires_at field in the database.
|
||||
FieldPasswordResetExpiresAt = "password_reset_expires_at"
|
||||
// FieldCreatedAt holds the string denoting the created_at field in the database.
|
||||
FieldCreatedAt = "created_at"
|
||||
// FieldUpdatedAt holds the string denoting the updated_at field in the database.
|
||||
@@ -41,8 +53,14 @@ const (
|
||||
var Columns = []string{
|
||||
FieldID,
|
||||
FieldEmail,
|
||||
FieldUsername,
|
||||
FieldFirstName,
|
||||
FieldLastName,
|
||||
FieldPasswordHash,
|
||||
FieldVerified,
|
||||
FieldEmailVerificationToken,
|
||||
FieldPasswordResetToken,
|
||||
FieldPasswordResetExpiresAt,
|
||||
FieldCreatedAt,
|
||||
FieldUpdatedAt,
|
||||
}
|
||||
@@ -85,6 +103,21 @@ func ByEmail(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldEmail, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByUsername orders the results by the username field.
|
||||
func ByUsername(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldUsername, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByFirstName orders the results by the first_name field.
|
||||
func ByFirstName(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldFirstName, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByLastName orders the results by the last_name field.
|
||||
func ByLastName(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldLastName, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByPasswordHash orders the results by the password_hash field.
|
||||
func ByPasswordHash(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldPasswordHash, opts...).ToFunc()
|
||||
@@ -95,6 +128,21 @@ func ByVerified(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldVerified, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByEmailVerificationToken orders the results by the email_verification_token field.
|
||||
func ByEmailVerificationToken(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldEmailVerificationToken, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByPasswordResetToken orders the results by the password_reset_token field.
|
||||
func ByPasswordResetToken(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldPasswordResetToken, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByPasswordResetExpiresAt orders the results by the password_reset_expires_at field.
|
||||
func ByPasswordResetExpiresAt(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldPasswordResetExpiresAt, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByCreatedAt orders the results by the created_at field.
|
||||
func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldCreatedAt, opts...).ToFunc()
|
||||
|
||||
@@ -70,6 +70,21 @@ func Email(v string) predicate.User {
|
||||
return predicate.User(sql.FieldEQ(FieldEmail, v))
|
||||
}
|
||||
|
||||
// Username applies equality check predicate on the "username" field. It's identical to UsernameEQ.
|
||||
func Username(v string) predicate.User {
|
||||
return predicate.User(sql.FieldEQ(FieldUsername, v))
|
||||
}
|
||||
|
||||
// FirstName applies equality check predicate on the "first_name" field. It's identical to FirstNameEQ.
|
||||
func FirstName(v string) predicate.User {
|
||||
return predicate.User(sql.FieldEQ(FieldFirstName, v))
|
||||
}
|
||||
|
||||
// LastName applies equality check predicate on the "last_name" field. It's identical to LastNameEQ.
|
||||
func LastName(v string) predicate.User {
|
||||
return predicate.User(sql.FieldEQ(FieldLastName, v))
|
||||
}
|
||||
|
||||
// PasswordHash applies equality check predicate on the "password_hash" field. It's identical to PasswordHashEQ.
|
||||
func PasswordHash(v string) predicate.User {
|
||||
return predicate.User(sql.FieldEQ(FieldPasswordHash, v))
|
||||
@@ -80,6 +95,21 @@ func Verified(v bool) predicate.User {
|
||||
return predicate.User(sql.FieldEQ(FieldVerified, v))
|
||||
}
|
||||
|
||||
// EmailVerificationToken applies equality check predicate on the "email_verification_token" field. It's identical to EmailVerificationTokenEQ.
|
||||
func EmailVerificationToken(v string) predicate.User {
|
||||
return predicate.User(sql.FieldEQ(FieldEmailVerificationToken, v))
|
||||
}
|
||||
|
||||
// PasswordResetToken applies equality check predicate on the "password_reset_token" field. It's identical to PasswordResetTokenEQ.
|
||||
func PasswordResetToken(v string) predicate.User {
|
||||
return predicate.User(sql.FieldEQ(FieldPasswordResetToken, v))
|
||||
}
|
||||
|
||||
// PasswordResetExpiresAt applies equality check predicate on the "password_reset_expires_at" field. It's identical to PasswordResetExpiresAtEQ.
|
||||
func PasswordResetExpiresAt(v time.Time) predicate.User {
|
||||
return predicate.User(sql.FieldEQ(FieldPasswordResetExpiresAt, v))
|
||||
}
|
||||
|
||||
// CreatedAt applies equality check predicate on the "created_at" field. It's identical to CreatedAtEQ.
|
||||
func CreatedAt(v time.Time) predicate.User {
|
||||
return predicate.User(sql.FieldEQ(FieldCreatedAt, v))
|
||||
@@ -155,6 +185,231 @@ func EmailContainsFold(v string) predicate.User {
|
||||
return predicate.User(sql.FieldContainsFold(FieldEmail, v))
|
||||
}
|
||||
|
||||
// UsernameEQ applies the EQ predicate on the "username" field.
|
||||
func UsernameEQ(v string) predicate.User {
|
||||
return predicate.User(sql.FieldEQ(FieldUsername, v))
|
||||
}
|
||||
|
||||
// UsernameNEQ applies the NEQ predicate on the "username" field.
|
||||
func UsernameNEQ(v string) predicate.User {
|
||||
return predicate.User(sql.FieldNEQ(FieldUsername, v))
|
||||
}
|
||||
|
||||
// UsernameIn applies the In predicate on the "username" field.
|
||||
func UsernameIn(vs ...string) predicate.User {
|
||||
return predicate.User(sql.FieldIn(FieldUsername, vs...))
|
||||
}
|
||||
|
||||
// UsernameNotIn applies the NotIn predicate on the "username" field.
|
||||
func UsernameNotIn(vs ...string) predicate.User {
|
||||
return predicate.User(sql.FieldNotIn(FieldUsername, vs...))
|
||||
}
|
||||
|
||||
// UsernameGT applies the GT predicate on the "username" field.
|
||||
func UsernameGT(v string) predicate.User {
|
||||
return predicate.User(sql.FieldGT(FieldUsername, v))
|
||||
}
|
||||
|
||||
// UsernameGTE applies the GTE predicate on the "username" field.
|
||||
func UsernameGTE(v string) predicate.User {
|
||||
return predicate.User(sql.FieldGTE(FieldUsername, v))
|
||||
}
|
||||
|
||||
// UsernameLT applies the LT predicate on the "username" field.
|
||||
func UsernameLT(v string) predicate.User {
|
||||
return predicate.User(sql.FieldLT(FieldUsername, v))
|
||||
}
|
||||
|
||||
// UsernameLTE applies the LTE predicate on the "username" field.
|
||||
func UsernameLTE(v string) predicate.User {
|
||||
return predicate.User(sql.FieldLTE(FieldUsername, v))
|
||||
}
|
||||
|
||||
// UsernameContains applies the Contains predicate on the "username" field.
|
||||
func UsernameContains(v string) predicate.User {
|
||||
return predicate.User(sql.FieldContains(FieldUsername, v))
|
||||
}
|
||||
|
||||
// UsernameHasPrefix applies the HasPrefix predicate on the "username" field.
|
||||
func UsernameHasPrefix(v string) predicate.User {
|
||||
return predicate.User(sql.FieldHasPrefix(FieldUsername, v))
|
||||
}
|
||||
|
||||
// UsernameHasSuffix applies the HasSuffix predicate on the "username" field.
|
||||
func UsernameHasSuffix(v string) predicate.User {
|
||||
return predicate.User(sql.FieldHasSuffix(FieldUsername, v))
|
||||
}
|
||||
|
||||
// UsernameIsNil applies the IsNil predicate on the "username" field.
|
||||
func UsernameIsNil() predicate.User {
|
||||
return predicate.User(sql.FieldIsNull(FieldUsername))
|
||||
}
|
||||
|
||||
// UsernameNotNil applies the NotNil predicate on the "username" field.
|
||||
func UsernameNotNil() predicate.User {
|
||||
return predicate.User(sql.FieldNotNull(FieldUsername))
|
||||
}
|
||||
|
||||
// UsernameEqualFold applies the EqualFold predicate on the "username" field.
|
||||
func UsernameEqualFold(v string) predicate.User {
|
||||
return predicate.User(sql.FieldEqualFold(FieldUsername, v))
|
||||
}
|
||||
|
||||
// UsernameContainsFold applies the ContainsFold predicate on the "username" field.
|
||||
func UsernameContainsFold(v string) predicate.User {
|
||||
return predicate.User(sql.FieldContainsFold(FieldUsername, v))
|
||||
}
|
||||
|
||||
// FirstNameEQ applies the EQ predicate on the "first_name" field.
|
||||
func FirstNameEQ(v string) predicate.User {
|
||||
return predicate.User(sql.FieldEQ(FieldFirstName, v))
|
||||
}
|
||||
|
||||
// FirstNameNEQ applies the NEQ predicate on the "first_name" field.
|
||||
func FirstNameNEQ(v string) predicate.User {
|
||||
return predicate.User(sql.FieldNEQ(FieldFirstName, v))
|
||||
}
|
||||
|
||||
// FirstNameIn applies the In predicate on the "first_name" field.
|
||||
func FirstNameIn(vs ...string) predicate.User {
|
||||
return predicate.User(sql.FieldIn(FieldFirstName, vs...))
|
||||
}
|
||||
|
||||
// FirstNameNotIn applies the NotIn predicate on the "first_name" field.
|
||||
func FirstNameNotIn(vs ...string) predicate.User {
|
||||
return predicate.User(sql.FieldNotIn(FieldFirstName, vs...))
|
||||
}
|
||||
|
||||
// FirstNameGT applies the GT predicate on the "first_name" field.
|
||||
func FirstNameGT(v string) predicate.User {
|
||||
return predicate.User(sql.FieldGT(FieldFirstName, v))
|
||||
}
|
||||
|
||||
// FirstNameGTE applies the GTE predicate on the "first_name" field.
|
||||
func FirstNameGTE(v string) predicate.User {
|
||||
return predicate.User(sql.FieldGTE(FieldFirstName, v))
|
||||
}
|
||||
|
||||
// FirstNameLT applies the LT predicate on the "first_name" field.
|
||||
func FirstNameLT(v string) predicate.User {
|
||||
return predicate.User(sql.FieldLT(FieldFirstName, v))
|
||||
}
|
||||
|
||||
// FirstNameLTE applies the LTE predicate on the "first_name" field.
|
||||
func FirstNameLTE(v string) predicate.User {
|
||||
return predicate.User(sql.FieldLTE(FieldFirstName, v))
|
||||
}
|
||||
|
||||
// FirstNameContains applies the Contains predicate on the "first_name" field.
|
||||
func FirstNameContains(v string) predicate.User {
|
||||
return predicate.User(sql.FieldContains(FieldFirstName, v))
|
||||
}
|
||||
|
||||
// FirstNameHasPrefix applies the HasPrefix predicate on the "first_name" field.
|
||||
func FirstNameHasPrefix(v string) predicate.User {
|
||||
return predicate.User(sql.FieldHasPrefix(FieldFirstName, v))
|
||||
}
|
||||
|
||||
// FirstNameHasSuffix applies the HasSuffix predicate on the "first_name" field.
|
||||
func FirstNameHasSuffix(v string) predicate.User {
|
||||
return predicate.User(sql.FieldHasSuffix(FieldFirstName, v))
|
||||
}
|
||||
|
||||
// FirstNameIsNil applies the IsNil predicate on the "first_name" field.
|
||||
func FirstNameIsNil() predicate.User {
|
||||
return predicate.User(sql.FieldIsNull(FieldFirstName))
|
||||
}
|
||||
|
||||
// FirstNameNotNil applies the NotNil predicate on the "first_name" field.
|
||||
func FirstNameNotNil() predicate.User {
|
||||
return predicate.User(sql.FieldNotNull(FieldFirstName))
|
||||
}
|
||||
|
||||
// FirstNameEqualFold applies the EqualFold predicate on the "first_name" field.
|
||||
func FirstNameEqualFold(v string) predicate.User {
|
||||
return predicate.User(sql.FieldEqualFold(FieldFirstName, v))
|
||||
}
|
||||
|
||||
// FirstNameContainsFold applies the ContainsFold predicate on the "first_name" field.
|
||||
func FirstNameContainsFold(v string) predicate.User {
|
||||
return predicate.User(sql.FieldContainsFold(FieldFirstName, v))
|
||||
}
|
||||
|
||||
// LastNameEQ applies the EQ predicate on the "last_name" field.
|
||||
func LastNameEQ(v string) predicate.User {
|
||||
return predicate.User(sql.FieldEQ(FieldLastName, v))
|
||||
}
|
||||
|
||||
// LastNameNEQ applies the NEQ predicate on the "last_name" field.
|
||||
func LastNameNEQ(v string) predicate.User {
|
||||
return predicate.User(sql.FieldNEQ(FieldLastName, v))
|
||||
}
|
||||
|
||||
// LastNameIn applies the In predicate on the "last_name" field.
|
||||
func LastNameIn(vs ...string) predicate.User {
|
||||
return predicate.User(sql.FieldIn(FieldLastName, vs...))
|
||||
}
|
||||
|
||||
// LastNameNotIn applies the NotIn predicate on the "last_name" field.
|
||||
func LastNameNotIn(vs ...string) predicate.User {
|
||||
return predicate.User(sql.FieldNotIn(FieldLastName, vs...))
|
||||
}
|
||||
|
||||
// LastNameGT applies the GT predicate on the "last_name" field.
|
||||
func LastNameGT(v string) predicate.User {
|
||||
return predicate.User(sql.FieldGT(FieldLastName, v))
|
||||
}
|
||||
|
||||
// LastNameGTE applies the GTE predicate on the "last_name" field.
|
||||
func LastNameGTE(v string) predicate.User {
|
||||
return predicate.User(sql.FieldGTE(FieldLastName, v))
|
||||
}
|
||||
|
||||
// LastNameLT applies the LT predicate on the "last_name" field.
|
||||
func LastNameLT(v string) predicate.User {
|
||||
return predicate.User(sql.FieldLT(FieldLastName, v))
|
||||
}
|
||||
|
||||
// LastNameLTE applies the LTE predicate on the "last_name" field.
|
||||
func LastNameLTE(v string) predicate.User {
|
||||
return predicate.User(sql.FieldLTE(FieldLastName, v))
|
||||
}
|
||||
|
||||
// LastNameContains applies the Contains predicate on the "last_name" field.
|
||||
func LastNameContains(v string) predicate.User {
|
||||
return predicate.User(sql.FieldContains(FieldLastName, v))
|
||||
}
|
||||
|
||||
// LastNameHasPrefix applies the HasPrefix predicate on the "last_name" field.
|
||||
func LastNameHasPrefix(v string) predicate.User {
|
||||
return predicate.User(sql.FieldHasPrefix(FieldLastName, v))
|
||||
}
|
||||
|
||||
// LastNameHasSuffix applies the HasSuffix predicate on the "last_name" field.
|
||||
func LastNameHasSuffix(v string) predicate.User {
|
||||
return predicate.User(sql.FieldHasSuffix(FieldLastName, v))
|
||||
}
|
||||
|
||||
// LastNameIsNil applies the IsNil predicate on the "last_name" field.
|
||||
func LastNameIsNil() predicate.User {
|
||||
return predicate.User(sql.FieldIsNull(FieldLastName))
|
||||
}
|
||||
|
||||
// LastNameNotNil applies the NotNil predicate on the "last_name" field.
|
||||
func LastNameNotNil() predicate.User {
|
||||
return predicate.User(sql.FieldNotNull(FieldLastName))
|
||||
}
|
||||
|
||||
// LastNameEqualFold applies the EqualFold predicate on the "last_name" field.
|
||||
func LastNameEqualFold(v string) predicate.User {
|
||||
return predicate.User(sql.FieldEqualFold(FieldLastName, v))
|
||||
}
|
||||
|
||||
// LastNameContainsFold applies the ContainsFold predicate on the "last_name" field.
|
||||
func LastNameContainsFold(v string) predicate.User {
|
||||
return predicate.User(sql.FieldContainsFold(FieldLastName, v))
|
||||
}
|
||||
|
||||
// PasswordHashEQ applies the EQ predicate on the "password_hash" field.
|
||||
func PasswordHashEQ(v string) predicate.User {
|
||||
return predicate.User(sql.FieldEQ(FieldPasswordHash, v))
|
||||
@@ -230,6 +485,206 @@ func VerifiedNEQ(v bool) predicate.User {
|
||||
return predicate.User(sql.FieldNEQ(FieldVerified, v))
|
||||
}
|
||||
|
||||
// EmailVerificationTokenEQ applies the EQ predicate on the "email_verification_token" field.
|
||||
func EmailVerificationTokenEQ(v string) predicate.User {
|
||||
return predicate.User(sql.FieldEQ(FieldEmailVerificationToken, v))
|
||||
}
|
||||
|
||||
// EmailVerificationTokenNEQ applies the NEQ predicate on the "email_verification_token" field.
|
||||
func EmailVerificationTokenNEQ(v string) predicate.User {
|
||||
return predicate.User(sql.FieldNEQ(FieldEmailVerificationToken, v))
|
||||
}
|
||||
|
||||
// EmailVerificationTokenIn applies the In predicate on the "email_verification_token" field.
|
||||
func EmailVerificationTokenIn(vs ...string) predicate.User {
|
||||
return predicate.User(sql.FieldIn(FieldEmailVerificationToken, vs...))
|
||||
}
|
||||
|
||||
// EmailVerificationTokenNotIn applies the NotIn predicate on the "email_verification_token" field.
|
||||
func EmailVerificationTokenNotIn(vs ...string) predicate.User {
|
||||
return predicate.User(sql.FieldNotIn(FieldEmailVerificationToken, vs...))
|
||||
}
|
||||
|
||||
// EmailVerificationTokenGT applies the GT predicate on the "email_verification_token" field.
|
||||
func EmailVerificationTokenGT(v string) predicate.User {
|
||||
return predicate.User(sql.FieldGT(FieldEmailVerificationToken, v))
|
||||
}
|
||||
|
||||
// EmailVerificationTokenGTE applies the GTE predicate on the "email_verification_token" field.
|
||||
func EmailVerificationTokenGTE(v string) predicate.User {
|
||||
return predicate.User(sql.FieldGTE(FieldEmailVerificationToken, v))
|
||||
}
|
||||
|
||||
// EmailVerificationTokenLT applies the LT predicate on the "email_verification_token" field.
|
||||
func EmailVerificationTokenLT(v string) predicate.User {
|
||||
return predicate.User(sql.FieldLT(FieldEmailVerificationToken, v))
|
||||
}
|
||||
|
||||
// EmailVerificationTokenLTE applies the LTE predicate on the "email_verification_token" field.
|
||||
func EmailVerificationTokenLTE(v string) predicate.User {
|
||||
return predicate.User(sql.FieldLTE(FieldEmailVerificationToken, v))
|
||||
}
|
||||
|
||||
// EmailVerificationTokenContains applies the Contains predicate on the "email_verification_token" field.
|
||||
func EmailVerificationTokenContains(v string) predicate.User {
|
||||
return predicate.User(sql.FieldContains(FieldEmailVerificationToken, v))
|
||||
}
|
||||
|
||||
// EmailVerificationTokenHasPrefix applies the HasPrefix predicate on the "email_verification_token" field.
|
||||
func EmailVerificationTokenHasPrefix(v string) predicate.User {
|
||||
return predicate.User(sql.FieldHasPrefix(FieldEmailVerificationToken, v))
|
||||
}
|
||||
|
||||
// EmailVerificationTokenHasSuffix applies the HasSuffix predicate on the "email_verification_token" field.
|
||||
func EmailVerificationTokenHasSuffix(v string) predicate.User {
|
||||
return predicate.User(sql.FieldHasSuffix(FieldEmailVerificationToken, v))
|
||||
}
|
||||
|
||||
// EmailVerificationTokenIsNil applies the IsNil predicate on the "email_verification_token" field.
|
||||
func EmailVerificationTokenIsNil() predicate.User {
|
||||
return predicate.User(sql.FieldIsNull(FieldEmailVerificationToken))
|
||||
}
|
||||
|
||||
// EmailVerificationTokenNotNil applies the NotNil predicate on the "email_verification_token" field.
|
||||
func EmailVerificationTokenNotNil() predicate.User {
|
||||
return predicate.User(sql.FieldNotNull(FieldEmailVerificationToken))
|
||||
}
|
||||
|
||||
// EmailVerificationTokenEqualFold applies the EqualFold predicate on the "email_verification_token" field.
|
||||
func EmailVerificationTokenEqualFold(v string) predicate.User {
|
||||
return predicate.User(sql.FieldEqualFold(FieldEmailVerificationToken, v))
|
||||
}
|
||||
|
||||
// EmailVerificationTokenContainsFold applies the ContainsFold predicate on the "email_verification_token" field.
|
||||
func EmailVerificationTokenContainsFold(v string) predicate.User {
|
||||
return predicate.User(sql.FieldContainsFold(FieldEmailVerificationToken, v))
|
||||
}
|
||||
|
||||
// PasswordResetTokenEQ applies the EQ predicate on the "password_reset_token" field.
|
||||
func PasswordResetTokenEQ(v string) predicate.User {
|
||||
return predicate.User(sql.FieldEQ(FieldPasswordResetToken, v))
|
||||
}
|
||||
|
||||
// PasswordResetTokenNEQ applies the NEQ predicate on the "password_reset_token" field.
|
||||
func PasswordResetTokenNEQ(v string) predicate.User {
|
||||
return predicate.User(sql.FieldNEQ(FieldPasswordResetToken, v))
|
||||
}
|
||||
|
||||
// PasswordResetTokenIn applies the In predicate on the "password_reset_token" field.
|
||||
func PasswordResetTokenIn(vs ...string) predicate.User {
|
||||
return predicate.User(sql.FieldIn(FieldPasswordResetToken, vs...))
|
||||
}
|
||||
|
||||
// PasswordResetTokenNotIn applies the NotIn predicate on the "password_reset_token" field.
|
||||
func PasswordResetTokenNotIn(vs ...string) predicate.User {
|
||||
return predicate.User(sql.FieldNotIn(FieldPasswordResetToken, vs...))
|
||||
}
|
||||
|
||||
// PasswordResetTokenGT applies the GT predicate on the "password_reset_token" field.
|
||||
func PasswordResetTokenGT(v string) predicate.User {
|
||||
return predicate.User(sql.FieldGT(FieldPasswordResetToken, v))
|
||||
}
|
||||
|
||||
// PasswordResetTokenGTE applies the GTE predicate on the "password_reset_token" field.
|
||||
func PasswordResetTokenGTE(v string) predicate.User {
|
||||
return predicate.User(sql.FieldGTE(FieldPasswordResetToken, v))
|
||||
}
|
||||
|
||||
// PasswordResetTokenLT applies the LT predicate on the "password_reset_token" field.
|
||||
func PasswordResetTokenLT(v string) predicate.User {
|
||||
return predicate.User(sql.FieldLT(FieldPasswordResetToken, v))
|
||||
}
|
||||
|
||||
// PasswordResetTokenLTE applies the LTE predicate on the "password_reset_token" field.
|
||||
func PasswordResetTokenLTE(v string) predicate.User {
|
||||
return predicate.User(sql.FieldLTE(FieldPasswordResetToken, v))
|
||||
}
|
||||
|
||||
// PasswordResetTokenContains applies the Contains predicate on the "password_reset_token" field.
|
||||
func PasswordResetTokenContains(v string) predicate.User {
|
||||
return predicate.User(sql.FieldContains(FieldPasswordResetToken, v))
|
||||
}
|
||||
|
||||
// PasswordResetTokenHasPrefix applies the HasPrefix predicate on the "password_reset_token" field.
|
||||
func PasswordResetTokenHasPrefix(v string) predicate.User {
|
||||
return predicate.User(sql.FieldHasPrefix(FieldPasswordResetToken, v))
|
||||
}
|
||||
|
||||
// PasswordResetTokenHasSuffix applies the HasSuffix predicate on the "password_reset_token" field.
|
||||
func PasswordResetTokenHasSuffix(v string) predicate.User {
|
||||
return predicate.User(sql.FieldHasSuffix(FieldPasswordResetToken, v))
|
||||
}
|
||||
|
||||
// PasswordResetTokenIsNil applies the IsNil predicate on the "password_reset_token" field.
|
||||
func PasswordResetTokenIsNil() predicate.User {
|
||||
return predicate.User(sql.FieldIsNull(FieldPasswordResetToken))
|
||||
}
|
||||
|
||||
// PasswordResetTokenNotNil applies the NotNil predicate on the "password_reset_token" field.
|
||||
func PasswordResetTokenNotNil() predicate.User {
|
||||
return predicate.User(sql.FieldNotNull(FieldPasswordResetToken))
|
||||
}
|
||||
|
||||
// PasswordResetTokenEqualFold applies the EqualFold predicate on the "password_reset_token" field.
|
||||
func PasswordResetTokenEqualFold(v string) predicate.User {
|
||||
return predicate.User(sql.FieldEqualFold(FieldPasswordResetToken, v))
|
||||
}
|
||||
|
||||
// PasswordResetTokenContainsFold applies the ContainsFold predicate on the "password_reset_token" field.
|
||||
func PasswordResetTokenContainsFold(v string) predicate.User {
|
||||
return predicate.User(sql.FieldContainsFold(FieldPasswordResetToken, v))
|
||||
}
|
||||
|
||||
// PasswordResetExpiresAtEQ applies the EQ predicate on the "password_reset_expires_at" field.
|
||||
func PasswordResetExpiresAtEQ(v time.Time) predicate.User {
|
||||
return predicate.User(sql.FieldEQ(FieldPasswordResetExpiresAt, v))
|
||||
}
|
||||
|
||||
// PasswordResetExpiresAtNEQ applies the NEQ predicate on the "password_reset_expires_at" field.
|
||||
func PasswordResetExpiresAtNEQ(v time.Time) predicate.User {
|
||||
return predicate.User(sql.FieldNEQ(FieldPasswordResetExpiresAt, v))
|
||||
}
|
||||
|
||||
// PasswordResetExpiresAtIn applies the In predicate on the "password_reset_expires_at" field.
|
||||
func PasswordResetExpiresAtIn(vs ...time.Time) predicate.User {
|
||||
return predicate.User(sql.FieldIn(FieldPasswordResetExpiresAt, vs...))
|
||||
}
|
||||
|
||||
// PasswordResetExpiresAtNotIn applies the NotIn predicate on the "password_reset_expires_at" field.
|
||||
func PasswordResetExpiresAtNotIn(vs ...time.Time) predicate.User {
|
||||
return predicate.User(sql.FieldNotIn(FieldPasswordResetExpiresAt, vs...))
|
||||
}
|
||||
|
||||
// PasswordResetExpiresAtGT applies the GT predicate on the "password_reset_expires_at" field.
|
||||
func PasswordResetExpiresAtGT(v time.Time) predicate.User {
|
||||
return predicate.User(sql.FieldGT(FieldPasswordResetExpiresAt, v))
|
||||
}
|
||||
|
||||
// PasswordResetExpiresAtGTE applies the GTE predicate on the "password_reset_expires_at" field.
|
||||
func PasswordResetExpiresAtGTE(v time.Time) predicate.User {
|
||||
return predicate.User(sql.FieldGTE(FieldPasswordResetExpiresAt, v))
|
||||
}
|
||||
|
||||
// PasswordResetExpiresAtLT applies the LT predicate on the "password_reset_expires_at" field.
|
||||
func PasswordResetExpiresAtLT(v time.Time) predicate.User {
|
||||
return predicate.User(sql.FieldLT(FieldPasswordResetExpiresAt, v))
|
||||
}
|
||||
|
||||
// PasswordResetExpiresAtLTE applies the LTE predicate on the "password_reset_expires_at" field.
|
||||
func PasswordResetExpiresAtLTE(v time.Time) predicate.User {
|
||||
return predicate.User(sql.FieldLTE(FieldPasswordResetExpiresAt, v))
|
||||
}
|
||||
|
||||
// PasswordResetExpiresAtIsNil applies the IsNil predicate on the "password_reset_expires_at" field.
|
||||
func PasswordResetExpiresAtIsNil() predicate.User {
|
||||
return predicate.User(sql.FieldIsNull(FieldPasswordResetExpiresAt))
|
||||
}
|
||||
|
||||
// PasswordResetExpiresAtNotNil applies the NotNil predicate on the "password_reset_expires_at" field.
|
||||
func PasswordResetExpiresAtNotNil() predicate.User {
|
||||
return predicate.User(sql.FieldNotNull(FieldPasswordResetExpiresAt))
|
||||
}
|
||||
|
||||
// CreatedAtEQ applies the EQ predicate on the "created_at" field.
|
||||
func CreatedAtEQ(v time.Time) predicate.User {
|
||||
return predicate.User(sql.FieldEQ(FieldCreatedAt, v))
|
||||
|
||||
@@ -27,6 +27,48 @@ func (_c *UserCreate) SetEmail(v string) *UserCreate {
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetUsername sets the "username" field.
|
||||
func (_c *UserCreate) SetUsername(v string) *UserCreate {
|
||||
_c.mutation.SetUsername(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableUsername sets the "username" field if the given value is not nil.
|
||||
func (_c *UserCreate) SetNillableUsername(v *string) *UserCreate {
|
||||
if v != nil {
|
||||
_c.SetUsername(*v)
|
||||
}
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetFirstName sets the "first_name" field.
|
||||
func (_c *UserCreate) SetFirstName(v string) *UserCreate {
|
||||
_c.mutation.SetFirstName(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableFirstName sets the "first_name" field if the given value is not nil.
|
||||
func (_c *UserCreate) SetNillableFirstName(v *string) *UserCreate {
|
||||
if v != nil {
|
||||
_c.SetFirstName(*v)
|
||||
}
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetLastName sets the "last_name" field.
|
||||
func (_c *UserCreate) SetLastName(v string) *UserCreate {
|
||||
_c.mutation.SetLastName(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableLastName sets the "last_name" field if the given value is not nil.
|
||||
func (_c *UserCreate) SetNillableLastName(v *string) *UserCreate {
|
||||
if v != nil {
|
||||
_c.SetLastName(*v)
|
||||
}
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetPasswordHash sets the "password_hash" field.
|
||||
func (_c *UserCreate) SetPasswordHash(v string) *UserCreate {
|
||||
_c.mutation.SetPasswordHash(v)
|
||||
@@ -47,6 +89,48 @@ func (_c *UserCreate) SetNillableVerified(v *bool) *UserCreate {
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetEmailVerificationToken sets the "email_verification_token" field.
|
||||
func (_c *UserCreate) SetEmailVerificationToken(v string) *UserCreate {
|
||||
_c.mutation.SetEmailVerificationToken(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableEmailVerificationToken sets the "email_verification_token" field if the given value is not nil.
|
||||
func (_c *UserCreate) SetNillableEmailVerificationToken(v *string) *UserCreate {
|
||||
if v != nil {
|
||||
_c.SetEmailVerificationToken(*v)
|
||||
}
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetPasswordResetToken sets the "password_reset_token" field.
|
||||
func (_c *UserCreate) SetPasswordResetToken(v string) *UserCreate {
|
||||
_c.mutation.SetPasswordResetToken(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillablePasswordResetToken sets the "password_reset_token" field if the given value is not nil.
|
||||
func (_c *UserCreate) SetNillablePasswordResetToken(v *string) *UserCreate {
|
||||
if v != nil {
|
||||
_c.SetPasswordResetToken(*v)
|
||||
}
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetPasswordResetExpiresAt sets the "password_reset_expires_at" field.
|
||||
func (_c *UserCreate) SetPasswordResetExpiresAt(v time.Time) *UserCreate {
|
||||
_c.mutation.SetPasswordResetExpiresAt(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillablePasswordResetExpiresAt sets the "password_reset_expires_at" field if the given value is not nil.
|
||||
func (_c *UserCreate) SetNillablePasswordResetExpiresAt(v *time.Time) *UserCreate {
|
||||
if v != nil {
|
||||
_c.SetPasswordResetExpiresAt(*v)
|
||||
}
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetCreatedAt sets the "created_at" field.
|
||||
func (_c *UserCreate) SetCreatedAt(v time.Time) *UserCreate {
|
||||
_c.mutation.SetCreatedAt(v)
|
||||
@@ -211,6 +295,18 @@ func (_c *UserCreate) createSpec() (*User, *sqlgraph.CreateSpec) {
|
||||
_spec.SetField(user.FieldEmail, field.TypeString, value)
|
||||
_node.Email = value
|
||||
}
|
||||
if value, ok := _c.mutation.Username(); ok {
|
||||
_spec.SetField(user.FieldUsername, field.TypeString, value)
|
||||
_node.Username = value
|
||||
}
|
||||
if value, ok := _c.mutation.FirstName(); ok {
|
||||
_spec.SetField(user.FieldFirstName, field.TypeString, value)
|
||||
_node.FirstName = value
|
||||
}
|
||||
if value, ok := _c.mutation.LastName(); ok {
|
||||
_spec.SetField(user.FieldLastName, field.TypeString, value)
|
||||
_node.LastName = value
|
||||
}
|
||||
if value, ok := _c.mutation.PasswordHash(); ok {
|
||||
_spec.SetField(user.FieldPasswordHash, field.TypeString, value)
|
||||
_node.PasswordHash = value
|
||||
@@ -219,6 +315,18 @@ func (_c *UserCreate) createSpec() (*User, *sqlgraph.CreateSpec) {
|
||||
_spec.SetField(user.FieldVerified, field.TypeBool, value)
|
||||
_node.Verified = value
|
||||
}
|
||||
if value, ok := _c.mutation.EmailVerificationToken(); ok {
|
||||
_spec.SetField(user.FieldEmailVerificationToken, field.TypeString, value)
|
||||
_node.EmailVerificationToken = value
|
||||
}
|
||||
if value, ok := _c.mutation.PasswordResetToken(); ok {
|
||||
_spec.SetField(user.FieldPasswordResetToken, field.TypeString, value)
|
||||
_node.PasswordResetToken = value
|
||||
}
|
||||
if value, ok := _c.mutation.PasswordResetExpiresAt(); ok {
|
||||
_spec.SetField(user.FieldPasswordResetExpiresAt, field.TypeTime, value)
|
||||
_node.PasswordResetExpiresAt = value
|
||||
}
|
||||
if value, ok := _c.mutation.CreatedAt(); ok {
|
||||
_spec.SetField(user.FieldCreatedAt, field.TypeTime, value)
|
||||
_node.CreatedAt = value
|
||||
|
||||
@@ -43,6 +43,66 @@ func (_u *UserUpdate) SetNillableEmail(v *string) *UserUpdate {
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetUsername sets the "username" field.
|
||||
func (_u *UserUpdate) SetUsername(v string) *UserUpdate {
|
||||
_u.mutation.SetUsername(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableUsername sets the "username" field if the given value is not nil.
|
||||
func (_u *UserUpdate) SetNillableUsername(v *string) *UserUpdate {
|
||||
if v != nil {
|
||||
_u.SetUsername(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// ClearUsername clears the value of the "username" field.
|
||||
func (_u *UserUpdate) ClearUsername() *UserUpdate {
|
||||
_u.mutation.ClearUsername()
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetFirstName sets the "first_name" field.
|
||||
func (_u *UserUpdate) SetFirstName(v string) *UserUpdate {
|
||||
_u.mutation.SetFirstName(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableFirstName sets the "first_name" field if the given value is not nil.
|
||||
func (_u *UserUpdate) SetNillableFirstName(v *string) *UserUpdate {
|
||||
if v != nil {
|
||||
_u.SetFirstName(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// ClearFirstName clears the value of the "first_name" field.
|
||||
func (_u *UserUpdate) ClearFirstName() *UserUpdate {
|
||||
_u.mutation.ClearFirstName()
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetLastName sets the "last_name" field.
|
||||
func (_u *UserUpdate) SetLastName(v string) *UserUpdate {
|
||||
_u.mutation.SetLastName(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableLastName sets the "last_name" field if the given value is not nil.
|
||||
func (_u *UserUpdate) SetNillableLastName(v *string) *UserUpdate {
|
||||
if v != nil {
|
||||
_u.SetLastName(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// ClearLastName clears the value of the "last_name" field.
|
||||
func (_u *UserUpdate) ClearLastName() *UserUpdate {
|
||||
_u.mutation.ClearLastName()
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetPasswordHash sets the "password_hash" field.
|
||||
func (_u *UserUpdate) SetPasswordHash(v string) *UserUpdate {
|
||||
_u.mutation.SetPasswordHash(v)
|
||||
@@ -71,6 +131,66 @@ func (_u *UserUpdate) SetNillableVerified(v *bool) *UserUpdate {
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetEmailVerificationToken sets the "email_verification_token" field.
|
||||
func (_u *UserUpdate) SetEmailVerificationToken(v string) *UserUpdate {
|
||||
_u.mutation.SetEmailVerificationToken(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableEmailVerificationToken sets the "email_verification_token" field if the given value is not nil.
|
||||
func (_u *UserUpdate) SetNillableEmailVerificationToken(v *string) *UserUpdate {
|
||||
if v != nil {
|
||||
_u.SetEmailVerificationToken(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// ClearEmailVerificationToken clears the value of the "email_verification_token" field.
|
||||
func (_u *UserUpdate) ClearEmailVerificationToken() *UserUpdate {
|
||||
_u.mutation.ClearEmailVerificationToken()
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetPasswordResetToken sets the "password_reset_token" field.
|
||||
func (_u *UserUpdate) SetPasswordResetToken(v string) *UserUpdate {
|
||||
_u.mutation.SetPasswordResetToken(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillablePasswordResetToken sets the "password_reset_token" field if the given value is not nil.
|
||||
func (_u *UserUpdate) SetNillablePasswordResetToken(v *string) *UserUpdate {
|
||||
if v != nil {
|
||||
_u.SetPasswordResetToken(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// ClearPasswordResetToken clears the value of the "password_reset_token" field.
|
||||
func (_u *UserUpdate) ClearPasswordResetToken() *UserUpdate {
|
||||
_u.mutation.ClearPasswordResetToken()
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetPasswordResetExpiresAt sets the "password_reset_expires_at" field.
|
||||
func (_u *UserUpdate) SetPasswordResetExpiresAt(v time.Time) *UserUpdate {
|
||||
_u.mutation.SetPasswordResetExpiresAt(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillablePasswordResetExpiresAt sets the "password_reset_expires_at" field if the given value is not nil.
|
||||
func (_u *UserUpdate) SetNillablePasswordResetExpiresAt(v *time.Time) *UserUpdate {
|
||||
if v != nil {
|
||||
_u.SetPasswordResetExpiresAt(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// ClearPasswordResetExpiresAt clears the value of the "password_reset_expires_at" field.
|
||||
func (_u *UserUpdate) ClearPasswordResetExpiresAt() *UserUpdate {
|
||||
_u.mutation.ClearPasswordResetExpiresAt()
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetUpdatedAt sets the "updated_at" field.
|
||||
func (_u *UserUpdate) SetUpdatedAt(v time.Time) *UserUpdate {
|
||||
_u.mutation.SetUpdatedAt(v)
|
||||
@@ -184,12 +304,48 @@ func (_u *UserUpdate) sqlSave(ctx context.Context) (_node int, err error) {
|
||||
if value, ok := _u.mutation.Email(); ok {
|
||||
_spec.SetField(user.FieldEmail, field.TypeString, value)
|
||||
}
|
||||
if value, ok := _u.mutation.Username(); ok {
|
||||
_spec.SetField(user.FieldUsername, field.TypeString, value)
|
||||
}
|
||||
if _u.mutation.UsernameCleared() {
|
||||
_spec.ClearField(user.FieldUsername, field.TypeString)
|
||||
}
|
||||
if value, ok := _u.mutation.FirstName(); ok {
|
||||
_spec.SetField(user.FieldFirstName, field.TypeString, value)
|
||||
}
|
||||
if _u.mutation.FirstNameCleared() {
|
||||
_spec.ClearField(user.FieldFirstName, field.TypeString)
|
||||
}
|
||||
if value, ok := _u.mutation.LastName(); ok {
|
||||
_spec.SetField(user.FieldLastName, field.TypeString, value)
|
||||
}
|
||||
if _u.mutation.LastNameCleared() {
|
||||
_spec.ClearField(user.FieldLastName, field.TypeString)
|
||||
}
|
||||
if value, ok := _u.mutation.PasswordHash(); ok {
|
||||
_spec.SetField(user.FieldPasswordHash, field.TypeString, value)
|
||||
}
|
||||
if value, ok := _u.mutation.Verified(); ok {
|
||||
_spec.SetField(user.FieldVerified, field.TypeBool, value)
|
||||
}
|
||||
if value, ok := _u.mutation.EmailVerificationToken(); ok {
|
||||
_spec.SetField(user.FieldEmailVerificationToken, field.TypeString, value)
|
||||
}
|
||||
if _u.mutation.EmailVerificationTokenCleared() {
|
||||
_spec.ClearField(user.FieldEmailVerificationToken, field.TypeString)
|
||||
}
|
||||
if value, ok := _u.mutation.PasswordResetToken(); ok {
|
||||
_spec.SetField(user.FieldPasswordResetToken, field.TypeString, value)
|
||||
}
|
||||
if _u.mutation.PasswordResetTokenCleared() {
|
||||
_spec.ClearField(user.FieldPasswordResetToken, field.TypeString)
|
||||
}
|
||||
if value, ok := _u.mutation.PasswordResetExpiresAt(); ok {
|
||||
_spec.SetField(user.FieldPasswordResetExpiresAt, field.TypeTime, value)
|
||||
}
|
||||
if _u.mutation.PasswordResetExpiresAtCleared() {
|
||||
_spec.ClearField(user.FieldPasswordResetExpiresAt, field.TypeTime)
|
||||
}
|
||||
if value, ok := _u.mutation.UpdatedAt(); ok {
|
||||
_spec.SetField(user.FieldUpdatedAt, field.TypeTime, value)
|
||||
}
|
||||
@@ -272,6 +428,66 @@ func (_u *UserUpdateOne) SetNillableEmail(v *string) *UserUpdateOne {
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetUsername sets the "username" field.
|
||||
func (_u *UserUpdateOne) SetUsername(v string) *UserUpdateOne {
|
||||
_u.mutation.SetUsername(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableUsername sets the "username" field if the given value is not nil.
|
||||
func (_u *UserUpdateOne) SetNillableUsername(v *string) *UserUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetUsername(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// ClearUsername clears the value of the "username" field.
|
||||
func (_u *UserUpdateOne) ClearUsername() *UserUpdateOne {
|
||||
_u.mutation.ClearUsername()
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetFirstName sets the "first_name" field.
|
||||
func (_u *UserUpdateOne) SetFirstName(v string) *UserUpdateOne {
|
||||
_u.mutation.SetFirstName(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableFirstName sets the "first_name" field if the given value is not nil.
|
||||
func (_u *UserUpdateOne) SetNillableFirstName(v *string) *UserUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetFirstName(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// ClearFirstName clears the value of the "first_name" field.
|
||||
func (_u *UserUpdateOne) ClearFirstName() *UserUpdateOne {
|
||||
_u.mutation.ClearFirstName()
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetLastName sets the "last_name" field.
|
||||
func (_u *UserUpdateOne) SetLastName(v string) *UserUpdateOne {
|
||||
_u.mutation.SetLastName(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableLastName sets the "last_name" field if the given value is not nil.
|
||||
func (_u *UserUpdateOne) SetNillableLastName(v *string) *UserUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetLastName(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// ClearLastName clears the value of the "last_name" field.
|
||||
func (_u *UserUpdateOne) ClearLastName() *UserUpdateOne {
|
||||
_u.mutation.ClearLastName()
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetPasswordHash sets the "password_hash" field.
|
||||
func (_u *UserUpdateOne) SetPasswordHash(v string) *UserUpdateOne {
|
||||
_u.mutation.SetPasswordHash(v)
|
||||
@@ -300,6 +516,66 @@ func (_u *UserUpdateOne) SetNillableVerified(v *bool) *UserUpdateOne {
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetEmailVerificationToken sets the "email_verification_token" field.
|
||||
func (_u *UserUpdateOne) SetEmailVerificationToken(v string) *UserUpdateOne {
|
||||
_u.mutation.SetEmailVerificationToken(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableEmailVerificationToken sets the "email_verification_token" field if the given value is not nil.
|
||||
func (_u *UserUpdateOne) SetNillableEmailVerificationToken(v *string) *UserUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetEmailVerificationToken(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// ClearEmailVerificationToken clears the value of the "email_verification_token" field.
|
||||
func (_u *UserUpdateOne) ClearEmailVerificationToken() *UserUpdateOne {
|
||||
_u.mutation.ClearEmailVerificationToken()
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetPasswordResetToken sets the "password_reset_token" field.
|
||||
func (_u *UserUpdateOne) SetPasswordResetToken(v string) *UserUpdateOne {
|
||||
_u.mutation.SetPasswordResetToken(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillablePasswordResetToken sets the "password_reset_token" field if the given value is not nil.
|
||||
func (_u *UserUpdateOne) SetNillablePasswordResetToken(v *string) *UserUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetPasswordResetToken(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// ClearPasswordResetToken clears the value of the "password_reset_token" field.
|
||||
func (_u *UserUpdateOne) ClearPasswordResetToken() *UserUpdateOne {
|
||||
_u.mutation.ClearPasswordResetToken()
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetPasswordResetExpiresAt sets the "password_reset_expires_at" field.
|
||||
func (_u *UserUpdateOne) SetPasswordResetExpiresAt(v time.Time) *UserUpdateOne {
|
||||
_u.mutation.SetPasswordResetExpiresAt(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillablePasswordResetExpiresAt sets the "password_reset_expires_at" field if the given value is not nil.
|
||||
func (_u *UserUpdateOne) SetNillablePasswordResetExpiresAt(v *time.Time) *UserUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetPasswordResetExpiresAt(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// ClearPasswordResetExpiresAt clears the value of the "password_reset_expires_at" field.
|
||||
func (_u *UserUpdateOne) ClearPasswordResetExpiresAt() *UserUpdateOne {
|
||||
_u.mutation.ClearPasswordResetExpiresAt()
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetUpdatedAt sets the "updated_at" field.
|
||||
func (_u *UserUpdateOne) SetUpdatedAt(v time.Time) *UserUpdateOne {
|
||||
_u.mutation.SetUpdatedAt(v)
|
||||
@@ -443,12 +719,48 @@ func (_u *UserUpdateOne) sqlSave(ctx context.Context) (_node *User, err error) {
|
||||
if value, ok := _u.mutation.Email(); ok {
|
||||
_spec.SetField(user.FieldEmail, field.TypeString, value)
|
||||
}
|
||||
if value, ok := _u.mutation.Username(); ok {
|
||||
_spec.SetField(user.FieldUsername, field.TypeString, value)
|
||||
}
|
||||
if _u.mutation.UsernameCleared() {
|
||||
_spec.ClearField(user.FieldUsername, field.TypeString)
|
||||
}
|
||||
if value, ok := _u.mutation.FirstName(); ok {
|
||||
_spec.SetField(user.FieldFirstName, field.TypeString, value)
|
||||
}
|
||||
if _u.mutation.FirstNameCleared() {
|
||||
_spec.ClearField(user.FieldFirstName, field.TypeString)
|
||||
}
|
||||
if value, ok := _u.mutation.LastName(); ok {
|
||||
_spec.SetField(user.FieldLastName, field.TypeString, value)
|
||||
}
|
||||
if _u.mutation.LastNameCleared() {
|
||||
_spec.ClearField(user.FieldLastName, field.TypeString)
|
||||
}
|
||||
if value, ok := _u.mutation.PasswordHash(); ok {
|
||||
_spec.SetField(user.FieldPasswordHash, field.TypeString, value)
|
||||
}
|
||||
if value, ok := _u.mutation.Verified(); ok {
|
||||
_spec.SetField(user.FieldVerified, field.TypeBool, value)
|
||||
}
|
||||
if value, ok := _u.mutation.EmailVerificationToken(); ok {
|
||||
_spec.SetField(user.FieldEmailVerificationToken, field.TypeString, value)
|
||||
}
|
||||
if _u.mutation.EmailVerificationTokenCleared() {
|
||||
_spec.ClearField(user.FieldEmailVerificationToken, field.TypeString)
|
||||
}
|
||||
if value, ok := _u.mutation.PasswordResetToken(); ok {
|
||||
_spec.SetField(user.FieldPasswordResetToken, field.TypeString, value)
|
||||
}
|
||||
if _u.mutation.PasswordResetTokenCleared() {
|
||||
_spec.ClearField(user.FieldPasswordResetToken, field.TypeString)
|
||||
}
|
||||
if value, ok := _u.mutation.PasswordResetExpiresAt(); ok {
|
||||
_spec.SetField(user.FieldPasswordResetExpiresAt, field.TypeTime, value)
|
||||
}
|
||||
if _u.mutation.PasswordResetExpiresAtCleared() {
|
||||
_spec.ClearField(user.FieldPasswordResetExpiresAt, field.TypeTime)
|
||||
}
|
||||
if value, ok := _u.mutation.UpdatedAt(); ok {
|
||||
_spec.SetField(user.FieldUpdatedAt, field.TypeTime, value)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user