This commit is contained in:
parent
7fcc39be60
commit
e10eadb1e0
|
@ -69,6 +69,7 @@ type conf struct {
|
|||
WD string // current working direcitory, ${pwd}
|
||||
Locale string // default locale
|
||||
Playground string // playground directory
|
||||
AllowRegister bool // allow register or not
|
||||
}
|
||||
|
||||
// Logger.
|
||||
|
|
|
@ -12,5 +12,6 @@
|
|||
"RuntimeMode": "dev",
|
||||
"WD": "${pwd}",
|
||||
"Locale": "en_US",
|
||||
"Playground": "${home}/playground"
|
||||
"Playground": "${home}/playground",
|
||||
"AllowRegister": true
|
||||
}
|
|
@ -41,6 +41,7 @@ const (
|
|||
emailExists = "email exists"
|
||||
userCreated = "user created"
|
||||
userCreateError = "user create error"
|
||||
notAllowRegister = "not allow register"
|
||||
)
|
||||
|
||||
// Exclusive lock for adding user.
|
||||
|
@ -334,12 +335,16 @@ func getOnlineUsers() []*conf.User {
|
|||
// addUser add a user with the specified username, password and email.
|
||||
//
|
||||
// 1. create the user's workspace
|
||||
// 2. generate 'Hello, 世界' demo code in the workspace (a console version and a http version)
|
||||
// 2. generate 'Hello, 世界' demo code in the workspace (a console version and a HTTP version)
|
||||
// 3. update the user customized configurations, such as style.css
|
||||
// 4. serve files of the user's workspace via HTTP
|
||||
//
|
||||
// Note: user [playground] is a reserved mock user
|
||||
func addUser(username, password, email string) string {
|
||||
if !conf.Wide.AllowRegister {
|
||||
return notAllowRegister
|
||||
}
|
||||
|
||||
if "playground" == username {
|
||||
return userExists
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue