Browse Source

Fixes

master
parent
commit
3ce516bfe6
Signed by: chris GPG Key ID: 3025DCBD46F81C0F
  1. 2
      cmd/gateway/main.go
  2. 13
      flake.nix
  3. 2
      gateway/gateway.go

2
cmd/gateway/main.go

@ -37,7 +37,7 @@ func main() {
http.HandleFunc("/register", gateway.Register(client)) http.HandleFunc("/register", gateway.Register(client))
http.HandleFunc("/login", gateway.Login(client)) http.HandleFunc("/login", gateway.Login(client))
http.HandleFunc("/authorize", gateway.Authorize(client, serverSecret)) 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)) http.HandleFunc("/change_password", gateway.ChangePassword(client))
// Listen for requests. // Listen for requests.

13
flake.nix

@ -8,6 +8,7 @@
outputs = inputs @ { self, nixpkgs, ... }: outputs = inputs @ { self, nixpkgs, ... }:
inputs.flake-utils.lib.eachDefaultSystem (system: inputs.flake-utils.lib.eachDefaultSystem (system:
let pkgs = nixpkgs.legacyPackages.${system}; let pkgs = nixpkgs.legacyPackages.${system};
myGo = "${pkgs.go}/bin/go";
myProtoc = "${pkgs.grpc-tools}/bin/protoc"; myProtoc = "${pkgs.grpc-tools}/bin/protoc";
myUsersDir = "$MY_USERS_DIR"; myUsersDir = "$MY_USERS_DIR";
myUsersBuild = pkgs.writeShellScriptBin "users-build" '' myUsersBuild = pkgs.writeShellScriptBin "users-build" ''
@ -16,6 +17,13 @@
--go_out=. --go_opt=paths=source_relative \ --go_out=. --go_opt=paths=source_relative \
--go-grpc_out=. --go-grpc_opt=paths=source_relative \ --go-grpc_out=. --go-grpc_opt=paths=source_relative \
proto/users.proto && 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 popd > /dev/null
''; '';
in in
@ -33,10 +41,15 @@
grpc-tools grpc-tools
myUsersBuild myUsersBuild
myUsersTest
]; ];
shellHook = '' shellHook = ''
export MY_USERS_DIR="$(pwd)" 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
''; '';
}; };
} }

2
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) { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
res, err := client.ResetPassword(r.Context(), &proto.ResetPasswordRequest{ res, err := client.ResetPassword(r.Context(), &proto.ResetPasswordRequest{
Form: &proto.UserForm{ Form: &proto.UserForm{

Loading…
Cancel
Save