Skip to content

Commit

Permalink
Merge branch 'master' into tag-search
Browse files Browse the repository at this point in the history
  • Loading branch information
InfiniteStash committed Sep 1, 2024
2 parents c0d0774 + 84bd28f commit 3a14934
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 6 deletions.
6 changes: 3 additions & 3 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
7 changes: 6 additions & 1 deletion frontend/src/Login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<ContextType>(AuthContext);
const {
register,
Expand All @@ -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");
};

Expand Down
6 changes: 5 additions & 1 deletion frontend/src/Main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,11 @@ const Main: FC<Props> = ({ 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]);

Expand Down
1 change: 1 addition & 0 deletions pkg/api/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ func makeTLSConfig() *tls.Config {
}
tlsConfig := &tls.Config{
Certificates: certs,
MinVersion: tls.VersionTLS13,
}

return tlsConfig
Expand Down
2 changes: 1 addition & 1 deletion pkg/models/sql_translate.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit 3a14934

Please sign in to comment.