mirror of
https://github.com/casdoor/casdoor.git
synced 2025-05-23 10:45:47 +08:00
Improve syncer.initAdapter().
This commit is contained in:
parent
fa45d3083a
commit
f4890a6a22
@ -50,26 +50,28 @@ func initBuiltInUser() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
user = &User{
|
user = &User{
|
||||||
Owner: "built-in",
|
Owner: "built-in",
|
||||||
Name: "admin",
|
Name: "admin",
|
||||||
CreatedTime: util.GetCurrentTime(),
|
CreatedTime: util.GetCurrentTime(),
|
||||||
Id: util.GenerateId(),
|
Id: util.GenerateId(),
|
||||||
Type: "normal-user",
|
Type: "normal-user",
|
||||||
Password: "123",
|
Password: "123",
|
||||||
DisplayName: "Admin",
|
DisplayName: "Admin",
|
||||||
Avatar: "https://casbin.org/img/casbin.svg",
|
Avatar: "https://casbin.org/img/casbin.svg",
|
||||||
Email: "admin@example.com",
|
Email: "admin@example.com",
|
||||||
Phone: "12345678910",
|
Phone: "12345678910",
|
||||||
Address: []string{},
|
Address: []string{},
|
||||||
Affiliation: "Example Inc.",
|
Affiliation: "Example Inc.",
|
||||||
Tag: "staff",
|
Tag: "staff",
|
||||||
Score: 2000,
|
Score: 2000,
|
||||||
Ranking: 1,
|
Ranking: 1,
|
||||||
IsAdmin: true,
|
IsAdmin: true,
|
||||||
IsGlobalAdmin: true,
|
IsGlobalAdmin: true,
|
||||||
IsForbidden: false,
|
IsForbidden: false,
|
||||||
IsDeleted: false,
|
IsDeleted: false,
|
||||||
Properties: make(map[string]string),
|
SignupApplication: "built-in-app",
|
||||||
|
CreatedIp: "127.0.0.1",
|
||||||
|
Properties: make(map[string]string),
|
||||||
}
|
}
|
||||||
AddUser(user)
|
AddUser(user)
|
||||||
}
|
}
|
||||||
|
@ -125,6 +125,9 @@ func (syncer *Syncer) calculateHash(user *OriginalUser) string {
|
|||||||
func (syncer *Syncer) initAdapter() {
|
func (syncer *Syncer) initAdapter() {
|
||||||
if syncer.Adapter == nil {
|
if syncer.Adapter == nil {
|
||||||
dataSourceName := fmt.Sprintf("%s:%s@tcp(%s:%d)/", syncer.User, syncer.Password, syncer.Host, syncer.Port)
|
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)
|
syncer.Adapter = NewAdapter(beego.AppConfig.String("driverName"), dataSourceName, syncer.Database)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -558,3 +558,7 @@ export function getApplicationOrgName(application) {
|
|||||||
export function getRandomName() {
|
export function getRandomName() {
|
||||||
return Math.random().toString(36).slice(-6);
|
return Math.random().toString(36).slice(-6);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getRandomNumber() {
|
||||||
|
return Math.random().toString(10).slice(-11);
|
||||||
|
}
|
||||||
|
@ -70,8 +70,8 @@ class UserListPage extends React.Component {
|
|||||||
passwordSalt: "",
|
passwordSalt: "",
|
||||||
displayName: `New User - ${randomName}`,
|
displayName: `New User - ${randomName}`,
|
||||||
avatar: "https://casbin.org/img/casbin.svg",
|
avatar: "https://casbin.org/img/casbin.svg",
|
||||||
email: "user@example.com",
|
email: `${randomName}@example.com`,
|
||||||
phone: "12345678",
|
phone: Setting.getRandomNumber(),
|
||||||
address: [],
|
address: [],
|
||||||
affiliation: "Example Inc.",
|
affiliation: "Example Inc.",
|
||||||
tag: "staff",
|
tag: "staff",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user