From 3ce516bfe6b07f339af9bab76ac4011a7f007bec Mon Sep 17 00:00:00 2001 From: Christopher James Hayward Date: Sat, 1 Jul 2023 14:46:22 -0400 Subject: [PATCH] Fixes --- cmd/gateway/main.go | 2 +- flake.nix | 13 +++++++++++++ gateway/gateway.go | 2 +- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/cmd/gateway/main.go b/cmd/gateway/main.go index 2b34553..7aa627a 100644 --- a/cmd/gateway/main.go +++ b/cmd/gateway/main.go @@ -37,7 +37,7 @@ func main() { http.HandleFunc("/register", gateway.Register(client)) http.HandleFunc("/login", gateway.Login(client)) http.HandleFunc("/authorize", gateway.Authorize(client, serverSecret)) - http.HandleFunc("/reset_password", gateway.ResetPassword(client)) + http.HandleFunc("/reset_password", gateway.ResetPassword(client, port)) http.HandleFunc("/change_password", gateway.ChangePassword(client)) // Listen for requests. diff --git a/flake.nix b/flake.nix index d71be06..b322b1c 100644 --- a/flake.nix +++ b/flake.nix @@ -8,6 +8,7 @@ outputs = inputs @ { self, nixpkgs, ... }: inputs.flake-utils.lib.eachDefaultSystem (system: let pkgs = nixpkgs.legacyPackages.${system}; + myGo = "${pkgs.go}/bin/go"; myProtoc = "${pkgs.grpc-tools}/bin/protoc"; myUsersDir = "$MY_USERS_DIR"; myUsersBuild = pkgs.writeShellScriptBin "users-build" '' @@ -16,6 +17,13 @@ --go_out=. --go_opt=paths=source_relative \ --go-grpc_out=. --go-grpc_opt=paths=source_relative \ proto/users.proto && + ${myGo} build -o ${myUsersDir}/bin/users-server ${myUsersDir}/cmd/server/main.go && + ${myGo} build -o ${myUsersDir}/bin/users-gateway ${myUsersDir}/cmd/gateway/main.go && + popd > /dev/null + ''; + myUsersTest = pkgs.writeShellScriptBin "users-test" '' + pushd ${myUsersDir} > /dev/null && + ${pkgs.parallel}/bin/parallel :: ${myUsersDir}/bin/users-server ${myUsersDir}/bin/users-gateway popd > /dev/null ''; in @@ -33,10 +41,15 @@ grpc-tools myUsersBuild + myUsersTest ]; shellHook = '' export MY_USERS_DIR="$(pwd)" + export GO111MODULE=on + export GOPATH=$XDG_DATA_HOME/go + export PATH=$GOPATH/bin:$PATH + export PATH=$MY_USERS_DIR/bin:$PATH ''; }; } diff --git a/gateway/gateway.go b/gateway/gateway.go index 0ba5fdf..ab17126 100644 --- a/gateway/gateway.go +++ b/gateway/gateway.go @@ -71,7 +71,7 @@ func Authorize(client proto.UsersClient, serverSecret *string) http.HandlerFunc }) } -func ResetPassword(client proto.UsersClient) http.HandlerFunc { +func ResetPassword(client proto.UsersClient, port *int) http.HandlerFunc { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { res, err := client.ResetPassword(r.Context(), &proto.ResetPasswordRequest{ Form: &proto.UserForm{