feat: complete registration invitation and auth redesign
This commit is contained in:
+3
-10
@@ -27,7 +27,7 @@ func genDb(data *Data, p2pDel bool, tenantID types.TenantID) {
|
||||
|
||||
// Add authentication record
|
||||
authHandler := store.Store.GetAuthHandler("basic")
|
||||
authHandler.Init([]byte(`{"add_to_tags": true}`), "basic")
|
||||
authHandler.Init([]byte(`{"add_to_tags": false}`), "basic")
|
||||
|
||||
nameIndex := make(map[string]string, len(data.Users))
|
||||
|
||||
@@ -40,12 +40,13 @@ func genDb(data *Data, p2pDel bool, tenantID types.TenantID) {
|
||||
}
|
||||
user := types.User{
|
||||
TenantID: tenantID,
|
||||
Username: uu.Username,
|
||||
Phone: uu.Tel,
|
||||
State: state,
|
||||
Access: types.DefaultAccess{
|
||||
Auth: types.ModeCAuth,
|
||||
Anon: types.ModeNone,
|
||||
},
|
||||
Tags: uu.Tags,
|
||||
Public: parsePublic(&uu.Public, data.datapath),
|
||||
}
|
||||
if !uu.Trusted.IsZero() {
|
||||
@@ -53,14 +54,6 @@ func genDb(data *Data, p2pDel bool, tenantID types.TenantID) {
|
||||
}
|
||||
user.CreatedAt = getCreatedTime(uu.CreatedAt)
|
||||
|
||||
user.Tags = append(user.Tags, "basic:"+uu.Username)
|
||||
if uu.Email != "" {
|
||||
user.Tags = append(user.Tags, "email:"+uu.Email)
|
||||
}
|
||||
if uu.Tel != "" {
|
||||
user.Tags = append(user.Tags, "tel:"+uu.Tel)
|
||||
}
|
||||
|
||||
// store.Users.Create will subscribe user to !me topic but won't create a !me topic
|
||||
if _, err := store.Users.Create(tenantID, &user, uu.Private); err != nil {
|
||||
log.Fatal(err)
|
||||
|
||||
+3
-3
@@ -321,17 +321,17 @@ func main() {
|
||||
if userId.IsZero() {
|
||||
log.Fatalf("Must specify a valid user ID '%s' to promote to ROOT", *makeRoot)
|
||||
}
|
||||
login, _, _, _, err := store.Users.GetAuthRecord(tenantID, userId, "basic")
|
||||
login, _, _, _, err := store.Users.GetAuthRecord(tenantID, userId)
|
||||
if err != nil {
|
||||
log.Fatalln("Failed to read user authentication record", err)
|
||||
}
|
||||
tenantAdapter, ok := adapter.(interface {
|
||||
TenantAuthUpdRecord(types.TenantID, types.Uid, string, string, auth.Level, []byte, time.Time) error
|
||||
TenantAuthUpdateRecord(types.TenantID, types.Uid, string, auth.Level, []byte, time.Time) error
|
||||
})
|
||||
if !ok {
|
||||
log.Fatalln("Configured adapter does not support tenant authentication")
|
||||
}
|
||||
if err = tenantAdapter.TenantAuthUpdRecord(tenantID, userId, "basic", "basic:"+login,
|
||||
if err = tenantAdapter.TenantAuthUpdateRecord(tenantID, userId, login,
|
||||
auth.LevelRoot, nil, time.Time{}); err != nil {
|
||||
log.Fatalln("Failed to promote user to ROOT", err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user