mirror of
https://github.com/anyproto/any-sync.git
synced 2025-06-09 09:35:03 +09:00
Email verification methods
This commit is contained in:
parent
1026e993ec
commit
c8860ff4e3
5 changed files with 1581 additions and 51 deletions
|
@ -85,6 +85,21 @@ func (mr *MockAnyPpClientServiceMockRecorder) GetSubscriptionStatus(ctx, in any)
|
|||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetSubscriptionStatus", reflect.TypeOf((*MockAnyPpClientService)(nil).GetSubscriptionStatus), ctx, in)
|
||||
}
|
||||
|
||||
// GetVerificationEmail mocks base method.
|
||||
func (m *MockAnyPpClientService) GetVerificationEmail(ctx context.Context, in *paymentserviceproto.GetVerificationEmailRequestSigned) (*paymentserviceproto.GetVerificationEmailResponse, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "GetVerificationEmail", ctx, in)
|
||||
ret0, _ := ret[0].(*paymentserviceproto.GetVerificationEmailResponse)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// GetVerificationEmail indicates an expected call of GetVerificationEmail.
|
||||
func (mr *MockAnyPpClientServiceMockRecorder) GetVerificationEmail(ctx, in any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetVerificationEmail", reflect.TypeOf((*MockAnyPpClientService)(nil).GetVerificationEmail), ctx, in)
|
||||
}
|
||||
|
||||
// Init mocks base method.
|
||||
func (m *MockAnyPpClientService) Init(a *app.App) error {
|
||||
m.ctrl.T.Helper()
|
||||
|
@ -112,3 +127,18 @@ func (mr *MockAnyPpClientServiceMockRecorder) Name() *gomock.Call {
|
|||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Name", reflect.TypeOf((*MockAnyPpClientService)(nil).Name))
|
||||
}
|
||||
|
||||
// VerifyEmail mocks base method.
|
||||
func (m *MockAnyPpClientService) VerifyEmail(ctx context.Context, in *paymentserviceproto.VerifyEmailRequestSigned) (*paymentserviceproto.VerifyEmailResponse, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "VerifyEmail", ctx, in)
|
||||
ret0, _ := ret[0].(*paymentserviceproto.VerifyEmailResponse)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// VerifyEmail indicates an expected call of VerifyEmail.
|
||||
func (mr *MockAnyPpClientServiceMockRecorder) VerifyEmail(ctx, in any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "VerifyEmail", reflect.TypeOf((*MockAnyPpClientService)(nil).VerifyEmail), ctx, in)
|
||||
}
|
||||
|
|
|
@ -25,6 +25,8 @@ type AnyPpClientService interface {
|
|||
GetSubscriptionStatus(ctx context.Context, in *pp.GetSubscriptionRequestSigned) (out *pp.GetSubscriptionResponse, err error)
|
||||
BuySubscription(ctx context.Context, in *pp.BuySubscriptionRequestSigned) (out *pp.BuySubscriptionResponse, err error)
|
||||
GetSubscriptionPortalLink(ctx context.Context, in *pp.GetSubscriptionPortalLinkRequestSigned) (out *pp.GetSubscriptionPortalLinkResponse, err error)
|
||||
GetVerificationEmail(ctx context.Context, in *pp.GetVerificationEmailRequestSigned) (out *pp.GetVerificationEmailResponse, err error)
|
||||
VerifyEmail(ctx context.Context, in *pp.VerifyEmailRequestSigned) (out *pp.VerifyEmailResponse, err error)
|
||||
|
||||
app.Component
|
||||
}
|
||||
|
@ -101,3 +103,23 @@ func (s *service) GetSubscriptionPortalLink(ctx context.Context, in *pp.GetSubsc
|
|||
})
|
||||
return
|
||||
}
|
||||
|
||||
func (s *service) GetVerificationEmail(ctx context.Context, in *pp.GetVerificationEmailRequestSigned) (out *pp.GetVerificationEmailResponse, err error) {
|
||||
err = s.doClient(ctx, func(cl pp.DRPCAnyPaymentProcessingClient) error {
|
||||
if out, err = cl.GetVerificationEmail(ctx, in); err != nil {
|
||||
return rpcerr.Unwrap(err)
|
||||
}
|
||||
return nil
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
func (s *service) VerifyEmail(ctx context.Context, in *pp.VerifyEmailRequestSigned) (out *pp.VerifyEmailResponse, err error) {
|
||||
err = s.doClient(ctx, func(cl pp.DRPCAnyPaymentProcessingClient) error {
|
||||
if out, err = cl.VerifyEmail(ctx, in); err != nil {
|
||||
return rpcerr.Unwrap(err)
|
||||
}
|
||||
return nil
|
||||
})
|
||||
return
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -43,6 +43,8 @@ type DRPCAnyPaymentProcessingClient interface {
|
|||
GetSubscriptionStatus(ctx context.Context, in *GetSubscriptionRequestSigned) (*GetSubscriptionResponse, error)
|
||||
BuySubscription(ctx context.Context, in *BuySubscriptionRequestSigned) (*BuySubscriptionResponse, error)
|
||||
GetSubscriptionPortalLink(ctx context.Context, in *GetSubscriptionPortalLinkRequestSigned) (*GetSubscriptionPortalLinkResponse, error)
|
||||
GetVerificationEmail(ctx context.Context, in *GetVerificationEmailRequestSigned) (*GetVerificationEmailResponse, error)
|
||||
VerifyEmail(ctx context.Context, in *VerifyEmailRequestSigned) (*VerifyEmailResponse, error)
|
||||
}
|
||||
|
||||
type drpcAnyPaymentProcessingClient struct {
|
||||
|
@ -82,10 +84,30 @@ func (c *drpcAnyPaymentProcessingClient) GetSubscriptionPortalLink(ctx context.C
|
|||
return out, nil
|
||||
}
|
||||
|
||||
func (c *drpcAnyPaymentProcessingClient) GetVerificationEmail(ctx context.Context, in *GetVerificationEmailRequestSigned) (*GetVerificationEmailResponse, error) {
|
||||
out := new(GetVerificationEmailResponse)
|
||||
err := c.cc.Invoke(ctx, "/AnyPaymentProcessing/GetVerificationEmail", drpcEncoding_File_paymentservice_paymentserviceproto_protos_paymentservice_proto{}, in, out)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *drpcAnyPaymentProcessingClient) VerifyEmail(ctx context.Context, in *VerifyEmailRequestSigned) (*VerifyEmailResponse, error) {
|
||||
out := new(VerifyEmailResponse)
|
||||
err := c.cc.Invoke(ctx, "/AnyPaymentProcessing/VerifyEmail", drpcEncoding_File_paymentservice_paymentserviceproto_protos_paymentservice_proto{}, in, out)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
type DRPCAnyPaymentProcessingServer interface {
|
||||
GetSubscriptionStatus(context.Context, *GetSubscriptionRequestSigned) (*GetSubscriptionResponse, error)
|
||||
BuySubscription(context.Context, *BuySubscriptionRequestSigned) (*BuySubscriptionResponse, error)
|
||||
GetSubscriptionPortalLink(context.Context, *GetSubscriptionPortalLinkRequestSigned) (*GetSubscriptionPortalLinkResponse, error)
|
||||
GetVerificationEmail(context.Context, *GetVerificationEmailRequestSigned) (*GetVerificationEmailResponse, error)
|
||||
VerifyEmail(context.Context, *VerifyEmailRequestSigned) (*VerifyEmailResponse, error)
|
||||
}
|
||||
|
||||
type DRPCAnyPaymentProcessingUnimplementedServer struct{}
|
||||
|
@ -102,9 +124,17 @@ func (s *DRPCAnyPaymentProcessingUnimplementedServer) GetSubscriptionPortalLink(
|
|||
return nil, drpcerr.WithCode(errors.New("Unimplemented"), drpcerr.Unimplemented)
|
||||
}
|
||||
|
||||
func (s *DRPCAnyPaymentProcessingUnimplementedServer) GetVerificationEmail(context.Context, *GetVerificationEmailRequestSigned) (*GetVerificationEmailResponse, error) {
|
||||
return nil, drpcerr.WithCode(errors.New("Unimplemented"), drpcerr.Unimplemented)
|
||||
}
|
||||
|
||||
func (s *DRPCAnyPaymentProcessingUnimplementedServer) VerifyEmail(context.Context, *VerifyEmailRequestSigned) (*VerifyEmailResponse, error) {
|
||||
return nil, drpcerr.WithCode(errors.New("Unimplemented"), drpcerr.Unimplemented)
|
||||
}
|
||||
|
||||
type DRPCAnyPaymentProcessingDescription struct{}
|
||||
|
||||
func (DRPCAnyPaymentProcessingDescription) NumMethods() int { return 3 }
|
||||
func (DRPCAnyPaymentProcessingDescription) NumMethods() int { return 5 }
|
||||
|
||||
func (DRPCAnyPaymentProcessingDescription) Method(n int) (string, drpc.Encoding, drpc.Receiver, interface{}, bool) {
|
||||
switch n {
|
||||
|
@ -135,6 +165,24 @@ func (DRPCAnyPaymentProcessingDescription) Method(n int) (string, drpc.Encoding,
|
|||
in1.(*GetSubscriptionPortalLinkRequestSigned),
|
||||
)
|
||||
}, DRPCAnyPaymentProcessingServer.GetSubscriptionPortalLink, true
|
||||
case 3:
|
||||
return "/AnyPaymentProcessing/GetVerificationEmail", drpcEncoding_File_paymentservice_paymentserviceproto_protos_paymentservice_proto{},
|
||||
func(srv interface{}, ctx context.Context, in1, in2 interface{}) (drpc.Message, error) {
|
||||
return srv.(DRPCAnyPaymentProcessingServer).
|
||||
GetVerificationEmail(
|
||||
ctx,
|
||||
in1.(*GetVerificationEmailRequestSigned),
|
||||
)
|
||||
}, DRPCAnyPaymentProcessingServer.GetVerificationEmail, true
|
||||
case 4:
|
||||
return "/AnyPaymentProcessing/VerifyEmail", drpcEncoding_File_paymentservice_paymentserviceproto_protos_paymentservice_proto{},
|
||||
func(srv interface{}, ctx context.Context, in1, in2 interface{}) (drpc.Message, error) {
|
||||
return srv.(DRPCAnyPaymentProcessingServer).
|
||||
VerifyEmail(
|
||||
ctx,
|
||||
in1.(*VerifyEmailRequestSigned),
|
||||
)
|
||||
}, DRPCAnyPaymentProcessingServer.VerifyEmail, true
|
||||
default:
|
||||
return "", nil, nil, nil, false
|
||||
}
|
||||
|
@ -191,3 +239,35 @@ func (x *drpcAnyPaymentProcessing_GetSubscriptionPortalLinkStream) SendAndClose(
|
|||
}
|
||||
return x.CloseSend()
|
||||
}
|
||||
|
||||
type DRPCAnyPaymentProcessing_GetVerificationEmailStream interface {
|
||||
drpc.Stream
|
||||
SendAndClose(*GetVerificationEmailResponse) error
|
||||
}
|
||||
|
||||
type drpcAnyPaymentProcessing_GetVerificationEmailStream struct {
|
||||
drpc.Stream
|
||||
}
|
||||
|
||||
func (x *drpcAnyPaymentProcessing_GetVerificationEmailStream) SendAndClose(m *GetVerificationEmailResponse) error {
|
||||
if err := x.MsgSend(m, drpcEncoding_File_paymentservice_paymentserviceproto_protos_paymentservice_proto{}); err != nil {
|
||||
return err
|
||||
}
|
||||
return x.CloseSend()
|
||||
}
|
||||
|
||||
type DRPCAnyPaymentProcessing_VerifyEmailStream interface {
|
||||
drpc.Stream
|
||||
SendAndClose(*VerifyEmailResponse) error
|
||||
}
|
||||
|
||||
type drpcAnyPaymentProcessing_VerifyEmailStream struct {
|
||||
drpc.Stream
|
||||
}
|
||||
|
||||
func (x *drpcAnyPaymentProcessing_VerifyEmailStream) SendAndClose(m *VerifyEmailResponse) error {
|
||||
if err := x.MsgSend(m, drpcEncoding_File_paymentservice_paymentserviceproto_protos_paymentservice_proto{}); err != nil {
|
||||
return err
|
||||
}
|
||||
return x.CloseSend()
|
||||
}
|
||||
|
|
|
@ -74,6 +74,10 @@ message GetSubscriptionResponse {
|
|||
// if name was requested - it will be here
|
||||
// seeBuySubscriptionRequest.requestedAnyName field
|
||||
string requestedAnyName = 9;
|
||||
|
||||
// if user verified her email OR provided it while buying a subscription
|
||||
// it will be here
|
||||
string userEmail = 10;
|
||||
}
|
||||
|
||||
// 2
|
||||
|
@ -130,21 +134,77 @@ message GetSubscriptionPortalLinkResponse {
|
|||
string portalUrl = 1;
|
||||
}
|
||||
|
||||
message GetVerificationEmailRequest {
|
||||
// in the following format: "A5k2d9sFZw84yisTxRnz2bPRd1YPfVfhxqymZ6yESprFTG65"
|
||||
// you can get it with Account().SignKey.GetPublic().Account()
|
||||
string ownerAnyId = 1;
|
||||
|
||||
string email = 2;
|
||||
|
||||
bool subscribeToNewsletter = 3;
|
||||
}
|
||||
|
||||
message GetVerificationEmailResponse {
|
||||
|
||||
}
|
||||
|
||||
message GetVerificationEmailRequestSigned {
|
||||
// GetVerificationEmailRequest
|
||||
bytes payload = 1;
|
||||
|
||||
// this is payload signed with payload.ownerAnyID
|
||||
bytes signature = 2;
|
||||
}
|
||||
|
||||
message VerifyEmailRequest {
|
||||
// in the following format: "A5k2d9sFZw84yisTxRnz2bPRd1YPfVfhxqymZ6yESprFTG65"
|
||||
// you can get it with Account().SignKey.GetPublic().Account()
|
||||
string ownerAnyId = 1;
|
||||
|
||||
// this is the owner's main EOA (Externally Owned Account) address
|
||||
// not AccountAbstraction's SCW (Smart Contract Wallet) address!
|
||||
// this is required to reserve a name for the owner (later that is done by user)
|
||||
// in the following format: "0x7a250d5630b4cf539739df2c5dacb4c659f2488d"
|
||||
string ownerEthAddress = 2;
|
||||
|
||||
string code = 3;
|
||||
}
|
||||
|
||||
message VerifyEmailResponse {
|
||||
bool success = 1;
|
||||
}
|
||||
|
||||
message VerifyEmailRequestSigned {
|
||||
// VerifyEmailRequest
|
||||
bytes payload = 1;
|
||||
|
||||
// this is payload signed with payload.ownerAnyID
|
||||
bytes signature = 2;
|
||||
}
|
||||
|
||||
// NOTICE:
|
||||
// 1 - User can not ask for a payment/other links on behalf of another user (a signature is required)
|
||||
// 2 - Admin can do that on behalf of any user
|
||||
service AnyPaymentProcessing {
|
||||
rpc GetSubscriptionStatus(GetSubscriptionRequestSigned) returns (GetSubscriptionResponse) {}
|
||||
|
||||
// Will save a new BillingID to DB, and return a payment link.
|
||||
// Save a new BillingID to DB, and return a payment link.
|
||||
// You can call BuySubscription multiple times even if current payment is not processed yet
|
||||
// (to get new payment link).
|
||||
// If user has already an active subscription, then this will return an error.
|
||||
rpc BuySubscription(BuySubscriptionRequestSigned) returns (BuySubscriptionResponse) {}
|
||||
|
||||
// Will generate a link to the portal where user can:
|
||||
// Generate a link to the portal where user can:
|
||||
// a) change her billing details
|
||||
// b) see payment info, invoices, etc
|
||||
// c) cancel/renew the subscription
|
||||
rpc GetSubscriptionPortalLink(GetSubscriptionPortalLinkRequestSigned) returns (GetSubscriptionPortalLinkResponse) {}
|
||||
|
||||
// Verify user's email: 1st step - get a verification link to the email
|
||||
// Will fail if already verified, i.e. you can not change your email
|
||||
rpc GetVerificationEmail(GetVerificationEmailRequestSigned) returns (GetVerificationEmailResponse) {}
|
||||
|
||||
// Enter the code from the email
|
||||
// Will fail if: link was not requested, link is expired, if email is already verified
|
||||
rpc VerifyEmail(VerifyEmailRequestSigned) returns (VerifyEmailResponse) {}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue