generated from VLADIMIR/template
add refresh-password route
This commit is contained in:
@@ -24,6 +24,13 @@ service EveningDetectiveServer {
|
|||||||
body: "*"
|
body: "*"
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rpc RefreshPassword(RefreshPasswordReq) returns (RefreshPasswordRsp) {
|
||||||
|
option (google.api.http) = {
|
||||||
|
post: "/api/refresh-password"
|
||||||
|
body: "*"
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
message PingReq {}
|
message PingReq {}
|
||||||
@@ -46,3 +53,11 @@ message SignupReq {
|
|||||||
message SignupRsp {
|
message SignupRsp {
|
||||||
string error = 1;
|
string error = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
message RefreshPasswordReq {
|
||||||
|
string email = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message RefreshPasswordRsp {
|
||||||
|
string error = 1;
|
||||||
|
}
|
||||||
|
|||||||
@@ -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": {
|
"/api/signup": {
|
||||||
"post": {
|
"post": {
|
||||||
"operationId": "EveningDetectiveServer_Signup",
|
"operationId": "EveningDetectiveServer_Signup",
|
||||||
@@ -113,6 +145,22 @@
|
|||||||
"evening_detective_serverPingRsp": {
|
"evening_detective_serverPingRsp": {
|
||||||
"type": "object"
|
"type": "object"
|
||||||
},
|
},
|
||||||
|
"evening_detective_serverRefreshPasswordReq": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"email": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"evening_detective_serverRefreshPasswordRsp": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"error": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"evening_detective_serverSignupReq": {
|
"evening_detective_serverSignupReq": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
|
|||||||
+12
-2
@@ -28,8 +28,8 @@ func (s *server) Echo(_ context.Context, req *proto.EchoReq) (*proto.EchoRsp, er
|
|||||||
return &proto.EchoRsp{Text: req.Text}, nil
|
return &proto.EchoRsp{Text: req.Text}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *server) Signup(ctx context.Context, signupReq *proto.SignupReq) (*proto.SignupRsp, error) {
|
func (s *server) Signup(ctx context.Context, req *proto.SignupReq) (*proto.SignupRsp, error) {
|
||||||
err := s.usersService.AddUser(ctx, signupReq.Username, signupReq.Email)
|
err := s.usersService.AddUser(ctx, req.Username, req.Email)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return &proto.SignupRsp{
|
return &proto.SignupRsp{
|
||||||
Error: err.Error(),
|
Error: err.Error(),
|
||||||
@@ -37,3 +37,13 @@ func (s *server) Signup(ctx context.Context, signupReq *proto.SignupReq) (*proto
|
|||||||
}
|
}
|
||||||
return &proto.SignupRsp{}, nil
|
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
|
||||||
|
}
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
package repos
|
||||||
|
|
||||||
|
type User struct {
|
||||||
|
Username string
|
||||||
|
Email string
|
||||||
|
}
|
||||||
@@ -7,6 +7,10 @@ import (
|
|||||||
"github.com/jackc/pgx/v5/pgxpool"
|
"github.com/jackc/pgx/v5/pgxpool"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
ErrUserNotFound = errors.New("Пользователь не найден")
|
||||||
|
)
|
||||||
|
|
||||||
type UsersRepo struct {
|
type UsersRepo struct {
|
||||||
pool *pgxpool.Pool
|
pool *pgxpool.Pool
|
||||||
}
|
}
|
||||||
@@ -21,7 +25,7 @@ func (s *UsersRepo) AddUser(
|
|||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
username string,
|
username string,
|
||||||
email string,
|
email string,
|
||||||
passwoedHash string,
|
passwordHash string,
|
||||||
role string,
|
role string,
|
||||||
) error {
|
) error {
|
||||||
tag, err := s.pool.Exec(
|
tag, err := s.pool.Exec(
|
||||||
@@ -34,7 +38,7 @@ func (s *UsersRepo) AddUser(
|
|||||||
)`,
|
)`,
|
||||||
username,
|
username,
|
||||||
email,
|
email,
|
||||||
passwoedHash,
|
passwordHash,
|
||||||
role,
|
role,
|
||||||
|
|
||||||
username,
|
username,
|
||||||
@@ -48,3 +52,26 @@ func (s *UsersRepo) AddUser(
|
|||||||
}
|
}
|
||||||
return nil
|
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
|
||||||
|
}
|
||||||
|
|||||||
@@ -60,3 +60,34 @@ func (s *UsersService) AddUser(
|
|||||||
|
|
||||||
return err
|
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
|
||||||
|
}
|
||||||
|
|||||||
+106
-9
@@ -278,6 +278,94 @@ func (x *SignupRsp) GetError() string {
|
|||||||
return ""
|
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
|
var File_main_proto protoreflect.FileDescriptor
|
||||||
|
|
||||||
const file_main_proto_rawDesc = "" +
|
const file_main_proto_rawDesc = "" +
|
||||||
@@ -294,11 +382,16 @@ const file_main_proto_rawDesc = "" +
|
|||||||
"\busername\x18\x01 \x01(\tR\busername\x12\x14\n" +
|
"\busername\x18\x01 \x01(\tR\busername\x12\x14\n" +
|
||||||
"\x05email\x18\x02 \x01(\tR\x05email\"!\n" +
|
"\x05email\x18\x02 \x01(\tR\x05email\"!\n" +
|
||||||
"\tSignupRsp\x12\x14\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" +
|
"\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" +
|
"\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" +
|
"\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 (
|
var (
|
||||||
file_main_proto_rawDescOnce sync.Once
|
file_main_proto_rawDescOnce sync.Once
|
||||||
@@ -312,7 +405,7 @@ func file_main_proto_rawDescGZIP() []byte {
|
|||||||
return file_main_proto_rawDescData
|
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{
|
var file_main_proto_goTypes = []any{
|
||||||
(*PingReq)(nil), // 0: crabs.evening_detective_server.PingReq
|
(*PingReq)(nil), // 0: crabs.evening_detective_server.PingReq
|
||||||
(*PingRsp)(nil), // 1: crabs.evening_detective_server.PingRsp
|
(*PingRsp)(nil), // 1: crabs.evening_detective_server.PingRsp
|
||||||
@@ -320,16 +413,20 @@ var file_main_proto_goTypes = []any{
|
|||||||
(*EchoRsp)(nil), // 3: crabs.evening_detective_server.EchoRsp
|
(*EchoRsp)(nil), // 3: crabs.evening_detective_server.EchoRsp
|
||||||
(*SignupReq)(nil), // 4: crabs.evening_detective_server.SignupReq
|
(*SignupReq)(nil), // 4: crabs.evening_detective_server.SignupReq
|
||||||
(*SignupRsp)(nil), // 5: crabs.evening_detective_server.SignupRsp
|
(*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{
|
var file_main_proto_depIdxs = []int32{
|
||||||
0, // 0: crabs.evening_detective_server.EveningDetectiveServer.Ping:input_type -> crabs.evening_detective_server.PingReq
|
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
|
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
|
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
|
6, // 3: crabs.evening_detective_server.EveningDetectiveServer.RefreshPassword:input_type -> crabs.evening_detective_server.RefreshPasswordReq
|
||||||
3, // 4: crabs.evening_detective_server.EveningDetectiveServer.Echo:output_type -> crabs.evening_detective_server.EchoRsp
|
1, // 4: crabs.evening_detective_server.EveningDetectiveServer.Ping:output_type -> crabs.evening_detective_server.PingRsp
|
||||||
5, // 5: crabs.evening_detective_server.EveningDetectiveServer.Signup:output_type -> crabs.evening_detective_server.SignupRsp
|
3, // 5: crabs.evening_detective_server.EveningDetectiveServer.Echo:output_type -> crabs.evening_detective_server.EchoRsp
|
||||||
3, // [3:6] is the sub-list for method output_type
|
5, // 6: crabs.evening_detective_server.EveningDetectiveServer.Signup:output_type -> crabs.evening_detective_server.SignupRsp
|
||||||
0, // [0:3] is the sub-list for method input_type
|
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 type_name
|
||||||
0, // [0:0] is the sub-list for extension extendee
|
0, // [0:0] is the sub-list for extension extendee
|
||||||
0, // [0:0] is the sub-list for field type_name
|
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(),
|
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||||
RawDescriptor: unsafe.Slice(unsafe.StringData(file_main_proto_rawDesc), len(file_main_proto_rawDesc)),
|
RawDescriptor: unsafe.Slice(unsafe.StringData(file_main_proto_rawDesc), len(file_main_proto_rawDesc)),
|
||||||
NumEnums: 0,
|
NumEnums: 0,
|
||||||
NumMessages: 6,
|
NumMessages: 8,
|
||||||
NumExtensions: 0,
|
NumExtensions: 0,
|
||||||
NumServices: 1,
|
NumServices: 1,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -118,6 +118,33 @@ func local_request_EveningDetectiveServer_Signup_0(ctx context.Context, marshale
|
|||||||
return msg, metadata, err
|
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".
|
// RegisterEveningDetectiveServerHandlerServer registers the http handlers for service EveningDetectiveServer to "mux".
|
||||||
// UnaryRPC :call EveningDetectiveServerServer directly.
|
// UnaryRPC :call EveningDetectiveServerServer directly.
|
||||||
// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906.
|
// 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()...)
|
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
|
return nil
|
||||||
}
|
}
|
||||||
@@ -275,6 +322,23 @@ func RegisterEveningDetectiveServerHandlerClient(ctx context.Context, mux *runti
|
|||||||
}
|
}
|
||||||
forward_EveningDetectiveServer_Signup_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
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
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -282,10 +346,12 @@ var (
|
|||||||
pattern_EveningDetectiveServer_Ping_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"api", "ping"}, ""))
|
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_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_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 (
|
var (
|
||||||
forward_EveningDetectiveServer_Ping_0 = runtime.ForwardResponseMessage
|
forward_EveningDetectiveServer_Ping_0 = runtime.ForwardResponseMessage
|
||||||
forward_EveningDetectiveServer_Echo_0 = runtime.ForwardResponseMessage
|
forward_EveningDetectiveServer_Echo_0 = runtime.ForwardResponseMessage
|
||||||
forward_EveningDetectiveServer_Signup_0 = runtime.ForwardResponseMessage
|
forward_EveningDetectiveServer_Signup_0 = runtime.ForwardResponseMessage
|
||||||
|
forward_EveningDetectiveServer_RefreshPassword_0 = runtime.ForwardResponseMessage
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ const (
|
|||||||
EveningDetectiveServer_Ping_FullMethodName = "/crabs.evening_detective_server.EveningDetectiveServer/Ping"
|
EveningDetectiveServer_Ping_FullMethodName = "/crabs.evening_detective_server.EveningDetectiveServer/Ping"
|
||||||
EveningDetectiveServer_Echo_FullMethodName = "/crabs.evening_detective_server.EveningDetectiveServer/Echo"
|
EveningDetectiveServer_Echo_FullMethodName = "/crabs.evening_detective_server.EveningDetectiveServer/Echo"
|
||||||
EveningDetectiveServer_Signup_FullMethodName = "/crabs.evening_detective_server.EveningDetectiveServer/Signup"
|
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.
|
// 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)
|
Ping(ctx context.Context, in *PingReq, opts ...grpc.CallOption) (*PingRsp, error)
|
||||||
Echo(ctx context.Context, in *EchoReq, opts ...grpc.CallOption) (*EchoRsp, error)
|
Echo(ctx context.Context, in *EchoReq, opts ...grpc.CallOption) (*EchoRsp, error)
|
||||||
Signup(ctx context.Context, in *SignupReq, opts ...grpc.CallOption) (*SignupRsp, 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 {
|
type eveningDetectiveServerClient struct {
|
||||||
@@ -71,6 +73,16 @@ func (c *eveningDetectiveServerClient) Signup(ctx context.Context, in *SignupReq
|
|||||||
return out, nil
|
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.
|
// EveningDetectiveServerServer is the server API for EveningDetectiveServer service.
|
||||||
// All implementations must embed UnimplementedEveningDetectiveServerServer
|
// All implementations must embed UnimplementedEveningDetectiveServerServer
|
||||||
// for forward compatibility.
|
// for forward compatibility.
|
||||||
@@ -78,6 +90,7 @@ type EveningDetectiveServerServer interface {
|
|||||||
Ping(context.Context, *PingReq) (*PingRsp, error)
|
Ping(context.Context, *PingReq) (*PingRsp, error)
|
||||||
Echo(context.Context, *EchoReq) (*EchoRsp, error)
|
Echo(context.Context, *EchoReq) (*EchoRsp, error)
|
||||||
Signup(context.Context, *SignupReq) (*SignupRsp, error)
|
Signup(context.Context, *SignupReq) (*SignupRsp, error)
|
||||||
|
RefreshPassword(context.Context, *RefreshPasswordReq) (*RefreshPasswordRsp, error)
|
||||||
mustEmbedUnimplementedEveningDetectiveServerServer()
|
mustEmbedUnimplementedEveningDetectiveServerServer()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -97,6 +110,9 @@ func (UnimplementedEveningDetectiveServerServer) Echo(context.Context, *EchoReq)
|
|||||||
func (UnimplementedEveningDetectiveServerServer) Signup(context.Context, *SignupReq) (*SignupRsp, error) {
|
func (UnimplementedEveningDetectiveServerServer) Signup(context.Context, *SignupReq) (*SignupRsp, error) {
|
||||||
return nil, status.Error(codes.Unimplemented, "method Signup not implemented")
|
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) mustEmbedUnimplementedEveningDetectiveServerServer() {
|
||||||
}
|
}
|
||||||
func (UnimplementedEveningDetectiveServerServer) testEmbeddedByValue() {}
|
func (UnimplementedEveningDetectiveServerServer) testEmbeddedByValue() {}
|
||||||
@@ -173,6 +189,24 @@ func _EveningDetectiveServer_Signup_Handler(srv interface{}, ctx context.Context
|
|||||||
return interceptor(ctx, in, info, handler)
|
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.
|
// EveningDetectiveServer_ServiceDesc is the grpc.ServiceDesc for EveningDetectiveServer service.
|
||||||
// It's only intended for direct use with grpc.RegisterService,
|
// It's only intended for direct use with grpc.RegisterService,
|
||||||
// and not to be introspected or modified (even as a copy)
|
// and not to be introspected or modified (even as a copy)
|
||||||
@@ -192,6 +226,10 @@ var EveningDetectiveServer_ServiceDesc = grpc.ServiceDesc{
|
|||||||
MethodName: "Signup",
|
MethodName: "Signup",
|
||||||
Handler: _EveningDetectiveServer_Signup_Handler,
|
Handler: _EveningDetectiveServer_Signup_Handler,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
MethodName: "RefreshPassword",
|
||||||
|
Handler: _EveningDetectiveServer_RefreshPassword_Handler,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
Streams: []grpc.StreamDesc{},
|
Streams: []grpc.StreamDesc{},
|
||||||
Metadata: "main.proto",
|
Metadata: "main.proto",
|
||||||
|
|||||||
Reference in New Issue
Block a user