From d22ad7cb09d4eb907ec8c6841c2efce47a04f6d7 Mon Sep 17 00:00:00 2001 From: Fedorov Vladimir Date: Tue, 30 Jun 2026 21:06:51 +0700 Subject: [PATCH] add refresh-password route --- api/main.proto | 15 +++ .../main.swagger.json | 48 +++++++ internal/app/server.go | 14 +- internal/repos/user.go | 6 + internal/repos/users_repo/repo.go | 31 ++++- internal/services/users_service/service.go | 31 +++++ proto/main.pb.go | 127 +++++++++++++++--- proto/main.pb.gw.go | 78 ++++++++++- proto/main_grpc.pb.go | 44 +++++- 9 files changed, 366 insertions(+), 28 deletions(-) create mode 100644 internal/repos/user.go diff --git a/api/main.proto b/api/main.proto index ae725d6..b8ab5ec 100644 --- a/api/main.proto +++ b/api/main.proto @@ -24,6 +24,13 @@ service EveningDetectiveServer { body: "*" }; } + + rpc RefreshPassword(RefreshPasswordReq) returns (RefreshPasswordRsp) { + option (google.api.http) = { + post: "/api/refresh-password" + body: "*" + }; + } } message PingReq {} @@ -46,3 +53,11 @@ message SignupReq { message SignupRsp { string error = 1; } + +message RefreshPasswordReq { + string email = 1; +} + +message RefreshPasswordRsp { + string error = 1; +} diff --git a/cmd/evening_detective_server/main.swagger.json b/cmd/evening_detective_server/main.swagger.json index 99d2169..18049e0 100644 --- a/cmd/evening_detective_server/main.swagger.json +++ b/cmd/evening_detective_server/main.swagger.json @@ -68,6 +68,38 @@ ] } }, + "/api/refresh-password": { + "post": { + "operationId": "EveningDetectiveServer_RefreshPassword", + "responses": { + "200": { + "description": "A successful response.", + "schema": { + "$ref": "#/definitions/evening_detective_serverRefreshPasswordRsp" + } + }, + "default": { + "description": "An unexpected error response.", + "schema": { + "$ref": "#/definitions/rpcStatus" + } + } + }, + "parameters": [ + { + "name": "body", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/evening_detective_serverRefreshPasswordReq" + } + } + ], + "tags": [ + "EveningDetectiveServer" + ] + } + }, "/api/signup": { "post": { "operationId": "EveningDetectiveServer_Signup", @@ -113,6 +145,22 @@ "evening_detective_serverPingRsp": { "type": "object" }, + "evening_detective_serverRefreshPasswordReq": { + "type": "object", + "properties": { + "email": { + "type": "string" + } + } + }, + "evening_detective_serverRefreshPasswordRsp": { + "type": "object", + "properties": { + "error": { + "type": "string" + } + } + }, "evening_detective_serverSignupReq": { "type": "object", "properties": { diff --git a/internal/app/server.go b/internal/app/server.go index e99198c..019796e 100644 --- a/internal/app/server.go +++ b/internal/app/server.go @@ -28,8 +28,8 @@ func (s *server) Echo(_ context.Context, req *proto.EchoReq) (*proto.EchoRsp, er return &proto.EchoRsp{Text: req.Text}, nil } -func (s *server) Signup(ctx context.Context, signupReq *proto.SignupReq) (*proto.SignupRsp, error) { - err := s.usersService.AddUser(ctx, signupReq.Username, signupReq.Email) +func (s *server) Signup(ctx context.Context, req *proto.SignupReq) (*proto.SignupRsp, error) { + err := s.usersService.AddUser(ctx, req.Username, req.Email) if err != nil { return &proto.SignupRsp{ Error: err.Error(), @@ -37,3 +37,13 @@ func (s *server) Signup(ctx context.Context, signupReq *proto.SignupReq) (*proto } return &proto.SignupRsp{}, nil } + +func (s *server) RefreshPassword(ctx context.Context, req *proto.RefreshPasswordReq) (*proto.RefreshPasswordRsp, error) { + err := s.usersService.RefreshPassword(ctx, req.Email) + if err != nil { + return &proto.RefreshPasswordRsp{ + Error: err.Error(), + }, nil + } + return &proto.RefreshPasswordRsp{}, nil +} diff --git a/internal/repos/user.go b/internal/repos/user.go new file mode 100644 index 0000000..c065db0 --- /dev/null +++ b/internal/repos/user.go @@ -0,0 +1,6 @@ +package repos + +type User struct { + Username string + Email string +} diff --git a/internal/repos/users_repo/repo.go b/internal/repos/users_repo/repo.go index 8711896..0150016 100644 --- a/internal/repos/users_repo/repo.go +++ b/internal/repos/users_repo/repo.go @@ -7,6 +7,10 @@ import ( "github.com/jackc/pgx/v5/pgxpool" ) +var ( + ErrUserNotFound = errors.New("Пользователь не найден") +) + type UsersRepo struct { pool *pgxpool.Pool } @@ -21,7 +25,7 @@ func (s *UsersRepo) AddUser( ctx context.Context, username string, email string, - passwoedHash string, + passwordHash string, role string, ) error { tag, err := s.pool.Exec( @@ -34,7 +38,7 @@ func (s *UsersRepo) AddUser( )`, username, email, - passwoedHash, + passwordHash, role, username, @@ -48,3 +52,26 @@ func (s *UsersRepo) AddUser( } return nil } + +func (s *UsersRepo) UpdateUserPassword( + ctx context.Context, + email string, + passwordHash string, +) error { + tag, err := s.pool.Exec( + ctx, + `UPDATE users + SET password_hash = $1 + WHERE email = $2`, + passwordHash, + email, + ) + if err != nil { + return err + } + if tag.RowsAffected() == 0 { + return ErrUserNotFound + } + + return nil +} diff --git a/internal/services/users_service/service.go b/internal/services/users_service/service.go index 37a261f..c84a67b 100644 --- a/internal/services/users_service/service.go +++ b/internal/services/users_service/service.go @@ -60,3 +60,34 @@ func (s *UsersService) AddUser( return err } + +func (s *UsersService) RefreshPassword( + ctx context.Context, + email string, +) error { + password, err := s.passwordGenerator.Generate() + if err != nil { + return err + } + hashedPassword, err := bcrypt.GenerateFromPassword([]byte(password), bcrypt.DefaultCost) + if err != nil { + return err + } + + err = s.usersRepo.UpdateUserPassword( + ctx, + email, + string(hashedPassword), + ) + if err != nil { + return err + } + + err = s.emailSender.Send(ctx, email_sender.Message{ + To: email, + Subject: "Приветствую тебя, детектив!", + Body: fmt.Sprintf("Вот твой новый пароль для входа в систему, не теряй: %s", password), + }) + + return err +} diff --git a/proto/main.pb.go b/proto/main.pb.go index ac5c76a..3a828f0 100644 --- a/proto/main.pb.go +++ b/proto/main.pb.go @@ -278,6 +278,94 @@ func (x *SignupRsp) GetError() string { return "" } +type RefreshPasswordReq struct { + state protoimpl.MessageState `protogen:"open.v1"` + Email string `protobuf:"bytes,1,opt,name=email,proto3" json:"email,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *RefreshPasswordReq) Reset() { + *x = RefreshPasswordReq{} + mi := &file_main_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *RefreshPasswordReq) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RefreshPasswordReq) ProtoMessage() {} + +func (x *RefreshPasswordReq) ProtoReflect() protoreflect.Message { + mi := &file_main_proto_msgTypes[6] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use RefreshPasswordReq.ProtoReflect.Descriptor instead. +func (*RefreshPasswordReq) Descriptor() ([]byte, []int) { + return file_main_proto_rawDescGZIP(), []int{6} +} + +func (x *RefreshPasswordReq) GetEmail() string { + if x != nil { + return x.Email + } + return "" +} + +type RefreshPasswordRsp struct { + state protoimpl.MessageState `protogen:"open.v1"` + Error string `protobuf:"bytes,1,opt,name=error,proto3" json:"error,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *RefreshPasswordRsp) Reset() { + *x = RefreshPasswordRsp{} + mi := &file_main_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *RefreshPasswordRsp) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*RefreshPasswordRsp) ProtoMessage() {} + +func (x *RefreshPasswordRsp) ProtoReflect() protoreflect.Message { + mi := &file_main_proto_msgTypes[7] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use RefreshPasswordRsp.ProtoReflect.Descriptor instead. +func (*RefreshPasswordRsp) Descriptor() ([]byte, []int) { + return file_main_proto_rawDescGZIP(), []int{7} +} + +func (x *RefreshPasswordRsp) GetError() string { + if x != nil { + return x.Error + } + return "" +} + var File_main_proto protoreflect.FileDescriptor const file_main_proto_rawDesc = "" + @@ -294,11 +382,16 @@ const file_main_proto_rawDesc = "" + "\busername\x18\x01 \x01(\tR\busername\x12\x14\n" + "\x05email\x18\x02 \x01(\tR\x05email\"!\n" + "\tSignupRsp\x12\x14\n" + - "\x05error\x18\x01 \x01(\tR\x05error2\xea\x02\n" + + "\x05error\x18\x01 \x01(\tR\x05error\"*\n" + + "\x12RefreshPasswordReq\x12\x14\n" + + "\x05email\x18\x01 \x01(\tR\x05email\"*\n" + + "\x12RefreshPasswordRsp\x12\x14\n" + + "\x05error\x18\x01 \x01(\tR\x05error2\x88\x04\n" + "\x16EveningDetectiveServer\x12k\n" + "\x04Ping\x12'.crabs.evening_detective_server.PingReq\x1a'.crabs.evening_detective_server.PingRsp\"\x11\x82\xd3\xe4\x93\x02\v\x12\t/api/ping\x12k\n" + "\x04Echo\x12'.crabs.evening_detective_server.EchoReq\x1a'.crabs.evening_detective_server.EchoRsp\"\x11\x82\xd3\xe4\x93\x02\v\"\t/api/echo\x12v\n" + - "\x06Signup\x12).crabs.evening_detective_server.SignupReq\x1a).crabs.evening_detective_server.SignupRsp\"\x16\x82\xd3\xe4\x93\x02\x10:\x01*\"\v/api/signupB\vZ\tpkg/protob\x06proto3" + "\x06Signup\x12).crabs.evening_detective_server.SignupReq\x1a).crabs.evening_detective_server.SignupRsp\"\x16\x82\xd3\xe4\x93\x02\x10:\x01*\"\v/api/signup\x12\x9b\x01\n" + + "\x0fRefreshPassword\x122.crabs.evening_detective_server.RefreshPasswordReq\x1a2.crabs.evening_detective_server.RefreshPasswordRsp\" \x82\xd3\xe4\x93\x02\x1a:\x01*\"\x15/api/refresh-passwordB\vZ\tpkg/protob\x06proto3" var ( file_main_proto_rawDescOnce sync.Once @@ -312,24 +405,28 @@ func file_main_proto_rawDescGZIP() []byte { return file_main_proto_rawDescData } -var file_main_proto_msgTypes = make([]protoimpl.MessageInfo, 6) +var file_main_proto_msgTypes = make([]protoimpl.MessageInfo, 8) var file_main_proto_goTypes = []any{ - (*PingReq)(nil), // 0: crabs.evening_detective_server.PingReq - (*PingRsp)(nil), // 1: crabs.evening_detective_server.PingRsp - (*EchoReq)(nil), // 2: crabs.evening_detective_server.EchoReq - (*EchoRsp)(nil), // 3: crabs.evening_detective_server.EchoRsp - (*SignupReq)(nil), // 4: crabs.evening_detective_server.SignupReq - (*SignupRsp)(nil), // 5: crabs.evening_detective_server.SignupRsp + (*PingReq)(nil), // 0: crabs.evening_detective_server.PingReq + (*PingRsp)(nil), // 1: crabs.evening_detective_server.PingRsp + (*EchoReq)(nil), // 2: crabs.evening_detective_server.EchoReq + (*EchoRsp)(nil), // 3: crabs.evening_detective_server.EchoRsp + (*SignupReq)(nil), // 4: crabs.evening_detective_server.SignupReq + (*SignupRsp)(nil), // 5: crabs.evening_detective_server.SignupRsp + (*RefreshPasswordReq)(nil), // 6: crabs.evening_detective_server.RefreshPasswordReq + (*RefreshPasswordRsp)(nil), // 7: crabs.evening_detective_server.RefreshPasswordRsp } var file_main_proto_depIdxs = []int32{ 0, // 0: crabs.evening_detective_server.EveningDetectiveServer.Ping:input_type -> crabs.evening_detective_server.PingReq 2, // 1: crabs.evening_detective_server.EveningDetectiveServer.Echo:input_type -> crabs.evening_detective_server.EchoReq 4, // 2: crabs.evening_detective_server.EveningDetectiveServer.Signup:input_type -> crabs.evening_detective_server.SignupReq - 1, // 3: crabs.evening_detective_server.EveningDetectiveServer.Ping:output_type -> crabs.evening_detective_server.PingRsp - 3, // 4: crabs.evening_detective_server.EveningDetectiveServer.Echo:output_type -> crabs.evening_detective_server.EchoRsp - 5, // 5: crabs.evening_detective_server.EveningDetectiveServer.Signup:output_type -> crabs.evening_detective_server.SignupRsp - 3, // [3:6] is the sub-list for method output_type - 0, // [0:3] is the sub-list for method input_type + 6, // 3: crabs.evening_detective_server.EveningDetectiveServer.RefreshPassword:input_type -> crabs.evening_detective_server.RefreshPasswordReq + 1, // 4: crabs.evening_detective_server.EveningDetectiveServer.Ping:output_type -> crabs.evening_detective_server.PingRsp + 3, // 5: crabs.evening_detective_server.EveningDetectiveServer.Echo:output_type -> crabs.evening_detective_server.EchoRsp + 5, // 6: crabs.evening_detective_server.EveningDetectiveServer.Signup:output_type -> crabs.evening_detective_server.SignupRsp + 7, // 7: crabs.evening_detective_server.EveningDetectiveServer.RefreshPassword:output_type -> crabs.evening_detective_server.RefreshPasswordRsp + 4, // [4:8] is the sub-list for method output_type + 0, // [0:4] is the sub-list for method input_type 0, // [0:0] is the sub-list for extension type_name 0, // [0:0] is the sub-list for extension extendee 0, // [0:0] is the sub-list for field type_name @@ -346,7 +443,7 @@ func file_main_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: unsafe.Slice(unsafe.StringData(file_main_proto_rawDesc), len(file_main_proto_rawDesc)), NumEnums: 0, - NumMessages: 6, + NumMessages: 8, NumExtensions: 0, NumServices: 1, }, diff --git a/proto/main.pb.gw.go b/proto/main.pb.gw.go index 517f35e..066836f 100644 --- a/proto/main.pb.gw.go +++ b/proto/main.pb.gw.go @@ -118,6 +118,33 @@ func local_request_EveningDetectiveServer_Signup_0(ctx context.Context, marshale return msg, metadata, err } +func request_EveningDetectiveServer_RefreshPassword_0(ctx context.Context, marshaler runtime.Marshaler, client EveningDetectiveServerClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq RefreshPasswordReq + metadata runtime.ServerMetadata + ) + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if req.Body != nil { + _, _ = io.Copy(io.Discard, req.Body) + } + msg, err := client.RefreshPassword(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err +} + +func local_request_EveningDetectiveServer_RefreshPassword_0(ctx context.Context, marshaler runtime.Marshaler, server EveningDetectiveServerServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var ( + protoReq RefreshPasswordReq + metadata runtime.ServerMetadata + ) + if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := server.RefreshPassword(ctx, &protoReq) + return msg, metadata, err +} + // RegisterEveningDetectiveServerHandlerServer registers the http handlers for service EveningDetectiveServer to "mux". // UnaryRPC :call EveningDetectiveServerServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. @@ -184,6 +211,26 @@ func RegisterEveningDetectiveServerHandlerServer(ctx context.Context, mux *runti } forward_EveningDetectiveServer_Signup_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) + mux.Handle(http.MethodPost, pattern_EveningDetectiveServer_RefreshPassword_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/crabs.evening_detective_server.EveningDetectiveServer/RefreshPassword", runtime.WithHTTPPathPattern("/api/refresh-password")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_EveningDetectiveServer_RefreshPassword_0(annotatedContext, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_EveningDetectiveServer_RefreshPassword_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) return nil } @@ -275,17 +322,36 @@ func RegisterEveningDetectiveServerHandlerClient(ctx context.Context, mux *runti } forward_EveningDetectiveServer_Signup_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) + mux.Handle(http.MethodPost, pattern_EveningDetectiveServer_RefreshPassword_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/crabs.evening_detective_server.EveningDetectiveServer/RefreshPassword", runtime.WithHTTPPathPattern("/api/refresh-password")) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_EveningDetectiveServer_RefreshPassword_0(annotatedContext, inboundMarshaler, client, req, pathParams) + annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md) + if err != nil { + runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err) + return + } + forward_EveningDetectiveServer_RefreshPassword_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + }) return nil } var ( - pattern_EveningDetectiveServer_Ping_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"api", "ping"}, "")) - pattern_EveningDetectiveServer_Echo_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"api", "echo"}, "")) - pattern_EveningDetectiveServer_Signup_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"api", "signup"}, "")) + pattern_EveningDetectiveServer_Ping_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"api", "ping"}, "")) + pattern_EveningDetectiveServer_Echo_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"api", "echo"}, "")) + pattern_EveningDetectiveServer_Signup_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"api", "signup"}, "")) + pattern_EveningDetectiveServer_RefreshPassword_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"api", "refresh-password"}, "")) ) var ( - forward_EveningDetectiveServer_Ping_0 = runtime.ForwardResponseMessage - forward_EveningDetectiveServer_Echo_0 = runtime.ForwardResponseMessage - forward_EveningDetectiveServer_Signup_0 = runtime.ForwardResponseMessage + forward_EveningDetectiveServer_Ping_0 = runtime.ForwardResponseMessage + forward_EveningDetectiveServer_Echo_0 = runtime.ForwardResponseMessage + forward_EveningDetectiveServer_Signup_0 = runtime.ForwardResponseMessage + forward_EveningDetectiveServer_RefreshPassword_0 = runtime.ForwardResponseMessage ) diff --git a/proto/main_grpc.pb.go b/proto/main_grpc.pb.go index ee5583a..229dbcc 100644 --- a/proto/main_grpc.pb.go +++ b/proto/main_grpc.pb.go @@ -19,9 +19,10 @@ import ( const _ = grpc.SupportPackageIsVersion9 const ( - EveningDetectiveServer_Ping_FullMethodName = "/crabs.evening_detective_server.EveningDetectiveServer/Ping" - EveningDetectiveServer_Echo_FullMethodName = "/crabs.evening_detective_server.EveningDetectiveServer/Echo" - EveningDetectiveServer_Signup_FullMethodName = "/crabs.evening_detective_server.EveningDetectiveServer/Signup" + EveningDetectiveServer_Ping_FullMethodName = "/crabs.evening_detective_server.EveningDetectiveServer/Ping" + EveningDetectiveServer_Echo_FullMethodName = "/crabs.evening_detective_server.EveningDetectiveServer/Echo" + EveningDetectiveServer_Signup_FullMethodName = "/crabs.evening_detective_server.EveningDetectiveServer/Signup" + EveningDetectiveServer_RefreshPassword_FullMethodName = "/crabs.evening_detective_server.EveningDetectiveServer/RefreshPassword" ) // EveningDetectiveServerClient is the client API for EveningDetectiveServer service. @@ -31,6 +32,7 @@ type EveningDetectiveServerClient interface { Ping(ctx context.Context, in *PingReq, opts ...grpc.CallOption) (*PingRsp, error) Echo(ctx context.Context, in *EchoReq, opts ...grpc.CallOption) (*EchoRsp, error) Signup(ctx context.Context, in *SignupReq, opts ...grpc.CallOption) (*SignupRsp, error) + RefreshPassword(ctx context.Context, in *RefreshPasswordReq, opts ...grpc.CallOption) (*RefreshPasswordRsp, error) } type eveningDetectiveServerClient struct { @@ -71,6 +73,16 @@ func (c *eveningDetectiveServerClient) Signup(ctx context.Context, in *SignupReq return out, nil } +func (c *eveningDetectiveServerClient) RefreshPassword(ctx context.Context, in *RefreshPasswordReq, opts ...grpc.CallOption) (*RefreshPasswordRsp, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(RefreshPasswordRsp) + err := c.cc.Invoke(ctx, EveningDetectiveServer_RefreshPassword_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + // EveningDetectiveServerServer is the server API for EveningDetectiveServer service. // All implementations must embed UnimplementedEveningDetectiveServerServer // for forward compatibility. @@ -78,6 +90,7 @@ type EveningDetectiveServerServer interface { Ping(context.Context, *PingReq) (*PingRsp, error) Echo(context.Context, *EchoReq) (*EchoRsp, error) Signup(context.Context, *SignupReq) (*SignupRsp, error) + RefreshPassword(context.Context, *RefreshPasswordReq) (*RefreshPasswordRsp, error) mustEmbedUnimplementedEveningDetectiveServerServer() } @@ -97,6 +110,9 @@ func (UnimplementedEveningDetectiveServerServer) Echo(context.Context, *EchoReq) func (UnimplementedEveningDetectiveServerServer) Signup(context.Context, *SignupReq) (*SignupRsp, error) { return nil, status.Error(codes.Unimplemented, "method Signup not implemented") } +func (UnimplementedEveningDetectiveServerServer) RefreshPassword(context.Context, *RefreshPasswordReq) (*RefreshPasswordRsp, error) { + return nil, status.Error(codes.Unimplemented, "method RefreshPassword not implemented") +} func (UnimplementedEveningDetectiveServerServer) mustEmbedUnimplementedEveningDetectiveServerServer() { } func (UnimplementedEveningDetectiveServerServer) testEmbeddedByValue() {} @@ -173,6 +189,24 @@ func _EveningDetectiveServer_Signup_Handler(srv interface{}, ctx context.Context return interceptor(ctx, in, info, handler) } +func _EveningDetectiveServer_RefreshPassword_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(RefreshPasswordReq) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(EveningDetectiveServerServer).RefreshPassword(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: EveningDetectiveServer_RefreshPassword_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(EveningDetectiveServerServer).RefreshPassword(ctx, req.(*RefreshPasswordReq)) + } + return interceptor(ctx, in, info, handler) +} + // EveningDetectiveServer_ServiceDesc is the grpc.ServiceDesc for EveningDetectiveServer service. // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) @@ -192,6 +226,10 @@ var EveningDetectiveServer_ServiceDesc = grpc.ServiceDesc{ MethodName: "Signup", Handler: _EveningDetectiveServer_Signup_Handler, }, + { + MethodName: "RefreshPassword", + Handler: _EveningDetectiveServer_RefreshPassword_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "main.proto",