diff --git a/object/init.go b/object/init.go index 6478753b..0a00c8dc 100644 --- a/object/init.go +++ b/object/init.go @@ -50,26 +50,28 @@ func initBuiltInUser() { } user = &User{ - Owner: "built-in", - Name: "admin", - CreatedTime: util.GetCurrentTime(), - Id: util.GenerateId(), - Type: "normal-user", - Password: "123", - DisplayName: "Admin", - Avatar: "https://casbin.org/img/casbin.svg", - Email: "admin@example.com", - Phone: "12345678910", - Address: []string{}, - Affiliation: "Example Inc.", - Tag: "staff", - Score: 2000, - Ranking: 1, - IsAdmin: true, - IsGlobalAdmin: true, - IsForbidden: false, - IsDeleted: false, - Properties: make(map[string]string), + Owner: "built-in", + Name: "admin", + CreatedTime: util.GetCurrentTime(), + Id: util.GenerateId(), + Type: "normal-user", + Password: "123", + DisplayName: "Admin", + Avatar: "https://casbin.org/img/casbin.svg", + Email: "admin@example.com", + Phone: "12345678910", + Address: []string{}, + Affiliation: "Example Inc.", + Tag: "staff", + Score: 2000, + Ranking: 1, + IsAdmin: true, + IsGlobalAdmin: true, + IsForbidden: false, + IsDeleted: false, + SignupApplication: "built-in-app", + CreatedIp: "127.0.0.1", + Properties: make(map[string]string), } AddUser(user) } diff --git a/object/syncer_user.go b/object/syncer_user.go index 475eb9dd..974511bd 100644 --- a/object/syncer_user.go +++ b/object/syncer_user.go @@ -125,6 +125,9 @@ func (syncer *Syncer) calculateHash(user *OriginalUser) string { func (syncer *Syncer) initAdapter() { if syncer.Adapter == nil { dataSourceName := fmt.Sprintf("%s:%s@tcp(%s:%d)/", syncer.User, syncer.Password, syncer.Host, syncer.Port) + if !isCloudIntranet { + dataSourceName = strings.ReplaceAll(dataSourceName, "dbi.", "db.") + } syncer.Adapter = NewAdapter(beego.AppConfig.String("driverName"), dataSourceName, syncer.Database) } } diff --git a/web/src/Setting.js b/web/src/Setting.js index 7ee66ac7..2007c33c 100644 --- a/web/src/Setting.js +++ b/web/src/Setting.js @@ -558,3 +558,7 @@ export function getApplicationOrgName(application) { export function getRandomName() { return Math.random().toString(36).slice(-6); } + +export function getRandomNumber() { + return Math.random().toString(10).slice(-11); +} diff --git a/web/src/UserListPage.js b/web/src/UserListPage.js index 4406a265..8650361b 100644 --- a/web/src/UserListPage.js +++ b/web/src/UserListPage.js @@ -70,8 +70,8 @@ class UserListPage extends React.Component { passwordSalt: "", displayName: `New User - ${randomName}`, avatar: "https://casbin.org/img/casbin.svg", - email: "user@example.com", - phone: "12345678", + email: `${randomName}@example.com`, + phone: Setting.getRandomNumber(), address: [], affiliation: "Example Inc.", tag: "staff",