Add name field to user auth entries

This commit is contained in:
Melody Becker 2025-03-31 16:42:57 +02:00
parent 1e59c661c7
commit 4c8ebaeab8
Signed by: mstar
SSH key fingerprint: SHA256:9VAo09aaVNTWKzPW7Hq2LW+ox9OdwmTSHRoD4mlz1yI
2 changed files with 6 additions and 1 deletions

View file

@ -30,6 +30,7 @@ func newUserAuthMethod(db *gorm.DB, opts ...gen.DOOption) userAuthMethod {
_userAuthMethod.UserId = field.NewString(tableName, "user_id")
_userAuthMethod.AuthMethod = field.NewField(tableName, "auth_method")
_userAuthMethod.Token = field.NewBytes(tableName, "token")
_userAuthMethod.Name = field.NewString(tableName, "name")
_userAuthMethod.User = userAuthMethodBelongsToUser{
db: db.Session(&gorm.Session{}),
@ -184,6 +185,7 @@ type userAuthMethod struct {
UserId field.String
AuthMethod field.Field
Token field.Bytes
Name field.String
User userAuthMethodBelongsToUser
fieldMap map[string]field.Expr
@ -205,6 +207,7 @@ func (u *userAuthMethod) updateTableName(table string) *userAuthMethod {
u.UserId = field.NewString(table, "user_id")
u.AuthMethod = field.NewField(table, "auth_method")
u.Token = field.NewBytes(table, "token")
u.Name = field.NewString(table, "name")
u.fillFieldMap()
@ -221,11 +224,12 @@ func (u *userAuthMethod) GetFieldByName(fieldName string) (field.OrderExpr, bool
}
func (u *userAuthMethod) fillFieldMap() {
u.fieldMap = make(map[string]field.Expr, 5)
u.fieldMap = make(map[string]field.Expr, 6)
u.fieldMap["id"] = u.ID
u.fieldMap["user_id"] = u.UserId
u.fieldMap["auth_method"] = u.AuthMethod
u.fieldMap["token"] = u.Token
u.fieldMap["name"] = u.Name
}

View file

@ -13,4 +13,5 @@ type UserAuthMethod struct {
UserId string
AuthMethod AuthenticationMethodType `gorm:"type:auth_method_type"`
Token []byte
Name string
}