fix some lint errors
This commit is contained in:
@@ -132,6 +132,7 @@ type Response struct {
|
|||||||
err string
|
err string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//nolint:gocognit
|
||||||
func (c *Controller) H(h adminHandler) http.Handler {
|
func (c *Controller) H(h adminHandler) http.Handler {
|
||||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
resp := h(r)
|
resp := h(r)
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ func TestFirstExisting(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
for _, tc := range cases {
|
for _, tc := range cases {
|
||||||
|
tc := tc // pin
|
||||||
t.Run(tc.name, func(t *testing.T) {
|
t.Run(tc.name, func(t *testing.T) {
|
||||||
actu := firstExisting(tc.or, tc.values...)
|
actu := firstExisting(tc.or, tc.values...)
|
||||||
if actu != tc.exp {
|
if actu != tc.exp {
|
||||||
|
|||||||
@@ -73,8 +73,7 @@ func (c *Controller) ServeChangeOwnPassword(r *http.Request) *Response {
|
|||||||
func (c *Controller) ServeChangeOwnPasswordDo(r *http.Request) *Response {
|
func (c *Controller) ServeChangeOwnPasswordDo(r *http.Request) *Response {
|
||||||
passwordOne := r.FormValue("password_one")
|
passwordOne := r.FormValue("password_one")
|
||||||
passwordTwo := r.FormValue("password_two")
|
passwordTwo := r.FormValue("password_two")
|
||||||
err := validatePasswords(passwordOne, passwordTwo)
|
if err := validatePasswords(passwordOne, passwordTwo); err != nil {
|
||||||
if err != nil {
|
|
||||||
return &Response{
|
return &Response{
|
||||||
redirect: r.Referer(),
|
redirect: r.Referer(),
|
||||||
flashW: []string{err.Error()},
|
flashW: []string{err.Error()},
|
||||||
@@ -145,8 +144,7 @@ func (c *Controller) ServeChangePasswordDo(r *http.Request) *Response {
|
|||||||
username := r.URL.Query().Get("user")
|
username := r.URL.Query().Get("user")
|
||||||
passwordOne := r.FormValue("password_one")
|
passwordOne := r.FormValue("password_one")
|
||||||
passwordTwo := r.FormValue("password_two")
|
passwordTwo := r.FormValue("password_two")
|
||||||
err := validatePasswords(passwordOne, passwordTwo)
|
if err := validatePasswords(passwordOne, passwordTwo); err != nil {
|
||||||
if err != nil {
|
|
||||||
return &Response{
|
return &Response{
|
||||||
redirect: r.Referer(),
|
redirect: r.Referer(),
|
||||||
flashW: []string{err.Error()},
|
flashW: []string{err.Error()},
|
||||||
@@ -220,8 +218,7 @@ func (c *Controller) ServeCreateUserDo(r *http.Request) *Response {
|
|||||||
Name: username,
|
Name: username,
|
||||||
Password: passwordOne,
|
Password: passwordOne,
|
||||||
}
|
}
|
||||||
err = c.DB.Create(&user).Error
|
if err := c.DB.Create(&user).Error; err != nil {
|
||||||
if err != nil {
|
|
||||||
return &Response{
|
return &Response{
|
||||||
redirect: r.Referer(),
|
redirect: r.Referer(),
|
||||||
flashW: []string{fmt.Sprintf("could not create user `%s`: %v", username, err)},
|
flashW: []string{fmt.Sprintf("could not create user `%s`: %v", username, err)},
|
||||||
|
|||||||
Reference in New Issue
Block a user