team code review
Этот коммит содержится в:
@@ -84,6 +84,7 @@ func (h handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||||||
if forwardProto == "http" {
|
if forwardProto == "http" {
|
||||||
l4g.Info("redirecting http request to https for %v", r.URL.Path)
|
l4g.Info("redirecting http request to https for %v", r.URL.Path)
|
||||||
http.Redirect(w, r, "https://"+r.Host, http.StatusTemporaryRedirect)
|
http.Redirect(w, r, "https://"+r.Host, http.StatusTemporaryRedirect)
|
||||||
|
return
|
||||||
} else {
|
} else {
|
||||||
protocol = "https"
|
protocol = "https"
|
||||||
}
|
}
|
||||||
|
|||||||
11
api/user.go
11
api/user.go
@@ -289,7 +289,7 @@ func login(c *Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
if !model.ComparePassword(user.Password, props["password"]) {
|
if !model.ComparePassword(user.Password, props["password"]) {
|
||||||
c.LogAuditWithUserId(user.Id, "fail")
|
c.LogAuditWithUserId(user.Id, "fail")
|
||||||
c.Err = model.NewAppError("login", "Login failed because of invalid password", extraInfo)
|
c.Err = model.NewAppError("login", "Login failed because of invalid password", extraInfo)
|
||||||
c.Err.StatusCode = http.StatusBadRequest
|
c.Err.StatusCode = http.StatusForbidden
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -417,7 +417,7 @@ func getSessions(c *Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
params := mux.Vars(r)
|
params := mux.Vars(r)
|
||||||
id := params["id"]
|
id := params["id"]
|
||||||
|
|
||||||
if !c.HasPermissionsToUser(id, "getAudits") {
|
if !c.HasPermissionsToUser(id, "getSessions") {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -740,7 +740,7 @@ func updateUser(c *Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if !c.HasPermissionsToUser(user.Id, "updateUsers") {
|
if !c.HasPermissionsToUser(user.Id, "updateUser") {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -813,12 +813,13 @@ func updatePassword(c *Context, w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
if !model.ComparePassword(user.Password, currentPassword) {
|
if !model.ComparePassword(user.Password, currentPassword) {
|
||||||
c.Err = model.NewAppError("updatePassword", "Update password failed because of invalid password", "")
|
c.Err = model.NewAppError("updatePassword", "Update password failed because of invalid password", "")
|
||||||
c.Err.StatusCode = http.StatusBadRequest
|
c.Err.StatusCode = http.StatusForbidden
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if uresult := <-Srv.Store.User().UpdatePassword(c.Session.UserId, model.HashPassword(newPassword)); uresult.Err != nil {
|
if uresult := <-Srv.Store.User().UpdatePassword(c.Session.UserId, model.HashPassword(newPassword)); uresult.Err != nil {
|
||||||
c.Err = uresult.Err
|
c.Err = model.NewAppError("updatePassword", "Update password failed", uresult.Err.Error())
|
||||||
|
c.Err.StatusCode = http.StatusForbidden
|
||||||
return
|
return
|
||||||
} else {
|
} else {
|
||||||
c.LogAudit("completed")
|
c.LogAudit("completed")
|
||||||
|
|||||||
@@ -198,7 +198,7 @@ func (u *User) Sanitize(options map[string]bool) {
|
|||||||
if len(options) != 0 && !options["phonenumber"] {
|
if len(options) != 0 && !options["phonenumber"] {
|
||||||
// TODO - fill in when PhoneNumber is added to user model
|
// TODO - fill in when PhoneNumber is added to user model
|
||||||
}
|
}
|
||||||
if len(options) != 0 && !options["passwordupadte"] {
|
if len(options) != 0 && !options["passwordupdate"] {
|
||||||
u.LastPasswordUpdate = 0
|
u.LastPasswordUpdate = 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ func (us SqlUserStore) Save(user *model.User) StoreChannel {
|
|||||||
return storeChannel
|
return storeChannel
|
||||||
}
|
}
|
||||||
|
|
||||||
func (us SqlUserStore) Update(user *model.User, allowRoleActiveUpdate bool) StoreChannel {
|
func (us SqlUserStore) Update(user *model.User, allowActiveUpdate bool) StoreChannel {
|
||||||
|
|
||||||
storeChannel := make(StoreChannel)
|
storeChannel := make(StoreChannel)
|
||||||
|
|
||||||
@@ -125,7 +125,7 @@ func (us SqlUserStore) Update(user *model.User, allowRoleActiveUpdate bool) Stor
|
|||||||
user.LastPingAt = oldUser.LastPingAt
|
user.LastPingAt = oldUser.LastPingAt
|
||||||
user.EmailVerified = oldUser.EmailVerified
|
user.EmailVerified = oldUser.EmailVerified
|
||||||
|
|
||||||
if !allowRoleActiveUpdate {
|
if !allowActiveUpdate {
|
||||||
user.Roles = oldUser.Roles
|
user.Roles = oldUser.Roles
|
||||||
user.DeleteAt = oldUser.DeleteAt
|
user.DeleteAt = oldUser.DeleteAt
|
||||||
}
|
}
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user