diff --git a/.golangci.yml b/.golangci.yml index fc20ef94..c0daccb9 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -14,21 +14,21 @@ linters: - govet - ineffassign - staticcheck - - typecheck - unused + - typecheck # additional - gofmt - revive - dogsled - errorlint - exhaustive - - exportloopref + - copyloopvar - gocritic - #- goerr113 - misspell - noctx - rowserrcheck - sqlclosecheck + #- err113 linters-settings: revive: diff --git a/frontend/src/Login.tsx b/frontend/src/Login.tsx index c8965eb4..2c9fdd59 100644 --- a/frontend/src/Login.tsx +++ b/frontend/src/Login.tsx @@ -29,6 +29,7 @@ const Login: FC = () => { const navigate = useNavigate(); const [loginError, setLoginError] = useState(""); const msg = new URLSearchParams(location.search).get("msg"); + const redirect = new URLSearchParams(location.search).get("redirect"); const Auth = useContext(AuthContext); const { register, @@ -42,15 +43,19 @@ const Login: FC = () => { const onSubmit = async (formData: LoginFormData) => { setLoading(true); + const body = new FormData(); body.append("username", formData.username); body.append("password", formData.password); + const res = await fetch(`${getPlatformURL()}login`, { method: "POST", body, credentials: getCredentialsSetting(), }).finally(() => setLoading(false)); - if (res.ok) window.location.replace("/"); + + const returnURL = decodeURIComponent(redirect ?? "") || "/"; + if (res.ok) window.location.replace(returnURL); else setLoginError("Access denied"); }; diff --git a/frontend/src/Main.tsx b/frontend/src/Main.tsx index 2287ea32..6377b8ba 100644 --- a/frontend/src/Main.tsx +++ b/frontend/src/Main.tsx @@ -50,7 +50,11 @@ const Main: FC = ({ children }) => { location.pathname !== ROUTE_FORGOT_PASSWORD && location.pathname !== ROUTE_RESET_PASSWORD ) { - navigate(ROUTE_LOGIN); + const redirect = + location.pathname === "/" + ? "" + : `?redirect=${encodeURIComponent(location.pathname)}`; + navigate(`${ROUTE_LOGIN}${redirect}`); } }, [loading, user, location, navigate]); diff --git a/pkg/api/server.go b/pkg/api/server.go index b2914112..8f3bbcf9 100644 --- a/pkg/api/server.go +++ b/pkg/api/server.go @@ -245,6 +245,7 @@ func makeTLSConfig() *tls.Config { } tlsConfig := &tls.Config{ Certificates: certs, + MinVersion: tls.VersionTLS13, } return tlsConfig diff --git a/pkg/models/sql_translate.go b/pkg/models/sql_translate.go index 87072186..289eb322 100644 --- a/pkg/models/sql_translate.go +++ b/pkg/models/sql_translate.go @@ -49,7 +49,7 @@ func CopyFull(target interface{}, source interface{}) { case field.Type == sourceField.Type: // direct copy targetFieldValue.Set(sourceFieldValue) - case reflect.PtrTo(field.Type) == sourceField.Type: + case reflect.PointerTo(field.Type) == sourceField.Type: // source field is pointer, target field is value // if nil, then set to zero value, otherwise copy if sourceFieldValue.IsNil() {