fixes
This commit is contained in:
parent
da86ee374a
commit
4a6326a5ab
|
@ -38,7 +38,7 @@ services:
|
|||
identification:
|
||||
local:
|
||||
jwt_secret: JWT_KEY
|
||||
ttl: 120s
|
||||
ttl: 20000s
|
||||
|
||||
carpooling_proofs:
|
||||
rpc_registry:
|
||||
|
|
1
go.mod
1
go.mod
|
@ -21,6 +21,7 @@ require (
|
|||
github.com/cespare/xxhash/v2 v2.2.0 // indirect
|
||||
github.com/coreos/go-semver v0.3.0 // indirect
|
||||
github.com/coreos/go-systemd/v22 v22.5.0 // indirect
|
||||
github.com/dgrijalva/jwt-go v3.2.0+incompatible // indirect
|
||||
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
|
||||
github.com/fsnotify/fsnotify v1.6.0 // indirect
|
||||
github.com/go-stack/stack v1.8.0 // indirect
|
||||
|
|
2
go.sum
2
go.sum
|
@ -64,6 +64,8 @@ github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSV
|
|||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/dgrijalva/jwt-go v3.2.0+incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumCAMpl/TFQ4/5kLM=
|
||||
github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
|
||||
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78=
|
||||
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc=
|
||||
github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
|
||||
|
|
|
@ -10,15 +10,12 @@ func (h *SilvermobiHandler) Login(ctx context.Context, username string, password
|
|||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
key := h.Config.GetString("identification.local.jwt_secret")
|
||||
ttl := h.Config.GetString("identification.local.ttl")
|
||||
|
||||
parsedttl, err := time.ParseDuration(ttl)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return account.CreateToken(parsedttl, key)
|
||||
}
|
||||
|
||||
|
|
|
@ -10,15 +10,11 @@ import (
|
|||
"math/rand"
|
||||
)
|
||||
|
||||
func (h *SilvermobiHandler) UpdatePhoneNumber(ctx context.Context, email string, phone_number string) error {
|
||||
func (h *SilvermobiHandler) UpdatePhoneNumber(ctx context.Context, id string, phone_number string) error {
|
||||
code := rand.Intn(9999)
|
||||
account, err := h.Services.MobilityAccounts.GetAccountUsername(ctx, email, "silvermobi")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = h.Services.MobilityAccounts.UpdatePhoneNumber(
|
||||
err := h.Services.MobilityAccounts.UpdatePhoneNumber(
|
||||
ctx,
|
||||
account.ID,
|
||||
id,
|
||||
phone_number,
|
||||
false,
|
||||
fmt.Sprintf("%04d", code),
|
||||
|
@ -44,10 +40,9 @@ func (h *SilvermobiHandler) UpdatePhoneNumber(ctx context.Context, email string,
|
|||
return nil
|
||||
}
|
||||
|
||||
func (h *SilvermobiHandler) VerifyPhoneNumber(ctx context.Context, email string, phone_number string, verification_code string) error {
|
||||
account, err := h.Services.MobilityAccounts.GetAccountUsername(ctx, email, "silvermobi")
|
||||
func (h *SilvermobiHandler) VerifyPhoneNumber(ctx context.Context, id string, phone_number string, verification_code string) error {
|
||||
request := &grpcapi.GetAccountRequest{
|
||||
Id: account.ID,
|
||||
Id: id,
|
||||
}
|
||||
resp, err := h.Services.MobilityAccounts.Client.GetAccount(ctx, request)
|
||||
if err != nil {
|
||||
|
@ -69,7 +64,7 @@ func (h *SilvermobiHandler) VerifyPhoneNumber(ctx context.Context, email string,
|
|||
|
||||
err = h.Services.MobilityAccounts.UpdatePhoneNumber(
|
||||
ctx,
|
||||
account.ID,
|
||||
id,
|
||||
phone_number,
|
||||
true,
|
||||
"",
|
||||
|
@ -81,29 +76,62 @@ func (h *SilvermobiHandler) VerifyPhoneNumber(ctx context.Context, email string,
|
|||
return nil
|
||||
}
|
||||
|
||||
func (h *SilvermobiHandler) UpdateBirthDate(ctx context.Context, username string, birthdate string) error {
|
||||
err := h.Services.MobilityAccounts.UpdateAccountBirthDate(ctx, username, "silvermobi", birthdate)
|
||||
func (h *SilvermobiHandler) UpdateBirthDate(ctx context.Context, id string, birthdate string) error {
|
||||
err := h.Services.MobilityAccounts.UpdateAccountBirthDate(ctx, id, "silvermobi", birthdate)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (h *SilvermobiHandler) CheckValidation(ctx context.Context, email string) (phone_validation, birth_validation bool, err error) {
|
||||
account, err := h.Services.MobilityAccounts.GetAccountUsername(ctx, email, "silvermobi")
|
||||
func (h *SilvermobiHandler) SetAccountType(ctx context.Context, id string, accountType string) error {
|
||||
err := h.Services.MobilityAccounts.SetAccountType(ctx, id, accountType)
|
||||
if err != nil {
|
||||
return false, false, err
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (h *SilvermobiHandler) GetAccountType(ctx context.Context, id string) (account_type string, err error) {
|
||||
request := &grpcapi.GetAccountRequest{
|
||||
Id: id,
|
||||
}
|
||||
resp, err := h.Services.MobilityAccounts.Client.GetAccount(ctx, request)
|
||||
if err != nil {
|
||||
return "", err
|
||||
log.Error().Err(err).Msg("Failed get account type")
|
||||
}
|
||||
account := h.Services.MobilityAccounts.ToAccountModel(resp.Account.ToStorageType())
|
||||
if account.Type != "" {
|
||||
|
||||
return account.Type, nil
|
||||
}
|
||||
return "", errors.New("account type not set")
|
||||
}
|
||||
|
||||
func (h *SilvermobiHandler) CheckValidation(ctx context.Context, id string) (phone_validation, birth_validation, type_validation bool, err error) {
|
||||
request := &grpcapi.GetAccountRequest{
|
||||
Id: id,
|
||||
}
|
||||
resp, err := h.Services.MobilityAccounts.Client.GetAccount(ctx, request)
|
||||
if err != nil {
|
||||
return false, false, false, err
|
||||
log.Error().Err(err).Msg("Failed get validation response")
|
||||
}
|
||||
account := h.Services.MobilityAccounts.ToAccountModel(resp.Account.ToStorageType())
|
||||
phone_validation = false
|
||||
birth_validation = false
|
||||
type_validation = false
|
||||
if account.LocalCredentials.PhoneNumberVerified {
|
||||
phone_validation = true
|
||||
|
||||
}
|
||||
if account.BirthDate != "" {
|
||||
birth_validation = true
|
||||
}
|
||||
log.Info().Msg("Getting phone and birth validation for " + email)
|
||||
return phone_validation, birth_validation, nil
|
||||
fmt.Println(account.Type)
|
||||
if account.Type != "" {
|
||||
type_validation = true
|
||||
}
|
||||
|
||||
log.Info().Msg("Getting phone and birth validation for " + account.Email)
|
||||
return phone_validation, birth_validation, type_validation, nil
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ type Account struct {
|
|||
LastName string `json:"lastName,omitempty"`
|
||||
VerifiedIdentity *bool `json:"verifiedIdentity,omitempty"`
|
||||
BirthDate string `json:"birthdate,omitempty"`
|
||||
Type string `json:"type,omitempty"`
|
||||
LocalCredentials
|
||||
}
|
||||
|
||||
|
@ -31,7 +32,7 @@ func (account Account) CreateToken(ttl time.Duration, key string) (token string,
|
|||
expires_at := jwt.NewNumericDate(time.Now().Add(ttl))
|
||||
claims := UserClaims{
|
||||
RegisteredClaims: jwt.RegisteredClaims{
|
||||
Subject: account.Email,
|
||||
Subject: account.ID,
|
||||
ExpiresAt: expires_at,
|
||||
},
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -21,6 +21,98 @@ const (
|
|||
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
||||
)
|
||||
|
||||
type AccountTypeRequest_AccountType int32
|
||||
|
||||
const (
|
||||
AccountTypeRequest_PASSENGER AccountTypeRequest_AccountType = 0
|
||||
AccountTypeRequest_DRIVER AccountTypeRequest_AccountType = 1
|
||||
)
|
||||
|
||||
// Enum value maps for AccountTypeRequest_AccountType.
|
||||
var (
|
||||
AccountTypeRequest_AccountType_name = map[int32]string{
|
||||
0: "PASSENGER",
|
||||
1: "DRIVER",
|
||||
}
|
||||
AccountTypeRequest_AccountType_value = map[string]int32{
|
||||
"PASSENGER": 0,
|
||||
"DRIVER": 1,
|
||||
}
|
||||
)
|
||||
|
||||
func (x AccountTypeRequest_AccountType) Enum() *AccountTypeRequest_AccountType {
|
||||
p := new(AccountTypeRequest_AccountType)
|
||||
*p = x
|
||||
return p
|
||||
}
|
||||
|
||||
func (x AccountTypeRequest_AccountType) String() string {
|
||||
return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x))
|
||||
}
|
||||
|
||||
func (AccountTypeRequest_AccountType) Descriptor() protoreflect.EnumDescriptor {
|
||||
return file_silvermobi_service_proto_enumTypes[0].Descriptor()
|
||||
}
|
||||
|
||||
func (AccountTypeRequest_AccountType) Type() protoreflect.EnumType {
|
||||
return &file_silvermobi_service_proto_enumTypes[0]
|
||||
}
|
||||
|
||||
func (x AccountTypeRequest_AccountType) Number() protoreflect.EnumNumber {
|
||||
return protoreflect.EnumNumber(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use AccountTypeRequest_AccountType.Descriptor instead.
|
||||
func (AccountTypeRequest_AccountType) EnumDescriptor() ([]byte, []int) {
|
||||
return file_silvermobi_service_proto_rawDescGZIP(), []int{20, 0}
|
||||
}
|
||||
|
||||
type AccountTypeResponse_AccountType int32
|
||||
|
||||
const (
|
||||
AccountTypeResponse_PASSENGER AccountTypeResponse_AccountType = 0
|
||||
AccountTypeResponse_DRIVER AccountTypeResponse_AccountType = 1
|
||||
)
|
||||
|
||||
// Enum value maps for AccountTypeResponse_AccountType.
|
||||
var (
|
||||
AccountTypeResponse_AccountType_name = map[int32]string{
|
||||
0: "PASSENGER",
|
||||
1: "DRIVER",
|
||||
}
|
||||
AccountTypeResponse_AccountType_value = map[string]int32{
|
||||
"PASSENGER": 0,
|
||||
"DRIVER": 1,
|
||||
}
|
||||
)
|
||||
|
||||
func (x AccountTypeResponse_AccountType) Enum() *AccountTypeResponse_AccountType {
|
||||
p := new(AccountTypeResponse_AccountType)
|
||||
*p = x
|
||||
return p
|
||||
}
|
||||
|
||||
func (x AccountTypeResponse_AccountType) String() string {
|
||||
return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x))
|
||||
}
|
||||
|
||||
func (AccountTypeResponse_AccountType) Descriptor() protoreflect.EnumDescriptor {
|
||||
return file_silvermobi_service_proto_enumTypes[1].Descriptor()
|
||||
}
|
||||
|
||||
func (AccountTypeResponse_AccountType) Type() protoreflect.EnumType {
|
||||
return &file_silvermobi_service_proto_enumTypes[1]
|
||||
}
|
||||
|
||||
func (x AccountTypeResponse_AccountType) Number() protoreflect.EnumNumber {
|
||||
return protoreflect.EnumNumber(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use AccountTypeResponse_AccountType.Descriptor instead.
|
||||
func (AccountTypeResponse_AccountType) EnumDescriptor() ([]byte, []int) {
|
||||
return file_silvermobi_service_proto_rawDescGZIP(), []int{21, 0}
|
||||
}
|
||||
|
||||
type AuthLoginRequest struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
|
@ -467,7 +559,6 @@ type SetPhoneNumberRequest struct {
|
|||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
PhoneNumber string `protobuf:"bytes,1,opt,name=phone_number,json=phoneNumber,proto3" json:"phone_number,omitempty"`
|
||||
Email string `protobuf:"bytes,2,opt,name=email,proto3" json:"email,omitempty"`
|
||||
}
|
||||
|
||||
func (x *SetPhoneNumberRequest) Reset() {
|
||||
|
@ -509,13 +600,6 @@ func (x *SetPhoneNumberRequest) GetPhoneNumber() string {
|
|||
return ""
|
||||
}
|
||||
|
||||
func (x *SetPhoneNumberRequest) GetEmail() string {
|
||||
if x != nil {
|
||||
return x.Email
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type SetPhoneNumberResponse struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
|
@ -570,7 +654,6 @@ type VerifyPhoneNumberRequest struct {
|
|||
|
||||
PhoneNumber string `protobuf:"bytes,1,opt,name=phone_number,json=phoneNumber,proto3" json:"phone_number,omitempty"`
|
||||
VerificationCode string `protobuf:"bytes,2,opt,name=verification_code,json=verificationCode,proto3" json:"verification_code,omitempty"`
|
||||
Email string `protobuf:"bytes,3,opt,name=email,proto3" json:"email,omitempty"`
|
||||
}
|
||||
|
||||
func (x *VerifyPhoneNumberRequest) Reset() {
|
||||
|
@ -619,13 +702,6 @@ func (x *VerifyPhoneNumberRequest) GetVerificationCode() string {
|
|||
return ""
|
||||
}
|
||||
|
||||
func (x *VerifyPhoneNumberRequest) GetEmail() string {
|
||||
if x != nil {
|
||||
return x.Email
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type VerifyPhoneNumberResponse struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
|
@ -679,7 +755,6 @@ type BirthDateRequest struct {
|
|||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Birthdate *timestamp.Timestamp `protobuf:"bytes,1,opt,name=birthdate,proto3" json:"birthdate,omitempty"`
|
||||
Email string `protobuf:"bytes,2,opt,name=email,proto3" json:"email,omitempty"`
|
||||
}
|
||||
|
||||
func (x *BirthDateRequest) Reset() {
|
||||
|
@ -721,13 +796,6 @@ func (x *BirthDateRequest) GetBirthdate() *timestamp.Timestamp {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (x *BirthDateRequest) GetEmail() string {
|
||||
if x != nil {
|
||||
return x.Email
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type BirthDateResponse struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
|
@ -975,8 +1043,6 @@ type ValidationRequest struct {
|
|||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Email string `protobuf:"bytes,1,opt,name=email,proto3" json:"email,omitempty"`
|
||||
}
|
||||
|
||||
func (x *ValidationRequest) Reset() {
|
||||
|
@ -1011,13 +1077,6 @@ func (*ValidationRequest) Descriptor() ([]byte, []int) {
|
|||
return file_silvermobi_service_proto_rawDescGZIP(), []int{18}
|
||||
}
|
||||
|
||||
func (x *ValidationRequest) GetEmail() string {
|
||||
if x != nil {
|
||||
return x.Email
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type ValidationResponse struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
|
@ -1025,6 +1084,7 @@ type ValidationResponse struct {
|
|||
|
||||
Phone bool `protobuf:"varint,1,opt,name=phone,proto3" json:"phone,omitempty"`
|
||||
Birthdate bool `protobuf:"varint,2,opt,name=birthdate,proto3" json:"birthdate,omitempty"`
|
||||
Type bool `protobuf:"varint,3,opt,name=type,proto3" json:"type,omitempty"`
|
||||
}
|
||||
|
||||
func (x *ValidationResponse) Reset() {
|
||||
|
@ -1073,6 +1133,123 @@ func (x *ValidationResponse) GetBirthdate() bool {
|
|||
return false
|
||||
}
|
||||
|
||||
func (x *ValidationResponse) GetType() bool {
|
||||
if x != nil {
|
||||
return x.Type
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
type AccountTypeRequest struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Request *bool `protobuf:"varint,2,opt,name=request,proto3,oneof" json:"request,omitempty"`
|
||||
Type *AccountTypeRequest_AccountType `protobuf:"varint,1,opt,name=type,proto3,enum=AccountTypeRequest_AccountType,oneof" json:"type,omitempty"`
|
||||
}
|
||||
|
||||
func (x *AccountTypeRequest) Reset() {
|
||||
*x = AccountTypeRequest{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_silvermobi_service_proto_msgTypes[20]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *AccountTypeRequest) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*AccountTypeRequest) ProtoMessage() {}
|
||||
|
||||
func (x *AccountTypeRequest) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_silvermobi_service_proto_msgTypes[20]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use AccountTypeRequest.ProtoReflect.Descriptor instead.
|
||||
func (*AccountTypeRequest) Descriptor() ([]byte, []int) {
|
||||
return file_silvermobi_service_proto_rawDescGZIP(), []int{20}
|
||||
}
|
||||
|
||||
func (x *AccountTypeRequest) GetRequest() bool {
|
||||
if x != nil && x.Request != nil {
|
||||
return *x.Request
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (x *AccountTypeRequest) GetType() AccountTypeRequest_AccountType {
|
||||
if x != nil && x.Type != nil {
|
||||
return *x.Type
|
||||
}
|
||||
return AccountTypeRequest_PASSENGER
|
||||
}
|
||||
|
||||
type AccountTypeResponse struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Ok bool `protobuf:"varint,1,opt,name=ok,proto3" json:"ok,omitempty"`
|
||||
Type *AccountTypeResponse_AccountType `protobuf:"varint,2,opt,name=type,proto3,enum=AccountTypeResponse_AccountType,oneof" json:"type,omitempty"`
|
||||
}
|
||||
|
||||
func (x *AccountTypeResponse) Reset() {
|
||||
*x = AccountTypeResponse{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_silvermobi_service_proto_msgTypes[21]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *AccountTypeResponse) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*AccountTypeResponse) ProtoMessage() {}
|
||||
|
||||
func (x *AccountTypeResponse) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_silvermobi_service_proto_msgTypes[21]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use AccountTypeResponse.ProtoReflect.Descriptor instead.
|
||||
func (*AccountTypeResponse) Descriptor() ([]byte, []int) {
|
||||
return file_silvermobi_service_proto_rawDescGZIP(), []int{21}
|
||||
}
|
||||
|
||||
func (x *AccountTypeResponse) GetOk() bool {
|
||||
if x != nil {
|
||||
return x.Ok
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (x *AccountTypeResponse) GetType() AccountTypeResponse_AccountType {
|
||||
if x != nil && x.Type != nil {
|
||||
return *x.Type
|
||||
}
|
||||
return AccountTypeResponse_PASSENGER
|
||||
}
|
||||
|
||||
var File_silvermobi_service_proto protoreflect.FileDescriptor
|
||||
|
||||
var file_silvermobi_service_proto_rawDesc = []byte{
|
||||
|
@ -1119,52 +1296,68 @@ var file_silvermobi_service_proto_rawDesc = []byte{
|
|||
0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x61, 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x52, 0x65,
|
||||
0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e,
|
||||
0x73, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e,
|
||||
0x73, 0x65, 0x22, 0x50, 0x0a, 0x15, 0x53, 0x65, 0x74, 0x50, 0x68, 0x6f, 0x6e, 0x65, 0x4e, 0x75,
|
||||
0x73, 0x65, 0x22, 0x3a, 0x0a, 0x15, 0x53, 0x65, 0x74, 0x50, 0x68, 0x6f, 0x6e, 0x65, 0x4e, 0x75,
|
||||
0x6d, 0x62, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x21, 0x0a, 0x0c, 0x70,
|
||||
0x68, 0x6f, 0x6e, 0x65, 0x5f, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28,
|
||||
0x09, 0x52, 0x0b, 0x70, 0x68, 0x6f, 0x6e, 0x65, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x12, 0x14,
|
||||
0x0a, 0x05, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x65,
|
||||
0x6d, 0x61, 0x69, 0x6c, 0x22, 0x28, 0x0a, 0x16, 0x53, 0x65, 0x74, 0x50, 0x68, 0x6f, 0x6e, 0x65,
|
||||
0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x0e,
|
||||
0x0a, 0x02, 0x6f, 0x6b, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x02, 0x6f, 0x6b, 0x22, 0x80,
|
||||
0x01, 0x0a, 0x18, 0x56, 0x65, 0x72, 0x69, 0x66, 0x79, 0x50, 0x68, 0x6f, 0x6e, 0x65, 0x4e, 0x75,
|
||||
0x6d, 0x62, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x21, 0x0a, 0x0c, 0x70,
|
||||
0x68, 0x6f, 0x6e, 0x65, 0x5f, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28,
|
||||
0x09, 0x52, 0x0b, 0x70, 0x68, 0x6f, 0x6e, 0x65, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x12, 0x2b,
|
||||
0x0a, 0x11, 0x76, 0x65, 0x72, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x63,
|
||||
0x6f, 0x64, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x10, 0x76, 0x65, 0x72, 0x69, 0x66,
|
||||
0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x65,
|
||||
0x6d, 0x61, 0x69, 0x6c, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x65, 0x6d, 0x61, 0x69,
|
||||
0x6c, 0x22, 0x2b, 0x0a, 0x19, 0x56, 0x65, 0x72, 0x69, 0x66, 0x79, 0x50, 0x68, 0x6f, 0x6e, 0x65,
|
||||
0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x0e,
|
||||
0x0a, 0x02, 0x6f, 0x6b, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x02, 0x6f, 0x6b, 0x22, 0x62,
|
||||
0x0a, 0x10, 0x42, 0x69, 0x72, 0x74, 0x68, 0x44, 0x61, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65,
|
||||
0x73, 0x74, 0x12, 0x38, 0x0a, 0x09, 0x62, 0x69, 0x72, 0x74, 0x68, 0x64, 0x61, 0x74, 0x65, 0x18,
|
||||
0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70,
|
||||
0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d,
|
||||
0x70, 0x52, 0x09, 0x62, 0x69, 0x72, 0x74, 0x68, 0x64, 0x61, 0x74, 0x65, 0x12, 0x14, 0x0a, 0x05,
|
||||
0x65, 0x6d, 0x61, 0x69, 0x6c, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x65, 0x6d, 0x61,
|
||||
0x69, 0x6c, 0x22, 0x23, 0x0a, 0x11, 0x42, 0x69, 0x72, 0x74, 0x68, 0x44, 0x61, 0x74, 0x65, 0x52,
|
||||
0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x6f, 0x6b, 0x18, 0x01, 0x20,
|
||||
0x01, 0x28, 0x08, 0x52, 0x02, 0x6f, 0x6b, 0x22, 0x39, 0x0a, 0x0f, 0x4b, 0x65, 0x79, 0x56, 0x61,
|
||||
0x6c, 0x75, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65,
|
||||
0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05,
|
||||
0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c,
|
||||
0x75, 0x65, 0x22, 0x22, 0x0a, 0x10, 0x4b, 0x65, 0x79, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x65,
|
||||
0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x6f, 0x6b, 0x18, 0x01, 0x20, 0x01,
|
||||
0x28, 0x08, 0x52, 0x02, 0x6f, 0x6b, 0x22, 0x1e, 0x0a, 0x0a, 0x4b, 0x65, 0x79, 0x52, 0x65, 0x71,
|
||||
0x75, 0x65, 0x73, 0x74, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28,
|
||||
0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x22, 0x25, 0x0a, 0x0d, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52,
|
||||
0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65,
|
||||
0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x22, 0x29, 0x0a,
|
||||
0x11, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65,
|
||||
0x73, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28,
|
||||
0x09, 0x52, 0x05, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x22, 0x48, 0x0a, 0x12, 0x56, 0x61, 0x6c, 0x69,
|
||||
0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x14,
|
||||
0x0a, 0x05, 0x70, 0x68, 0x6f, 0x6e, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x05, 0x70,
|
||||
0x68, 0x6f, 0x6e, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x62, 0x69, 0x72, 0x74, 0x68, 0x64, 0x61, 0x74,
|
||||
0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x09, 0x62, 0x69, 0x72, 0x74, 0x68, 0x64, 0x61,
|
||||
0x74, 0x65, 0x32, 0xf8, 0x04, 0x0a, 0x0e, 0x53, 0x69, 0x6c, 0x76, 0x65, 0x72, 0x6d, 0x6f, 0x62,
|
||||
0x09, 0x52, 0x0b, 0x70, 0x68, 0x6f, 0x6e, 0x65, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x22, 0x28,
|
||||
0x0a, 0x16, 0x53, 0x65, 0x74, 0x50, 0x68, 0x6f, 0x6e, 0x65, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72,
|
||||
0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x6f, 0x6b, 0x18, 0x01,
|
||||
0x20, 0x01, 0x28, 0x08, 0x52, 0x02, 0x6f, 0x6b, 0x22, 0x6a, 0x0a, 0x18, 0x56, 0x65, 0x72, 0x69,
|
||||
0x66, 0x79, 0x50, 0x68, 0x6f, 0x6e, 0x65, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x52, 0x65, 0x71,
|
||||
0x75, 0x65, 0x73, 0x74, 0x12, 0x21, 0x0a, 0x0c, 0x70, 0x68, 0x6f, 0x6e, 0x65, 0x5f, 0x6e, 0x75,
|
||||
0x6d, 0x62, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x70, 0x68, 0x6f, 0x6e,
|
||||
0x65, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x12, 0x2b, 0x0a, 0x11, 0x76, 0x65, 0x72, 0x69, 0x66,
|
||||
0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x02, 0x20, 0x01,
|
||||
0x28, 0x09, 0x52, 0x10, 0x76, 0x65, 0x72, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e,
|
||||
0x43, 0x6f, 0x64, 0x65, 0x22, 0x2b, 0x0a, 0x19, 0x56, 0x65, 0x72, 0x69, 0x66, 0x79, 0x50, 0x68,
|
||||
0x6f, 0x6e, 0x65, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73,
|
||||
0x65, 0x12, 0x0e, 0x0a, 0x02, 0x6f, 0x6b, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x02, 0x6f,
|
||||
0x6b, 0x22, 0x4c, 0x0a, 0x10, 0x42, 0x69, 0x72, 0x74, 0x68, 0x44, 0x61, 0x74, 0x65, 0x52, 0x65,
|
||||
0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x38, 0x0a, 0x09, 0x62, 0x69, 0x72, 0x74, 0x68, 0x64, 0x61,
|
||||
0x74, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c,
|
||||
0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73,
|
||||
0x74, 0x61, 0x6d, 0x70, 0x52, 0x09, 0x62, 0x69, 0x72, 0x74, 0x68, 0x64, 0x61, 0x74, 0x65, 0x22,
|
||||
0x23, 0x0a, 0x11, 0x42, 0x69, 0x72, 0x74, 0x68, 0x44, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70,
|
||||
0x6f, 0x6e, 0x73, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x6f, 0x6b, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08,
|
||||
0x52, 0x02, 0x6f, 0x6b, 0x22, 0x39, 0x0a, 0x0f, 0x4b, 0x65, 0x79, 0x56, 0x61, 0x6c, 0x75, 0x65,
|
||||
0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01,
|
||||
0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c,
|
||||
0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x22,
|
||||
0x22, 0x0a, 0x10, 0x4b, 0x65, 0x79, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f,
|
||||
0x6e, 0x73, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x6f, 0x6b, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52,
|
||||
0x02, 0x6f, 0x6b, 0x22, 0x1e, 0x0a, 0x0a, 0x4b, 0x65, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73,
|
||||
0x74, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03,
|
||||
0x6b, 0x65, 0x79, 0x22, 0x25, 0x0a, 0x0d, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x65, 0x73, 0x70,
|
||||
0x6f, 0x6e, 0x73, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x01, 0x20,
|
||||
0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x22, 0x13, 0x0a, 0x11, 0x56, 0x61,
|
||||
0x6c, 0x69, 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22,
|
||||
0x5c, 0x0a, 0x12, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73,
|
||||
0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x70, 0x68, 0x6f, 0x6e, 0x65, 0x18, 0x01,
|
||||
0x20, 0x01, 0x28, 0x08, 0x52, 0x05, 0x70, 0x68, 0x6f, 0x6e, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x62,
|
||||
0x69, 0x72, 0x74, 0x68, 0x64, 0x61, 0x74, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x09,
|
||||
0x62, 0x69, 0x72, 0x74, 0x68, 0x64, 0x61, 0x74, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70,
|
||||
0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x22, 0xac, 0x01,
|
||||
0x0a, 0x12, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x54, 0x79, 0x70, 0x65, 0x52, 0x65, 0x71,
|
||||
0x75, 0x65, 0x73, 0x74, 0x12, 0x1d, 0x0a, 0x07, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x18,
|
||||
0x02, 0x20, 0x01, 0x28, 0x08, 0x48, 0x00, 0x52, 0x07, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74,
|
||||
0x88, 0x01, 0x01, 0x12, 0x38, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28,
|
||||
0x0e, 0x32, 0x1f, 0x2e, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x54, 0x79, 0x70, 0x65, 0x52,
|
||||
0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x2e, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x54, 0x79,
|
||||
0x70, 0x65, 0x48, 0x01, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x88, 0x01, 0x01, 0x22, 0x28, 0x0a,
|
||||
0x0b, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x54, 0x79, 0x70, 0x65, 0x12, 0x0d, 0x0a, 0x09,
|
||||
0x50, 0x41, 0x53, 0x53, 0x45, 0x4e, 0x47, 0x45, 0x52, 0x10, 0x00, 0x12, 0x0a, 0x0a, 0x06, 0x44,
|
||||
0x52, 0x49, 0x56, 0x45, 0x52, 0x10, 0x01, 0x42, 0x0a, 0x0a, 0x08, 0x5f, 0x72, 0x65, 0x71, 0x75,
|
||||
0x65, 0x73, 0x74, 0x42, 0x07, 0x0a, 0x05, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x22, 0x93, 0x01, 0x0a,
|
||||
0x13, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x54, 0x79, 0x70, 0x65, 0x52, 0x65, 0x73, 0x70,
|
||||
0x6f, 0x6e, 0x73, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x6f, 0x6b, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08,
|
||||
0x52, 0x02, 0x6f, 0x6b, 0x12, 0x39, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01,
|
||||
0x28, 0x0e, 0x32, 0x20, 0x2e, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x54, 0x79, 0x70, 0x65,
|
||||
0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x2e, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74,
|
||||
0x54, 0x79, 0x70, 0x65, 0x48, 0x00, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x88, 0x01, 0x01, 0x22,
|
||||
0x28, 0x0a, 0x0b, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x54, 0x79, 0x70, 0x65, 0x12, 0x0d,
|
||||
0x0a, 0x09, 0x50, 0x41, 0x53, 0x53, 0x45, 0x4e, 0x47, 0x45, 0x52, 0x10, 0x00, 0x12, 0x0a, 0x0a,
|
||||
0x06, 0x44, 0x52, 0x49, 0x56, 0x45, 0x52, 0x10, 0x01, 0x42, 0x07, 0x0a, 0x05, 0x5f, 0x74, 0x79,
|
||||
0x70, 0x65, 0x32, 0xf6, 0x05, 0x0a, 0x0e, 0x53, 0x69, 0x6c, 0x76, 0x65, 0x72, 0x6d, 0x6f, 0x62,
|
||||
0x69, 0x47, 0x52, 0x50, 0x43, 0x12, 0x34, 0x0a, 0x09, 0x41, 0x75, 0x74, 0x68, 0x4c, 0x6f, 0x67,
|
||||
0x69, 0x6e, 0x12, 0x11, 0x2e, 0x41, 0x75, 0x74, 0x68, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x52, 0x65,
|
||||
0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x12, 0x2e, 0x41, 0x75, 0x74, 0x68, 0x4c, 0x6f, 0x67, 0x69,
|
||||
|
@ -1193,21 +1386,29 @@ var file_silvermobi_service_proto_rawDesc = []byte{
|
|||
0x73, 0x65, 0x22, 0x00, 0x12, 0x37, 0x0a, 0x0c, 0x53, 0x65, 0x74, 0x42, 0x69, 0x72, 0x74, 0x68,
|
||||
0x44, 0x61, 0x74, 0x65, 0x12, 0x11, 0x2e, 0x42, 0x69, 0x72, 0x74, 0x68, 0x44, 0x61, 0x74, 0x65,
|
||||
0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x12, 0x2e, 0x42, 0x69, 0x72, 0x74, 0x68, 0x44,
|
||||
0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x34, 0x0a,
|
||||
0x0b, 0x53, 0x65, 0x74, 0x4b, 0x65, 0x79, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x10, 0x2e, 0x4b,
|
||||
0x65, 0x79, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x11,
|
||||
0x2e, 0x4b, 0x65, 0x79, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73,
|
||||
0x65, 0x22, 0x00, 0x12, 0x2c, 0x0a, 0x0b, 0x47, 0x65, 0x74, 0x4b, 0x65, 0x79, 0x56, 0x61, 0x6c,
|
||||
0x75, 0x65, 0x12, 0x0b, 0x2e, 0x4b, 0x65, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a,
|
||||
0x0e, 0x2e, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22,
|
||||
0x00, 0x12, 0x3a, 0x0a, 0x0d, 0x47, 0x65, 0x74, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x69,
|
||||
0x6f, 0x6e, 0x12, 0x12, 0x2e, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52,
|
||||
0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x13, 0x2e, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74,
|
||||
0x69, 0x6f, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x34, 0x5a,
|
||||
0x32, 0x67, 0x69, 0x74, 0x2e, 0x63, 0x6f, 0x6f, 0x70, 0x67, 0x6f, 0x2e, 0x69, 0x6f, 0x2f, 0x63,
|
||||
0x6f, 0x6f, 0x70, 0x67, 0x6f, 0x2d, 0x61, 0x70, 0x70, 0x73, 0x2f, 0x73, 0x69, 0x6c, 0x76, 0x65,
|
||||
0x72, 0x6d, 0x6f, 0x62, 0x69, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x61, 0x70, 0x69, 0x2f, 0x70, 0x72,
|
||||
0x6f, 0x74, 0x6f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x3d, 0x0a,
|
||||
0x0e, 0x53, 0x65, 0x74, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x54, 0x79, 0x70, 0x65, 0x12,
|
||||
0x13, 0x2e, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x54, 0x79, 0x70, 0x65, 0x52, 0x65, 0x71,
|
||||
0x75, 0x65, 0x73, 0x74, 0x1a, 0x14, 0x2e, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x54, 0x79,
|
||||
0x70, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x3d, 0x0a, 0x0e,
|
||||
0x47, 0x65, 0x74, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x54, 0x79, 0x70, 0x65, 0x12, 0x13,
|
||||
0x2e, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x54, 0x79, 0x70, 0x65, 0x52, 0x65, 0x71, 0x75,
|
||||
0x65, 0x73, 0x74, 0x1a, 0x14, 0x2e, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x54, 0x79, 0x70,
|
||||
0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x34, 0x0a, 0x0b, 0x53,
|
||||
0x65, 0x74, 0x4b, 0x65, 0x79, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x10, 0x2e, 0x4b, 0x65, 0x79,
|
||||
0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x11, 0x2e, 0x4b,
|
||||
0x65, 0x79, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22,
|
||||
0x00, 0x12, 0x2c, 0x0a, 0x0b, 0x47, 0x65, 0x74, 0x4b, 0x65, 0x79, 0x56, 0x61, 0x6c, 0x75, 0x65,
|
||||
0x12, 0x0b, 0x2e, 0x4b, 0x65, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0e, 0x2e,
|
||||
0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12,
|
||||
0x3a, 0x0a, 0x0d, 0x47, 0x65, 0x74, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e,
|
||||
0x12, 0x12, 0x2e, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71,
|
||||
0x75, 0x65, 0x73, 0x74, 0x1a, 0x13, 0x2e, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x69, 0x6f,
|
||||
0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x34, 0x5a, 0x32, 0x67,
|
||||
0x69, 0x74, 0x2e, 0x63, 0x6f, 0x6f, 0x70, 0x67, 0x6f, 0x2e, 0x69, 0x6f, 0x2f, 0x63, 0x6f, 0x6f,
|
||||
0x70, 0x67, 0x6f, 0x2d, 0x61, 0x70, 0x70, 0x73, 0x2f, 0x73, 0x69, 0x6c, 0x76, 0x65, 0x72, 0x6d,
|
||||
0x6f, 0x62, 0x69, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x61, 0x70, 0x69, 0x2f, 0x70, 0x72, 0x6f, 0x74,
|
||||
0x6f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
|
@ -1222,57 +1423,68 @@ func file_silvermobi_service_proto_rawDescGZIP() []byte {
|
|||
return file_silvermobi_service_proto_rawDescData
|
||||
}
|
||||
|
||||
var file_silvermobi_service_proto_msgTypes = make([]protoimpl.MessageInfo, 20)
|
||||
var file_silvermobi_service_proto_enumTypes = make([]protoimpl.EnumInfo, 2)
|
||||
var file_silvermobi_service_proto_msgTypes = make([]protoimpl.MessageInfo, 22)
|
||||
var file_silvermobi_service_proto_goTypes = []interface{}{
|
||||
(*AuthLoginRequest)(nil), // 0: AuthLoginRequest
|
||||
(*AuthLoginResponse)(nil), // 1: AuthLoginResponse
|
||||
(*AuthRegisterRequest)(nil), // 2: AuthRegisterRequest
|
||||
(*AuthRegisterResponse)(nil), // 3: AuthRegisterResponse
|
||||
(*ForgetAccountRequest)(nil), // 4: ForgetAccountRequest
|
||||
(*ForgetAccountResponse)(nil), // 5: ForgetAccountResponse
|
||||
(*UpdatePasswordRequest)(nil), // 6: UpdatePasswordRequest
|
||||
(*UpdatePasswordResponse)(nil), // 7: UpdatePasswordResponse
|
||||
(*SetPhoneNumberRequest)(nil), // 8: SetPhoneNumberRequest
|
||||
(*SetPhoneNumberResponse)(nil), // 9: SetPhoneNumberResponse
|
||||
(*VerifyPhoneNumberRequest)(nil), // 10: VerifyPhoneNumberRequest
|
||||
(*VerifyPhoneNumberResponse)(nil), // 11: VerifyPhoneNumberResponse
|
||||
(*BirthDateRequest)(nil), // 12: BirthDateRequest
|
||||
(*BirthDateResponse)(nil), // 13: BirthDateResponse
|
||||
(*KeyValueRequest)(nil), // 14: KeyValueRequest
|
||||
(*KeyValueResponse)(nil), // 15: KeyValueResponse
|
||||
(*KeyRequest)(nil), // 16: KeyRequest
|
||||
(*ValueResponse)(nil), // 17: ValueResponse
|
||||
(*ValidationRequest)(nil), // 18: ValidationRequest
|
||||
(*ValidationResponse)(nil), // 19: ValidationResponse
|
||||
(*timestamp.Timestamp)(nil), // 20: google.protobuf.Timestamp
|
||||
(AccountTypeRequest_AccountType)(0), // 0: AccountTypeRequest.AccountType
|
||||
(AccountTypeResponse_AccountType)(0), // 1: AccountTypeResponse.AccountType
|
||||
(*AuthLoginRequest)(nil), // 2: AuthLoginRequest
|
||||
(*AuthLoginResponse)(nil), // 3: AuthLoginResponse
|
||||
(*AuthRegisterRequest)(nil), // 4: AuthRegisterRequest
|
||||
(*AuthRegisterResponse)(nil), // 5: AuthRegisterResponse
|
||||
(*ForgetAccountRequest)(nil), // 6: ForgetAccountRequest
|
||||
(*ForgetAccountResponse)(nil), // 7: ForgetAccountResponse
|
||||
(*UpdatePasswordRequest)(nil), // 8: UpdatePasswordRequest
|
||||
(*UpdatePasswordResponse)(nil), // 9: UpdatePasswordResponse
|
||||
(*SetPhoneNumberRequest)(nil), // 10: SetPhoneNumberRequest
|
||||
(*SetPhoneNumberResponse)(nil), // 11: SetPhoneNumberResponse
|
||||
(*VerifyPhoneNumberRequest)(nil), // 12: VerifyPhoneNumberRequest
|
||||
(*VerifyPhoneNumberResponse)(nil), // 13: VerifyPhoneNumberResponse
|
||||
(*BirthDateRequest)(nil), // 14: BirthDateRequest
|
||||
(*BirthDateResponse)(nil), // 15: BirthDateResponse
|
||||
(*KeyValueRequest)(nil), // 16: KeyValueRequest
|
||||
(*KeyValueResponse)(nil), // 17: KeyValueResponse
|
||||
(*KeyRequest)(nil), // 18: KeyRequest
|
||||
(*ValueResponse)(nil), // 19: ValueResponse
|
||||
(*ValidationRequest)(nil), // 20: ValidationRequest
|
||||
(*ValidationResponse)(nil), // 21: ValidationResponse
|
||||
(*AccountTypeRequest)(nil), // 22: AccountTypeRequest
|
||||
(*AccountTypeResponse)(nil), // 23: AccountTypeResponse
|
||||
(*timestamp.Timestamp)(nil), // 24: google.protobuf.Timestamp
|
||||
}
|
||||
var file_silvermobi_service_proto_depIdxs = []int32{
|
||||
20, // 0: BirthDateRequest.birthdate:type_name -> google.protobuf.Timestamp
|
||||
0, // 1: SilvermobiGRPC.AuthLogin:input_type -> AuthLoginRequest
|
||||
2, // 2: SilvermobiGRPC.AuthRegister:input_type -> AuthRegisterRequest
|
||||
4, // 3: SilvermobiGRPC.ForgetAccount:input_type -> ForgetAccountRequest
|
||||
6, // 4: SilvermobiGRPC.UpdatePassword:input_type -> UpdatePasswordRequest
|
||||
8, // 5: SilvermobiGRPC.SetPhoneNumber:input_type -> SetPhoneNumberRequest
|
||||
10, // 6: SilvermobiGRPC.VerifyPhoneNumber:input_type -> VerifyPhoneNumberRequest
|
||||
12, // 7: SilvermobiGRPC.SetBirthDate:input_type -> BirthDateRequest
|
||||
14, // 8: SilvermobiGRPC.SetKeyValue:input_type -> KeyValueRequest
|
||||
16, // 9: SilvermobiGRPC.GetKeyValue:input_type -> KeyRequest
|
||||
18, // 10: SilvermobiGRPC.GetValidation:input_type -> ValidationRequest
|
||||
1, // 11: SilvermobiGRPC.AuthLogin:output_type -> AuthLoginResponse
|
||||
3, // 12: SilvermobiGRPC.AuthRegister:output_type -> AuthRegisterResponse
|
||||
5, // 13: SilvermobiGRPC.ForgetAccount:output_type -> ForgetAccountResponse
|
||||
7, // 14: SilvermobiGRPC.UpdatePassword:output_type -> UpdatePasswordResponse
|
||||
9, // 15: SilvermobiGRPC.SetPhoneNumber:output_type -> SetPhoneNumberResponse
|
||||
11, // 16: SilvermobiGRPC.VerifyPhoneNumber:output_type -> VerifyPhoneNumberResponse
|
||||
13, // 17: SilvermobiGRPC.SetBirthDate:output_type -> BirthDateResponse
|
||||
15, // 18: SilvermobiGRPC.SetKeyValue:output_type -> KeyValueResponse
|
||||
17, // 19: SilvermobiGRPC.GetKeyValue:output_type -> ValueResponse
|
||||
19, // 20: SilvermobiGRPC.GetValidation:output_type -> ValidationResponse
|
||||
11, // [11:21] is the sub-list for method output_type
|
||||
1, // [1:11] is the sub-list for method input_type
|
||||
1, // [1:1] is the sub-list for extension type_name
|
||||
1, // [1:1] is the sub-list for extension extendee
|
||||
0, // [0:1] is the sub-list for field type_name
|
||||
24, // 0: BirthDateRequest.birthdate:type_name -> google.protobuf.Timestamp
|
||||
0, // 1: AccountTypeRequest.type:type_name -> AccountTypeRequest.AccountType
|
||||
1, // 2: AccountTypeResponse.type:type_name -> AccountTypeResponse.AccountType
|
||||
2, // 3: SilvermobiGRPC.AuthLogin:input_type -> AuthLoginRequest
|
||||
4, // 4: SilvermobiGRPC.AuthRegister:input_type -> AuthRegisterRequest
|
||||
6, // 5: SilvermobiGRPC.ForgetAccount:input_type -> ForgetAccountRequest
|
||||
8, // 6: SilvermobiGRPC.UpdatePassword:input_type -> UpdatePasswordRequest
|
||||
10, // 7: SilvermobiGRPC.SetPhoneNumber:input_type -> SetPhoneNumberRequest
|
||||
12, // 8: SilvermobiGRPC.VerifyPhoneNumber:input_type -> VerifyPhoneNumberRequest
|
||||
14, // 9: SilvermobiGRPC.SetBirthDate:input_type -> BirthDateRequest
|
||||
22, // 10: SilvermobiGRPC.SetAccountType:input_type -> AccountTypeRequest
|
||||
22, // 11: SilvermobiGRPC.GetAccountType:input_type -> AccountTypeRequest
|
||||
16, // 12: SilvermobiGRPC.SetKeyValue:input_type -> KeyValueRequest
|
||||
18, // 13: SilvermobiGRPC.GetKeyValue:input_type -> KeyRequest
|
||||
20, // 14: SilvermobiGRPC.GetValidation:input_type -> ValidationRequest
|
||||
3, // 15: SilvermobiGRPC.AuthLogin:output_type -> AuthLoginResponse
|
||||
5, // 16: SilvermobiGRPC.AuthRegister:output_type -> AuthRegisterResponse
|
||||
7, // 17: SilvermobiGRPC.ForgetAccount:output_type -> ForgetAccountResponse
|
||||
9, // 18: SilvermobiGRPC.UpdatePassword:output_type -> UpdatePasswordResponse
|
||||
11, // 19: SilvermobiGRPC.SetPhoneNumber:output_type -> SetPhoneNumberResponse
|
||||
13, // 20: SilvermobiGRPC.VerifyPhoneNumber:output_type -> VerifyPhoneNumberResponse
|
||||
15, // 21: SilvermobiGRPC.SetBirthDate:output_type -> BirthDateResponse
|
||||
23, // 22: SilvermobiGRPC.SetAccountType:output_type -> AccountTypeResponse
|
||||
23, // 23: SilvermobiGRPC.GetAccountType:output_type -> AccountTypeResponse
|
||||
17, // 24: SilvermobiGRPC.SetKeyValue:output_type -> KeyValueResponse
|
||||
19, // 25: SilvermobiGRPC.GetKeyValue:output_type -> ValueResponse
|
||||
21, // 26: SilvermobiGRPC.GetValidation:output_type -> ValidationResponse
|
||||
15, // [15:27] is the sub-list for method output_type
|
||||
3, // [3:15] is the sub-list for method input_type
|
||||
3, // [3:3] is the sub-list for extension type_name
|
||||
3, // [3:3] is the sub-list for extension extendee
|
||||
0, // [0:3] is the sub-list for field type_name
|
||||
}
|
||||
|
||||
func init() { file_silvermobi_service_proto_init() }
|
||||
|
@ -1521,19 +1733,46 @@ func file_silvermobi_service_proto_init() {
|
|||
return nil
|
||||
}
|
||||
}
|
||||
file_silvermobi_service_proto_msgTypes[20].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*AccountTypeRequest); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_silvermobi_service_proto_msgTypes[21].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*AccountTypeResponse); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
file_silvermobi_service_proto_msgTypes[20].OneofWrappers = []interface{}{}
|
||||
file_silvermobi_service_proto_msgTypes[21].OneofWrappers = []interface{}{}
|
||||
type x struct{}
|
||||
out := protoimpl.TypeBuilder{
|
||||
File: protoimpl.DescBuilder{
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: file_silvermobi_service_proto_rawDesc,
|
||||
NumEnums: 0,
|
||||
NumMessages: 20,
|
||||
NumEnums: 2,
|
||||
NumMessages: 22,
|
||||
NumExtensions: 0,
|
||||
NumServices: 1,
|
||||
},
|
||||
GoTypes: file_silvermobi_service_proto_goTypes,
|
||||
DependencyIndexes: file_silvermobi_service_proto_depIdxs,
|
||||
EnumInfos: file_silvermobi_service_proto_enumTypes,
|
||||
MessageInfos: file_silvermobi_service_proto_msgTypes,
|
||||
}.Build()
|
||||
File_silvermobi_service_proto = out.File
|
||||
|
|
|
@ -3,17 +3,16 @@ import "google/protobuf/timestamp.proto";
|
|||
option go_package = "git.coopgo.io/coopgo-apps/silvermobi/grpcapi/proto";
|
||||
|
||||
service SilvermobiGRPC {
|
||||
// User authentication functions
|
||||
|
||||
rpc AuthLogin(AuthLoginRequest) returns (AuthLoginResponse) {}
|
||||
rpc AuthRegister(AuthRegisterRequest) returns (AuthRegisterResponse) {}
|
||||
// User forget password
|
||||
rpc ForgetAccount(ForgetAccountRequest) returns (ForgetAccountResponse) {}
|
||||
rpc UpdatePassword(UpdatePasswordRequest) returns (UpdatePasswordResponse) {}
|
||||
// phone_number
|
||||
rpc SetPhoneNumber(SetPhoneNumberRequest) returns (SetPhoneNumberResponse) {}
|
||||
rpc VerifyPhoneNumber(VerifyPhoneNumberRequest) returns (VerifyPhoneNumberResponse) {}
|
||||
rpc SetBirthDate(BirthDateRequest) returns (BirthDateResponse) {}
|
||||
// redis
|
||||
rpc SetAccountType(AccountTypeRequest) returns (AccountTypeResponse) {}
|
||||
rpc GetAccountType(AccountTypeRequest) returns (AccountTypeResponse) {}
|
||||
rpc SetKeyValue(KeyValueRequest) returns (KeyValueResponse) {}
|
||||
rpc GetKeyValue(KeyRequest) returns (ValueResponse) {}
|
||||
rpc GetValidation(ValidationRequest) returns (ValidationResponse) {}
|
||||
|
@ -63,7 +62,6 @@ message UpdatePasswordResponse{
|
|||
|
||||
message SetPhoneNumberRequest {
|
||||
string phone_number = 1;
|
||||
string email = 2;
|
||||
}
|
||||
|
||||
message SetPhoneNumberResponse {
|
||||
|
@ -73,7 +71,6 @@ message SetPhoneNumberResponse {
|
|||
message VerifyPhoneNumberRequest {
|
||||
string phone_number = 1;
|
||||
string verification_code = 2;
|
||||
string email = 3;
|
||||
}
|
||||
|
||||
message VerifyPhoneNumberResponse {
|
||||
|
@ -82,7 +79,6 @@ message VerifyPhoneNumberResponse {
|
|||
|
||||
message BirthDateRequest {
|
||||
google.protobuf.Timestamp birthdate = 1 ;
|
||||
string email = 2;
|
||||
}
|
||||
|
||||
message BirthDateResponse {
|
||||
|
@ -106,10 +102,28 @@ message ValueResponse{
|
|||
}
|
||||
|
||||
message ValidationRequest {
|
||||
string email =1 ;
|
||||
}
|
||||
|
||||
message ValidationResponse {
|
||||
bool phone = 1 ;
|
||||
bool birthdate = 2;
|
||||
bool type = 3;
|
||||
}
|
||||
|
||||
message AccountTypeRequest {
|
||||
enum AccountType {
|
||||
PASSENGER = 0;
|
||||
DRIVER = 1;
|
||||
}
|
||||
optional bool request = 2;
|
||||
optional AccountType type = 1;
|
||||
}
|
||||
|
||||
message AccountTypeResponse {
|
||||
bool ok = 1 ;
|
||||
enum AccountType {
|
||||
PASSENGER = 0;
|
||||
DRIVER = 1;
|
||||
}
|
||||
optional AccountType type = 2;
|
||||
}
|
|
@ -26,6 +26,8 @@ const (
|
|||
SilvermobiGRPC_SetPhoneNumber_FullMethodName = "/SilvermobiGRPC/SetPhoneNumber"
|
||||
SilvermobiGRPC_VerifyPhoneNumber_FullMethodName = "/SilvermobiGRPC/VerifyPhoneNumber"
|
||||
SilvermobiGRPC_SetBirthDate_FullMethodName = "/SilvermobiGRPC/SetBirthDate"
|
||||
SilvermobiGRPC_SetAccountType_FullMethodName = "/SilvermobiGRPC/SetAccountType"
|
||||
SilvermobiGRPC_GetAccountType_FullMethodName = "/SilvermobiGRPC/GetAccountType"
|
||||
SilvermobiGRPC_SetKeyValue_FullMethodName = "/SilvermobiGRPC/SetKeyValue"
|
||||
SilvermobiGRPC_GetKeyValue_FullMethodName = "/SilvermobiGRPC/GetKeyValue"
|
||||
SilvermobiGRPC_GetValidation_FullMethodName = "/SilvermobiGRPC/GetValidation"
|
||||
|
@ -35,17 +37,15 @@ const (
|
|||
//
|
||||
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
|
||||
type SilvermobiGRPCClient interface {
|
||||
// User authentication functions
|
||||
AuthLogin(ctx context.Context, in *AuthLoginRequest, opts ...grpc.CallOption) (*AuthLoginResponse, error)
|
||||
AuthRegister(ctx context.Context, in *AuthRegisterRequest, opts ...grpc.CallOption) (*AuthRegisterResponse, error)
|
||||
// User forget password
|
||||
ForgetAccount(ctx context.Context, in *ForgetAccountRequest, opts ...grpc.CallOption) (*ForgetAccountResponse, error)
|
||||
UpdatePassword(ctx context.Context, in *UpdatePasswordRequest, opts ...grpc.CallOption) (*UpdatePasswordResponse, error)
|
||||
// phone_number
|
||||
SetPhoneNumber(ctx context.Context, in *SetPhoneNumberRequest, opts ...grpc.CallOption) (*SetPhoneNumberResponse, error)
|
||||
VerifyPhoneNumber(ctx context.Context, in *VerifyPhoneNumberRequest, opts ...grpc.CallOption) (*VerifyPhoneNumberResponse, error)
|
||||
SetBirthDate(ctx context.Context, in *BirthDateRequest, opts ...grpc.CallOption) (*BirthDateResponse, error)
|
||||
// redis
|
||||
SetAccountType(ctx context.Context, in *AccountTypeRequest, opts ...grpc.CallOption) (*AccountTypeResponse, error)
|
||||
GetAccountType(ctx context.Context, in *AccountTypeRequest, opts ...grpc.CallOption) (*AccountTypeResponse, error)
|
||||
SetKeyValue(ctx context.Context, in *KeyValueRequest, opts ...grpc.CallOption) (*KeyValueResponse, error)
|
||||
GetKeyValue(ctx context.Context, in *KeyRequest, opts ...grpc.CallOption) (*ValueResponse, error)
|
||||
GetValidation(ctx context.Context, in *ValidationRequest, opts ...grpc.CallOption) (*ValidationResponse, error)
|
||||
|
@ -122,6 +122,24 @@ func (c *silvermobiGRPCClient) SetBirthDate(ctx context.Context, in *BirthDateRe
|
|||
return out, nil
|
||||
}
|
||||
|
||||
func (c *silvermobiGRPCClient) SetAccountType(ctx context.Context, in *AccountTypeRequest, opts ...grpc.CallOption) (*AccountTypeResponse, error) {
|
||||
out := new(AccountTypeResponse)
|
||||
err := c.cc.Invoke(ctx, SilvermobiGRPC_SetAccountType_FullMethodName, in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *silvermobiGRPCClient) GetAccountType(ctx context.Context, in *AccountTypeRequest, opts ...grpc.CallOption) (*AccountTypeResponse, error) {
|
||||
out := new(AccountTypeResponse)
|
||||
err := c.cc.Invoke(ctx, SilvermobiGRPC_GetAccountType_FullMethodName, in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *silvermobiGRPCClient) SetKeyValue(ctx context.Context, in *KeyValueRequest, opts ...grpc.CallOption) (*KeyValueResponse, error) {
|
||||
out := new(KeyValueResponse)
|
||||
err := c.cc.Invoke(ctx, SilvermobiGRPC_SetKeyValue_FullMethodName, in, out, opts...)
|
||||
|
@ -153,17 +171,15 @@ func (c *silvermobiGRPCClient) GetValidation(ctx context.Context, in *Validation
|
|||
// All implementations must embed UnimplementedSilvermobiGRPCServer
|
||||
// for forward compatibility
|
||||
type SilvermobiGRPCServer interface {
|
||||
// User authentication functions
|
||||
AuthLogin(context.Context, *AuthLoginRequest) (*AuthLoginResponse, error)
|
||||
AuthRegister(context.Context, *AuthRegisterRequest) (*AuthRegisterResponse, error)
|
||||
// User forget password
|
||||
ForgetAccount(context.Context, *ForgetAccountRequest) (*ForgetAccountResponse, error)
|
||||
UpdatePassword(context.Context, *UpdatePasswordRequest) (*UpdatePasswordResponse, error)
|
||||
// phone_number
|
||||
SetPhoneNumber(context.Context, *SetPhoneNumberRequest) (*SetPhoneNumberResponse, error)
|
||||
VerifyPhoneNumber(context.Context, *VerifyPhoneNumberRequest) (*VerifyPhoneNumberResponse, error)
|
||||
SetBirthDate(context.Context, *BirthDateRequest) (*BirthDateResponse, error)
|
||||
// redis
|
||||
SetAccountType(context.Context, *AccountTypeRequest) (*AccountTypeResponse, error)
|
||||
GetAccountType(context.Context, *AccountTypeRequest) (*AccountTypeResponse, error)
|
||||
SetKeyValue(context.Context, *KeyValueRequest) (*KeyValueResponse, error)
|
||||
GetKeyValue(context.Context, *KeyRequest) (*ValueResponse, error)
|
||||
GetValidation(context.Context, *ValidationRequest) (*ValidationResponse, error)
|
||||
|
@ -195,6 +211,12 @@ func (UnimplementedSilvermobiGRPCServer) VerifyPhoneNumber(context.Context, *Ver
|
|||
func (UnimplementedSilvermobiGRPCServer) SetBirthDate(context.Context, *BirthDateRequest) (*BirthDateResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method SetBirthDate not implemented")
|
||||
}
|
||||
func (UnimplementedSilvermobiGRPCServer) SetAccountType(context.Context, *AccountTypeRequest) (*AccountTypeResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method SetAccountType not implemented")
|
||||
}
|
||||
func (UnimplementedSilvermobiGRPCServer) GetAccountType(context.Context, *AccountTypeRequest) (*AccountTypeResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method GetAccountType not implemented")
|
||||
}
|
||||
func (UnimplementedSilvermobiGRPCServer) SetKeyValue(context.Context, *KeyValueRequest) (*KeyValueResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method SetKeyValue not implemented")
|
||||
}
|
||||
|
@ -343,6 +365,42 @@ func _SilvermobiGRPC_SetBirthDate_Handler(srv interface{}, ctx context.Context,
|
|||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _SilvermobiGRPC_SetAccountType_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(AccountTypeRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(SilvermobiGRPCServer).SetAccountType(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: SilvermobiGRPC_SetAccountType_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(SilvermobiGRPCServer).SetAccountType(ctx, req.(*AccountTypeRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _SilvermobiGRPC_GetAccountType_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(AccountTypeRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(SilvermobiGRPCServer).GetAccountType(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: SilvermobiGRPC_GetAccountType_FullMethodName,
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(SilvermobiGRPCServer).GetAccountType(ctx, req.(*AccountTypeRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _SilvermobiGRPC_SetKeyValue_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(KeyValueRequest)
|
||||
if err := dec(in); err != nil {
|
||||
|
@ -432,6 +490,14 @@ var SilvermobiGRPC_ServiceDesc = grpc.ServiceDesc{
|
|||
MethodName: "SetBirthDate",
|
||||
Handler: _SilvermobiGRPC_SetBirthDate_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "SetAccountType",
|
||||
Handler: _SilvermobiGRPC_SetAccountType_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "GetAccountType",
|
||||
Handler: _SilvermobiGRPC_GetAccountType_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "SetKeyValue",
|
||||
Handler: _SilvermobiGRPC_SetKeyValue_Handler,
|
||||
|
|
|
@ -2,14 +2,31 @@ package grpcserver
|
|||
|
||||
import (
|
||||
"context"
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
grpcproto "git.coopgo.io/coopgo-apps/silvermobi/servers/grpcapi/proto"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/metadata"
|
||||
"google.golang.org/grpc/status"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
func (s SilvermobiGRPCService) SetPhoneNumber(ctx context.Context, req *grpcproto.SetPhoneNumberRequest) (res *grpcproto.SetPhoneNumberResponse, err error) {
|
||||
md, ok := metadata.FromIncomingContext(ctx)
|
||||
if !ok {
|
||||
return nil, status.Errorf(codes.Unauthenticated, "Missing metadata")
|
||||
}
|
||||
|
||||
authHeader, ok := md["authorization"]
|
||||
if !ok || len(authHeader) == 0 {
|
||||
return nil, status.Errorf(codes.Unauthenticated, "Missing authorization header")
|
||||
}
|
||||
tokenString := strings.TrimPrefix(authHeader[0], "Bearer ")
|
||||
id := ExtractIdFromToken(tokenString)
|
||||
if err = s.Handler.UpdatePhoneNumber(
|
||||
context.Background(),
|
||||
req.Email,
|
||||
id,
|
||||
req.PhoneNumber,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
|
@ -19,10 +36,20 @@ func (s SilvermobiGRPCService) SetPhoneNumber(ctx context.Context, req *grpcprot
|
|||
}
|
||||
|
||||
func (s SilvermobiGRPCService) VerifyPhoneNumber(ctx context.Context, req *grpcproto.VerifyPhoneNumberRequest) (res *grpcproto.VerifyPhoneNumberResponse, err error) {
|
||||
md, ok := metadata.FromIncomingContext(ctx)
|
||||
if !ok {
|
||||
return nil, status.Errorf(codes.Unauthenticated, "Missing metadata")
|
||||
}
|
||||
|
||||
authHeader, ok := md["authorization"]
|
||||
if !ok || len(authHeader) == 0 {
|
||||
return nil, status.Errorf(codes.Unauthenticated, "Missing authorization header")
|
||||
}
|
||||
tokenString := strings.TrimPrefix(authHeader[0], "Bearer ")
|
||||
id := ExtractIdFromToken(tokenString)
|
||||
if err = s.Handler.VerifyPhoneNumber(
|
||||
context.Background(),
|
||||
req.Email,
|
||||
id,
|
||||
req.PhoneNumber,
|
||||
req.VerificationCode,
|
||||
); err != nil {
|
||||
|
@ -33,23 +60,126 @@ func (s SilvermobiGRPCService) VerifyPhoneNumber(ctx context.Context, req *grpcp
|
|||
}
|
||||
|
||||
func (s SilvermobiGRPCService) SetBirthDate(ctx context.Context, req *grpcproto.BirthDateRequest) (res *grpcproto.BirthDateResponse, err error) {
|
||||
md, ok := metadata.FromIncomingContext(ctx)
|
||||
if !ok {
|
||||
return nil, status.Errorf(codes.Unauthenticated, "Missing metadata")
|
||||
}
|
||||
|
||||
authHeader, ok := md["authorization"]
|
||||
if !ok || len(authHeader) == 0 {
|
||||
return nil, status.Errorf(codes.Unauthenticated, "Missing authorization header")
|
||||
}
|
||||
tokenString := strings.TrimPrefix(authHeader[0], "Bearer ")
|
||||
id := ExtractIdFromToken(tokenString)
|
||||
birthdate := time.Unix(req.Birthdate.Seconds, int64(req.Birthdate.Nanos)).UTC()
|
||||
birthdateString := birthdate.Format("2006-01-02T15:04:05Z")
|
||||
if err = s.Handler.UpdateBirthDate(ctx, req.Email, birthdateString); err != nil {
|
||||
if err = s.Handler.UpdateBirthDate(ctx, id, birthdateString); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &grpcproto.BirthDateResponse{
|
||||
Ok: true,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (s SilvermobiGRPCService) SetAccountType(ctx context.Context, req *grpcproto.AccountTypeRequest) (res *grpcproto.AccountTypeResponse, err error) {
|
||||
md, ok := metadata.FromIncomingContext(ctx)
|
||||
if !ok {
|
||||
return nil, status.Errorf(codes.Unauthenticated, "Missing metadata")
|
||||
}
|
||||
authHeader, ok := md["authorization"]
|
||||
if !ok || len(authHeader) == 0 {
|
||||
return nil, status.Errorf(codes.Unauthenticated, "Missing authorization header")
|
||||
}
|
||||
tokenString := strings.TrimPrefix(authHeader[0], "Bearer ")
|
||||
id := ExtractIdFromToken(tokenString)
|
||||
if req.GetType() != grpcproto.AccountTypeRequest_PASSENGER && req.GetType() != grpcproto.AccountTypeRequest_DRIVER {
|
||||
return nil, status.Errorf(codes.InvalidArgument, "Type should be PASSENGER or DRIVER")
|
||||
}
|
||||
if err = s.Handler.SetAccountType(ctx, id, req.GetType().String()); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &grpcproto.AccountTypeResponse{
|
||||
Ok: true,
|
||||
}, nil
|
||||
|
||||
}
|
||||
|
||||
func (s SilvermobiGRPCService) GetAccountType(ctx context.Context, req *grpcproto.AccountTypeRequest) (res *grpcproto.AccountTypeResponse, err error) {
|
||||
md, ok := metadata.FromIncomingContext(ctx)
|
||||
if !ok {
|
||||
return nil, status.Errorf(codes.Unauthenticated, "Missing metadata")
|
||||
}
|
||||
authHeader, ok := md["authorization"]
|
||||
if !ok || len(authHeader) == 0 {
|
||||
return nil, status.Errorf(codes.Unauthenticated, "Missing authorization header")
|
||||
}
|
||||
tokenString := strings.TrimPrefix(authHeader[0], "Bearer ")
|
||||
id := ExtractIdFromToken(tokenString)
|
||||
if req.Request == nil || !*req.Request {
|
||||
return nil, status.Errorf(codes.InvalidArgument, "request arg should be true")
|
||||
}
|
||||
account_type, err := s.Handler.GetAccountType(ctx, id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var responseType grpcproto.AccountTypeResponse_AccountType
|
||||
switch account_type {
|
||||
case "PASSENGER":
|
||||
responseType = grpcproto.AccountTypeResponse_PASSENGER
|
||||
case "DRIVER":
|
||||
responseType = grpcproto.AccountTypeResponse_DRIVER
|
||||
default:
|
||||
return nil, status.Errorf(codes.InvalidArgument, "Invalid account type")
|
||||
}
|
||||
|
||||
response := &grpcproto.AccountTypeResponse{
|
||||
Type: &responseType,
|
||||
}
|
||||
|
||||
return response, nil
|
||||
|
||||
}
|
||||
|
||||
func (s SilvermobiGRPCService) GetValidation(ctx context.Context, req *grpcproto.ValidationRequest) (res *grpcproto.ValidationResponse, err error) {
|
||||
phone_validation, birth_validation, err := s.Handler.CheckValidation(ctx, req.Email)
|
||||
md, ok := metadata.FromIncomingContext(ctx)
|
||||
if !ok {
|
||||
return nil, status.Errorf(codes.Unauthenticated, "Missing metadata")
|
||||
}
|
||||
|
||||
authHeader, ok := md["authorization"]
|
||||
if !ok || len(authHeader) == 0 {
|
||||
return nil, status.Errorf(codes.Unauthenticated, "Missing authorization header")
|
||||
}
|
||||
tokenString := strings.TrimPrefix(authHeader[0], "Bearer ")
|
||||
id := ExtractIdFromToken(tokenString)
|
||||
phone_validation, birth_validation, type_validation, err := s.Handler.CheckValidation(ctx, id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &grpcproto.ValidationResponse{
|
||||
Phone: phone_validation,
|
||||
Birthdate: birth_validation,
|
||||
Type: type_validation,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func ExtractIdFromToken(tokenString string) string {
|
||||
parts := strings.Split(tokenString, ".")
|
||||
if len(parts) != 3 {
|
||||
return ""
|
||||
}
|
||||
payloadBytes, err := base64.RawStdEncoding.DecodeString(parts[1])
|
||||
if err != nil {
|
||||
return ""
|
||||
}
|
||||
var payloadMap map[string]interface{}
|
||||
if err := json.Unmarshal(payloadBytes, &payloadMap); err != nil {
|
||||
return ""
|
||||
}
|
||||
id, ok := payloadMap["sub"].(string)
|
||||
if !ok {
|
||||
return ""
|
||||
}
|
||||
return id
|
||||
}
|
||||
|
|
|
@ -2,9 +2,6 @@ package grpcserver
|
|||
|
||||
import (
|
||||
"context"
|
||||
"net"
|
||||
"strings"
|
||||
|
||||
"git.coopgo.io/coopgo-apps/silvermobi/handler"
|
||||
grpcproto "git.coopgo.io/coopgo-apps/silvermobi/servers/grpcapi/proto"
|
||||
"github.com/golang-jwt/jwt/v4"
|
||||
|
@ -14,6 +11,9 @@ import (
|
|||
"github.com/rs/zerolog/log"
|
||||
"github.com/spf13/viper"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/status"
|
||||
"net"
|
||||
)
|
||||
|
||||
type contextKey string
|
||||
|
@ -22,53 +22,25 @@ var (
|
|||
contextKeyUser = contextKey("user")
|
||||
)
|
||||
|
||||
type SilvermobiGRPCService struct {
|
||||
Config *viper.Viper
|
||||
Handler *handler.SilvermobiHandler
|
||||
|
||||
grpcproto.UnimplementedSilvermobiGRPCServer
|
||||
}
|
||||
|
||||
func NewSilvermobiGRPCService(cfg *viper.Viper, handler *handler.SilvermobiHandler) SilvermobiGRPCService {
|
||||
return SilvermobiGRPCService{
|
||||
Config: cfg,
|
||||
Handler: handler,
|
||||
}
|
||||
}
|
||||
|
||||
func Run(done chan error, cfg *viper.Viper, handler *handler.SilvermobiHandler) {
|
||||
var (
|
||||
address = "127.0.0.1:" + cfg.GetString("services.external.grpc.port")
|
||||
jwt_secret = cfg.GetString("identification.local.jwt_secret")
|
||||
)
|
||||
|
||||
log.Info().Msg("GRPC server on " + address)
|
||||
|
||||
server := grpc.NewServer(
|
||||
grpc.StreamInterceptor(grpc_middleware.ChainStreamServer(
|
||||
grpc_ctxtags.StreamServerInterceptor(),
|
||||
StreamAuthServerInterceptor(GRPCAuthFunc(jwt_secret)),
|
||||
)),
|
||||
grpc.UnaryInterceptor(grpc_middleware.ChainUnaryServer(
|
||||
grpc_ctxtags.UnaryServerInterceptor(),
|
||||
UnaryAuthServerInterceptor(GRPCAuthFunc(jwt_secret)),
|
||||
)),
|
||||
)
|
||||
|
||||
grpcproto.RegisterSilvermobiGRPCServer(server, NewSilvermobiGRPCService(cfg, handler))
|
||||
l, err := net.Listen("tcp", address)
|
||||
if err != nil {
|
||||
log.Fatal().Err(err)
|
||||
func NoAuth(method string) bool {
|
||||
noAuthMethods := []string{
|
||||
"/SilvermobiGRPC/ForgetAccount",
|
||||
"/SilvermobiGRPC/UpdatePassword",
|
||||
"/SilvermobiGRPC/AuthRegister",
|
||||
"/SilvermobiGRPC/AuthLogin",
|
||||
}
|
||||
|
||||
if err := server.Serve(l); err != nil {
|
||||
log.Error().Err(err).Msg("gRPC service ended")
|
||||
done <- err
|
||||
for _, m := range noAuthMethods {
|
||||
if method == m {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func UnaryAuthServerInterceptor(authFunc grpc_auth.AuthFunc) grpc.UnaryServerInterceptor {
|
||||
return func(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) {
|
||||
print(info.FullMethod)
|
||||
if NoAuth(info.FullMethod) {
|
||||
return handler(ctx, req)
|
||||
}
|
||||
|
@ -81,7 +53,6 @@ func UnaryAuthServerInterceptor(authFunc grpc_auth.AuthFunc) grpc.UnaryServerInt
|
|||
return handler(newCtx, req)
|
||||
}
|
||||
}
|
||||
|
||||
func StreamAuthServerInterceptor(authFunc grpc_auth.AuthFunc) grpc.StreamServerInterceptor {
|
||||
return func(srv interface{}, stream grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) error {
|
||||
if NoAuth(info.FullMethod) {
|
||||
|
@ -101,25 +72,65 @@ func StreamAuthServerInterceptor(authFunc grpc_auth.AuthFunc) grpc.StreamServerI
|
|||
}
|
||||
}
|
||||
|
||||
type SilvermobiGRPCService struct {
|
||||
Config *viper.Viper
|
||||
Handler *handler.SilvermobiHandler
|
||||
grpcproto.UnimplementedSilvermobiGRPCServer
|
||||
}
|
||||
|
||||
func NewSilvermobiGRPCService(cfg *viper.Viper, handler *handler.SilvermobiHandler) SilvermobiGRPCService {
|
||||
return SilvermobiGRPCService{
|
||||
Config: cfg,
|
||||
Handler: handler,
|
||||
}
|
||||
}
|
||||
|
||||
func Run(done chan error, cfg *viper.Viper, handler *handler.SilvermobiHandler) {
|
||||
var (
|
||||
address = "0.0.0.0:" + cfg.GetString("services.external.grpc.port")
|
||||
jwt_secret = cfg.GetString("identification.local.jwt_secret")
|
||||
)
|
||||
|
||||
log.Info().Msg("GRPC server on " + address)
|
||||
|
||||
server := grpc.NewServer(
|
||||
grpc.StreamInterceptor(grpc_middleware.ChainStreamServer(
|
||||
grpc_ctxtags.StreamServerInterceptor(),
|
||||
StreamAuthServerInterceptor(GRPCAuthFunc(jwt_secret)),
|
||||
)),
|
||||
grpc.UnaryInterceptor(grpc_middleware.ChainUnaryServer(
|
||||
grpc_ctxtags.UnaryServerInterceptor(),
|
||||
UnaryAuthServerInterceptor(GRPCAuthFunc(jwt_secret)),
|
||||
)),
|
||||
)
|
||||
|
||||
service := NewSilvermobiGRPCService(cfg, handler)
|
||||
grpcproto.RegisterSilvermobiGRPCServer(server, service)
|
||||
l, err := net.Listen("tcp", address)
|
||||
if err != nil {
|
||||
log.Fatal().Err(err)
|
||||
}
|
||||
|
||||
if err := server.Serve(l); err != nil {
|
||||
log.Error().Err(err).Msg("gRPC service ended")
|
||||
done <- err
|
||||
}
|
||||
}
|
||||
|
||||
func GRPCAuthFunc(jwtKey string) grpc_auth.AuthFunc {
|
||||
return func(ctx context.Context) (context.Context, error) {
|
||||
tokenString, err := grpc_auth.AuthFromMD(ctx, "bearer")
|
||||
if err != nil {
|
||||
log.Error().Err(err)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
claims := jwt.MapClaims{}
|
||||
jwt.ParseWithClaims(tokenString, claims, func(token *jwt.Token) (interface{}, error) {
|
||||
token, err := jwt.ParseWithClaims(tokenString, claims, func(token *jwt.Token) (interface{}, error) {
|
||||
return []byte(jwtKey), nil
|
||||
})
|
||||
|
||||
if err != nil || !token.Valid {
|
||||
return nil, status.Errorf(codes.Unauthenticated, "Invalid or expired token")
|
||||
}
|
||||
ctx = context.WithValue(ctx, contextKeyUser, claims["sub"].(string))
|
||||
|
||||
return ctx, nil
|
||||
}
|
||||
}
|
||||
|
||||
func NoAuth(method string) bool {
|
||||
return strings.Contains(method, "Auth")
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ func (s MobilityAccountService) Login(ctx context.Context, username, password, n
|
|||
}
|
||||
|
||||
account := resp.Account.ToStorageType()
|
||||
return toAccountModel(account), nil
|
||||
return s.ToAccountModel(account), nil
|
||||
}
|
||||
|
||||
func (s MobilityAccountService) UpdateAccountData(ctx context.Context, id string, data map[string]any) error {
|
||||
|
@ -78,7 +78,7 @@ func (s MobilityAccountService) GetAccountUsername(ctx context.Context, username
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return toAccountModel(resp.Account.ToStorageType()), nil
|
||||
return s.ToAccountModel(resp.Account.ToStorageType()), nil
|
||||
}
|
||||
|
||||
func (s MobilityAccountService) Register(ctx context.Context, username string, password string, email string, phone_number string, data map[string]any, namespace string) (*models.Account, error) {
|
||||
|
@ -108,7 +108,7 @@ func (s MobilityAccountService) Register(ctx context.Context, username string, p
|
|||
return nil, err
|
||||
}
|
||||
|
||||
return toAccountModel(resp.Account.ToStorageType()), nil
|
||||
return s.ToAccountModel(resp.Account.ToStorageType()), nil
|
||||
}
|
||||
func (s MobilityAccountService) UpdatePhoneNumber(ctx context.Context, accountid string, phone_number string, verified bool, verification_code string) error {
|
||||
_, err := s.Client.UpdatePhoneNumber(
|
||||
|
@ -128,13 +128,45 @@ func (s MobilityAccountService) UpdatePhoneNumber(ctx context.Context, accountid
|
|||
return nil
|
||||
}
|
||||
|
||||
func (s MobilityAccountService) UpdateAccountBirthDate(ctx context.Context, username string, namespace string, birthdate string) error {
|
||||
resp, err := s.Client.GetAccountUsername(ctx, &mobilityaccounts.GetAccountUsernameRequest{
|
||||
Username: username,
|
||||
Namespace: namespace,
|
||||
})
|
||||
func (s MobilityAccountService) SetAccountType(ctx context.Context, id string, accountType string) error {
|
||||
account, err := s.Client.GetAccount(ctx, &mobilityaccounts.GetAccountRequest{
|
||||
Id: resp.Account.Id,
|
||||
Id: id,
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
data := make(map[string]interface{})
|
||||
data["type"] = accountType
|
||||
dataStruct := &structpb.Struct{
|
||||
Fields: make(map[string]*structpb.Value),
|
||||
}
|
||||
|
||||
for key, value := range data {
|
||||
stringValue, ok := value.(string)
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
|
||||
dataStruct.Fields[key] = &structpb.Value{
|
||||
Kind: &structpb.Value_StringValue{
|
||||
StringValue: stringValue,
|
||||
},
|
||||
}
|
||||
}
|
||||
account.Account.Data = dataStruct
|
||||
_, err = s.Client.UpdateData(ctx, &mobilityaccounts.UpdateDataRequest{
|
||||
Account: account.Account,
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
|
||||
}
|
||||
|
||||
func (s MobilityAccountService) UpdateAccountBirthDate(ctx context.Context, id string, namespace string, birthdate string) error {
|
||||
account, err := s.Client.GetAccount(ctx, &mobilityaccounts.GetAccountRequest{
|
||||
Id: id,
|
||||
})
|
||||
data := make(map[string]interface{})
|
||||
data["birthdate"] = birthdate
|
||||
|
@ -165,18 +197,23 @@ func (s MobilityAccountService) UpdateAccountBirthDate(ctx context.Context, user
|
|||
return nil
|
||||
}
|
||||
|
||||
func toAccountModel(account ma.Account) *models.Account {
|
||||
func (s MobilityAccountService) ToAccountModel(account ma.Account) *models.Account {
|
||||
first_name := account.Data["first_name"].(string)
|
||||
last_name := account.Data["last_name"].(string)
|
||||
birth_date, ok := account.Data["birthdate"].(string)
|
||||
if !ok {
|
||||
birth_date = ""
|
||||
}
|
||||
accountType, ok := account.Data["type"].(string)
|
||||
if !ok {
|
||||
accountType = ""
|
||||
}
|
||||
return &models.Account{
|
||||
ID: account.ID,
|
||||
FirstName: first_name,
|
||||
LastName: last_name,
|
||||
BirthDate: birth_date,
|
||||
Type: accountType,
|
||||
LocalCredentials: models.LocalCredentials{
|
||||
Email: account.Authentication.Local.Email,
|
||||
EmailVerified: account.Authentication.Local.EmailValidation.Validated,
|
||||
|
|
Loading…
Reference in New Issue