diff --git a/conf/wide.go b/conf/wide.go index e139b03..7be32f9 100644 --- a/conf/wide.go +++ b/conf/wide.go @@ -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. diff --git a/conf/wide.json b/conf/wide.json index ca3e10b..9ac29b1 100644 --- a/conf/wide.json +++ b/conf/wide.json @@ -12,5 +12,6 @@ "RuntimeMode": "dev", "WD": "${pwd}", "Locale": "en_US", - "Playground": "${home}/playground" + "Playground": "${home}/playground", + "AllowRegister": true } \ No newline at end of file diff --git a/session/users.go b/session/users.go index 6b3be70..959e646 100644 --- a/session/users.go +++ b/session/users.go @@ -37,10 +37,11 @@ import ( const ( // TODO: i18n - userExists = "user exists" - emailExists = "email exists" - userCreated = "user created" - userCreateError = "user create error" + userExists = "user exists" + 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 }