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