Compare commits
3 commits
a9af73b557
...
c1611114d0
Author | SHA1 | Date | |
---|---|---|---|
c1611114d0 | |||
4c8ebaeab8 | |||
1e59c661c7 |
4 changed files with 13 additions and 2 deletions
|
@ -13,6 +13,8 @@
|
|||
use `hlog.FromRequest` to get a logger instance prepared with a bunch of metadata
|
||||
- As Linstrom is both intended for active use as well as providing a learning resource,
|
||||
all functions and structs must be documented
|
||||
- Errors returned from public functions must be wrapped with `git.mstar.dev/mstar/goutils/other.Error`
|
||||
and given appropriate descriptive information
|
||||
|
||||
## JS/TS
|
||||
|
||||
|
|
|
@ -4,9 +4,9 @@ import (
|
|||
"fmt"
|
||||
"os"
|
||||
|
||||
"git.mstar.dev/mstar/goutils/other"
|
||||
"github.com/BurntSushi/toml"
|
||||
"github.com/rs/zerolog/log"
|
||||
"git.mstar.dev/mstar/goutils/other"
|
||||
)
|
||||
|
||||
type ConfigSSL struct {
|
||||
|
@ -68,6 +68,9 @@ type ConfigStorage struct {
|
|||
MaxInMemoryCacheTTL int `toml:"max_in_memory_cache_ttl"`
|
||||
// The time to live for items in redis, in seconds
|
||||
MaxRedisCacheTTL *int `toml:"max_redis_cache_ttl"`
|
||||
// Key used for encrypting sensitive information in the db
|
||||
// DO NOT CHANGE THIS AFTER SETUP
|
||||
EncryptionKey string `toml:"encryption_key"`
|
||||
}
|
||||
|
||||
type ConfigS3 struct {
|
||||
|
@ -145,6 +148,7 @@ var defaultConfig Config = Config{
|
|||
MaxInMemoryCacheSize: 1e6, // 1 Megabyte
|
||||
MaxInMemoryCacheTTL: 5,
|
||||
MaxRedisCacheTTL: nil,
|
||||
EncryptionKey: "Encryption key for sensitive information. DO NOT CHANGE THIS AFTER SETUP",
|
||||
},
|
||||
Mail: ConfigMail{
|
||||
Host: "localhost",
|
||||
|
|
|
@ -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
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -13,4 +13,5 @@ type UserAuthMethod struct {
|
|||
UserId string
|
||||
AuthMethod AuthenticationMethodType `gorm:"type:auth_method_type"`
|
||||
Token []byte
|
||||
Name string
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue