Skip to content

Commit 424f7fa

Browse files
committed
take flash error message back and fix more windows lint error
1 parent 4f4468f commit 424f7fa

File tree

4 files changed

+11
-23
lines changed

4 files changed

+11
-23
lines changed

.drone.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ steps:
2828
image: golang:1.15
2929
commands:
3030
- make lint-backend
31+
- GOOS=windows make golangci-lint vet
3132
environment:
3233
GOPROXY: https://goproxy.cn # proxy.golang.org is blocked in China, this proxy is not
3334
GOSUMDB: sum.golang.org

modules/auth/sso/sspi_windows.go

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@
55
package sso
66

77
import (
8-
"code.gitea.io/gitea/modules/templates"
98
"errors"
109
"net/http"
1110
"strings"
1211

12+
"code.gitea.io/gitea/modules/templates"
13+
1314
"code.gitea.io/gitea/models"
1415
"code.gitea.io/gitea/modules/base"
1516
"code.gitea.io/gitea/modules/log"
@@ -82,7 +83,9 @@ func (s *SSPI) VerifyAuthData(req *http.Request, w http.ResponseWriter, store Da
8283
// Include the user login page in the 401 response to allow the user
8384
// to login with another authentication method if SSPI authentication
8485
// fails
85-
//addFlashErr(ctx, ctx.Tr("auth.sspi_auth_failed"))
86+
store.GetData()["Flash"] = map[string]string{
87+
"ErrMsg": err.Error(),
88+
}
8689

8790
store.GetData()["EnableOpenIDSignIn"] = setting.Service.EnableOpenIDSignIn
8891
store.GetData()["EnableSSPI"] = true
@@ -229,24 +232,6 @@ func sanitizeUsername(username string, cfg *models.SSPIConfig) string {
229232
return username
230233
}
231234

232-
/*
233-
// TODO flash err not implemented for chi
234-
// addFlashErr adds an error message to the Flash object mapped to a macaron.Context
235-
func addFlashErr(ctx *macaron.Context, err string) {
236-
fv := ctx.GetVal(reflect.TypeOf(&session.Flash{}))
237-
if !fv.IsValid() {
238-
return
239-
}
240-
flash, ok := fv.Interface().(*session.Flash)
241-
if !ok {
242-
return
243-
}
244-
flash.Error(err)
245-
ctx.Data["Flash"] = flash
246-
}
247-
248-
*/
249-
250235
// init registers the SSPI auth method as the last method in the list.
251236
// The SSPI plugin is expected to be executed last, as it returns 401 status code if negotiation
252237
// fails (or if negotiation should continue), which would prevent other authentication methods

modules/graceful/manager_windows.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,15 +73,17 @@ func (g *Manager) start() {
7373

7474
// Make SVC process
7575
run := svc.Run
76-
isInteractive, err := svc.IsAnInteractiveSession()
76+
isInteractive, err := svc.IsWindowsService()
7777
if err != nil {
7878
log.Error("Unable to ascertain if running as an Interactive Session: %v", err)
7979
return
8080
}
8181
if isInteractive {
8282
run = debug.Run
8383
}
84-
go run(WindowsServiceName, g)
84+
go func() {
85+
_ = run(WindowsServiceName, g)
86+
}()
8587
}
8688

8789
// Execute makes Manager implement svc.Handler

modules/log/console_windows.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ func enableVTMode(console windows.Handle) bool {
2323
// https://docs.microsoft.com/en-us/windows/console/setconsolemode
2424
// It only works on windows 10. Earlier terminals will fail with an err which we will
2525
// handle to say don't color
26-
mode = mode | windows.ENABLE_VIRTUAL_TERMINAL_PROCESSING
26+
mode |= windows.ENABLE_VIRTUAL_TERMINAL_PROCESSING
2727
err = windows.SetConsoleMode(console, mode)
2828
return err == nil
2929
}

0 commit comments

Comments
 (0)