Default user group

This commit is contained in:
LittleSheep 2024-07-24 17:33:05 +08:00
parent f113719e79
commit 7737d9fd08
3 changed files with 12 additions and 19 deletions

View File

@ -4,15 +4,10 @@
<option name="autoReloadType" value="ALL" /> <option name="autoReloadType" value="ALL" />
</component> </component>
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="3fefb2c4-b6f9-466b-a523-53352e8d6f95" name="更改" comment=":bug: Fix push notification to wrong person"> <list default="true" id="3fefb2c4-b6f9-466b-a523-53352e8d6f95" name="更改" comment=":sparkles: Account groups">
<change afterPath="$PROJECT_DIR$/pkg/internal/models/account_groups.go" afterDir="false" />
<change afterPath="$PROJECT_DIR$/pkg/internal/services/account_groups.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/dataSources/74bcf3ef-a2b9-435b-b9e5-f32902a33b25.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/dataSources/74bcf3ef-a2b9-435b-b9e5-f32902a33b25.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/dataSources/74bcf3ef-a2b9-435b-b9e5-f32902a33b25/storage_v2/_src_/database/hy_passport.gNOKQQ/schema/public.abK9xQ.meta" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/dataSources/74bcf3ef-a2b9-435b-b9e5-f32902a33b25/storage_v2/_src_/database/hy_passport.gNOKQQ/schema/public.abK9xQ.meta" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/internal/database/migrator.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/database/migrator.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/internal/services/accounts.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/services/accounts.go" afterDir="false" /> <change beforePath="$PROJECT_DIR$/pkg/internal/services/accounts.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/services/accounts.go" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pkg/internal/services/auth.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/services/auth.go" afterDir="false" /> <change beforePath="$PROJECT_DIR$/settings.toml" beforeDir="false" afterPath="$PROJECT_DIR$/settings.toml" afterDir="false" />
</list> </list>
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" /> <option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -159,7 +154,6 @@
</option> </option>
</component> </component>
<component name="VcsManagerConfiguration"> <component name="VcsManagerConfiguration">
<MESSAGE value=":bug: Fix request body validation" />
<MESSAGE value=":bug: Fix API mapping issue" /> <MESSAGE value=":bug: Fix API mapping issue" />
<MESSAGE value=":recycle: Improve notify API" /> <MESSAGE value=":recycle: Improve notify API" />
<MESSAGE value=":sparkles: Reset password APIs" /> <MESSAGE value=":sparkles: Reset password APIs" />
@ -184,7 +178,8 @@
<MESSAGE value=":sparkles: Support stream controller event emit" /> <MESSAGE value=":sparkles: Support stream controller event emit" />
<MESSAGE value=":recycle: Use dealer postman instead of built-in feature to deliver email and notify" /> <MESSAGE value=":recycle: Use dealer postman instead of built-in feature to deliver email and notify" />
<MESSAGE value=":bug: Fix push notification to wrong person" /> <MESSAGE value=":bug: Fix push notification to wrong person" />
<option name="LAST_COMMIT_MESSAGE" value=":bug: Fix push notification to wrong person" /> <MESSAGE value=":sparkles: Account groups" />
<option name="LAST_COMMIT_MESSAGE" value=":sparkles: Account groups" />
</component> </component>
<component name="VgoProject"> <component name="VgoProject">
<settings-migrated>true</settings-migrated> <settings-migrated>true</settings-migrated>

View File

@ -90,12 +90,17 @@ func CreateAccount(name, nick, email, password string) (models.Account, error) {
VerifiedAt: nil, VerifiedAt: nil,
}, },
}, },
PermNodes: datatypes.JSONMap(viper.GetStringMap("permissions.default")), PermNodes: datatypes.JSONMap{},
ConfirmedAt: nil, ConfirmedAt: nil,
} }
if err := database.C.Create(&user).Error; err != nil { if err := database.C.Create(&user).Error; err != nil {
return user, err return user, err
} else if viper.GetInt("default_user_group") > 0 {
database.C.Create(&models.AccountGroupMember{
AccountID: user.ID,
GroupID: uint(viper.GetInt("default_user_group")),
})
} }
if tk, err := NewMagicToken(models.ConfirmMagicToken, &user, nil); err != nil { if tk, err := NewMagicToken(models.ConfirmMagicToken, &user, nil); err != nil {

View File

@ -9,6 +9,8 @@ domain = "localhost"
content_endpoint = "https://usercontent.solsynth.dev" content_endpoint = "https://usercontent.solsynth.dev"
default_user_group = 1
use_registration_magic_token = false use_registration_magic_token = false
[debug] [debug]
@ -27,12 +29,3 @@ refresh_token_duration = 2592000
[database] [database]
dsn = "host=localhost user=postgres password=password dbname=hy_passport port=5432 sslmode=disable" dsn = "host=localhost user=postgres password=password dbname=hy_passport port=5432 sslmode=disable"
prefix = "passport_" prefix = "passport_"
[permissions.default]
CreatePosts = true
CreateAttachments = 1048576
[permissions.verified]
CreateRealms = true
CreateArticles = true
CreateAttachments = 26214400