preference apply; user signup bug fix
This commit is contained in:
parent
7218eef212
commit
24908aa309
|
@ -23,6 +23,7 @@ import (
|
|||
"runtime"
|
||||
"strconv"
|
||||
"text/template"
|
||||
"sync"
|
||||
|
||||
"github.com/b3log/wide/conf"
|
||||
"github.com/b3log/wide/i18n"
|
||||
|
@ -36,6 +37,9 @@ const (
|
|||
UserCreateError = "user create error"
|
||||
)
|
||||
|
||||
// Exclusive lock for adding user.
|
||||
var addUserMutex sync.Mutex
|
||||
|
||||
// PreferenceHandle handles request of preference page.
|
||||
func PreferenceHandler(w http.ResponseWriter, r *http.Request) {
|
||||
httpSession, _ := HTTPSession.Get(r, "wide-session")
|
||||
|
@ -106,6 +110,8 @@ func PreferenceHandler(w http.ResponseWriter, r *http.Request) {
|
|||
user.Password = args.Password
|
||||
user.Locale = args.Locale
|
||||
|
||||
conf.UpdateCustomizedConf(username)
|
||||
|
||||
succ = conf.Save()
|
||||
}
|
||||
|
||||
|
@ -241,6 +247,9 @@ func SignUpUser(w http.ResponseWriter, r *http.Request) {
|
|||
// 3. update the user customized configurations, such as style.css
|
||||
// 4. serve files of the user's workspace via HTTP
|
||||
func addUser(username, password string) string {
|
||||
addUserMutex.Lock()
|
||||
defer addUserMutex.Unlock()
|
||||
|
||||
for _, user := range conf.Wide.Users {
|
||||
if user.Name == username {
|
||||
return UserExists
|
||||
|
|
Loading…
Reference in New Issue