Remove stream from SendMagicLink (#320)

* add two rpcs to User service:
	- Passwordless: endpoint that receives an email, topic and an optional message
	- PasswordlessML: endpoint that receives token and topic via MagicLink.

* Proposal to add Passwordless login feature to the endpoint user.

* remove currency run check

* Commit from GitHub Actions (Publish APIs & Clients)

* Create downstream.yml

* Commit from GitHub Actions (Publish APIs & Clients)

* update todo

* Commit from GitHub Actions (Publish APIs & Clients)

* Update publish.yml

* Commit from GitHub Actions (Publish APIs & Clients)

* Update publish.yml

* Commit from GitHub Actions (Publish APIs & Clients)

* Update and rename publish.yml to generate.yml

* Update generate.yml

* Commit from GitHub Actions (Generate Clients & Examples)

* Commit from GitHub Actions (Generate Clients & Examples)

* add comments

* Commit from GitHub Actions (Generate Clients & Examples)

* move otp to auth category

* charge for user verification

* Commit from GitHub Actions (Generate Clients & Examples)

* Update user.proto

* Commit from GitHub Actions (Generate Clients & Examples)

* Commit from GitHub Actions (Generate Clients & Examples)

* Change js client git repo url (#249)

* Commit from GitHub Actions (Generate Clients & Examples)

* use tableName func for Count

* Commit from GitHub Actions (Generate Clients & Examples)

* update notes example

* Commit from GitHub Actions (Generate Clients & Examples)

* Update .gitignore

* Update .gitignore

* Commit from GitHub Actions (Generate Clients & Examples)

* add new endpoints SendMagicLink and VerifyToken to M3O user serivce

Signed-off-by: Daniel Joudat <danieljoudat@gmail.com>

* remove stream from SendMagicLink

Signed-off-by: Daniel Joudat <danieljoudat@gmail.com>

* fix user/examples.json

Signed-off-by: Daniel Joudat <danieljoudat@gmail.com>

* fix typo in user.proto sessino -> session | add dumpy session in user/examples.json

Signed-off-by: Daniel Joudat <danieljoudat@gmail.com>

Co-authored-by: Asim Aslam <asim@aslam.me>
Co-authored-by: asim <asim@users.noreply.github.com>
Co-authored-by: Janos Dobronszki <dobronszki@gmail.com>
Co-authored-by: crufter <crufter@users.noreply.github.com>
This commit is contained in:
Daniel Joudat
2021-12-13 16:47:25 +03:00
committed by GitHub
parent 28fb141819
commit 2b24aba3c3
6 changed files with 75 additions and 218 deletions

View File

@@ -1728,8 +1728,6 @@ type SendMagicLinkResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Session *Session `protobuf:"bytes,1,opt,name=session,proto3" json:"session,omitempty"`
}
func (x *SendMagicLinkResponse) Reset() {
@@ -1764,13 +1762,6 @@ func (*SendMagicLinkResponse) Descriptor() ([]byte, []int) {
return file_proto_user_proto_rawDescGZIP(), []int{29}
}
func (x *SendMagicLinkResponse) GetSession() *Session {
if x != nil {
return x.Session
}
return nil
}
// Check whether the token attached to MagicLink is valid or not.
// Ideally, you need to call this endpoint from your http request
// handler that handles the endpoint which is specified in the
@@ -1827,8 +1818,9 @@ type VerifyTokenResponse struct {
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
IsValid bool `protobuf:"varint,1,opt,name=is_valid,json=isValid,proto3" json:"is_valid,omitempty"`
Message string `protobuf:"bytes,2,opt,name=message,proto3" json:"message,omitempty"`
IsValid bool `protobuf:"varint,1,opt,name=is_valid,json=isValid,proto3" json:"is_valid,omitempty"`
Session *Session `protobuf:"bytes,2,opt,name=session,proto3" json:"session,omitempty"`
Message string `protobuf:"bytes,3,opt,name=message,proto3" json:"message,omitempty"`
}
func (x *VerifyTokenResponse) Reset() {
@@ -1870,6 +1862,13 @@ func (x *VerifyTokenResponse) GetIsValid() bool {
return false
}
func (x *VerifyTokenResponse) GetSession() *Session {
if x != nil {
return x.Session
}
return nil
}
func (x *VerifyTokenResponse) GetMessage() string {
if x != nil {
return x.Message
@@ -2046,19 +2045,19 @@ var file_proto_user_proto_rawDesc = []byte{
0x18, 0x0a, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09,
0x52, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x12, 0x1a, 0x0a, 0x08, 0x65, 0x6e, 0x64,
0x70, 0x6f, 0x69, 0x6e, 0x74, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x65, 0x6e, 0x64,
0x70, 0x6f, 0x69, 0x6e, 0x74, 0x22, 0x40, 0x0a, 0x15, 0x53, 0x65, 0x6e, 0x64, 0x4d, 0x61, 0x67,
0x69, 0x63, 0x4c, 0x69, 0x6e, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x27,
0x0a, 0x07, 0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32,
0x0d, 0x2e, 0x75, 0x73, 0x65, 0x72, 0x2e, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x07,
0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x22, 0x2a, 0x0a, 0x12, 0x56, 0x65, 0x72, 0x69, 0x66,
0x79, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x14, 0x0a,
0x05, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x74, 0x6f,
0x6b, 0x65, 0x6e, 0x22, 0x4a, 0x0a, 0x13, 0x56, 0x65, 0x72, 0x69, 0x66, 0x79, 0x54, 0x6f, 0x6b,
0x65, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x19, 0x0a, 0x08, 0x69, 0x73,
0x5f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x69, 0x73,
0x56, 0x61, 0x6c, 0x69, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65,
0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x32,
0xfe, 0x07, 0x0a, 0x04, 0x55, 0x73, 0x65, 0x72, 0x12, 0x35, 0x0a, 0x06, 0x43, 0x72, 0x65, 0x61,
0x70, 0x6f, 0x69, 0x6e, 0x74, 0x22, 0x17, 0x0a, 0x15, 0x53, 0x65, 0x6e, 0x64, 0x4d, 0x61, 0x67,
0x69, 0x63, 0x4c, 0x69, 0x6e, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x2a,
0x0a, 0x12, 0x56, 0x65, 0x72, 0x69, 0x66, 0x79, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x52, 0x65, 0x71,
0x75, 0x65, 0x73, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x01, 0x20,
0x01, 0x28, 0x09, 0x52, 0x05, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x22, 0x73, 0x0a, 0x13, 0x56, 0x65,
0x72, 0x69, 0x66, 0x79, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73,
0x65, 0x12, 0x19, 0x0a, 0x08, 0x69, 0x73, 0x5f, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x18, 0x01, 0x20,
0x01, 0x28, 0x08, 0x52, 0x07, 0x69, 0x73, 0x56, 0x61, 0x6c, 0x69, 0x64, 0x12, 0x27, 0x0a, 0x07,
0x73, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0d, 0x2e,
0x75, 0x73, 0x65, 0x72, 0x2e, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x07, 0x73, 0x65,
0x73, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65,
0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x32,
0xfc, 0x07, 0x0a, 0x04, 0x55, 0x73, 0x65, 0x72, 0x12, 0x35, 0x0a, 0x06, 0x43, 0x72, 0x65, 0x61,
0x74, 0x65, 0x12, 0x13, 0x2e, 0x75, 0x73, 0x65, 0x72, 0x2e, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65,
0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x14, 0x2e, 0x75, 0x73, 0x65, 0x72, 0x2e, 0x43,
0x72, 0x65, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12,
@@ -2112,18 +2111,18 @@ var file_proto_user_proto_rawDesc = []byte{
0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x2f, 0x0a, 0x04, 0x4c,
0x69, 0x73, 0x74, 0x12, 0x11, 0x2e, 0x75, 0x73, 0x65, 0x72, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x52,
0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x12, 0x2e, 0x75, 0x73, 0x65, 0x72, 0x2e, 0x4c, 0x69,
0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x4c, 0x0a, 0x0d,
0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x4a, 0x0a, 0x0d,
0x53, 0x65, 0x6e, 0x64, 0x4d, 0x61, 0x67, 0x69, 0x63, 0x4c, 0x69, 0x6e, 0x6b, 0x12, 0x1a, 0x2e,
0x75, 0x73, 0x65, 0x72, 0x2e, 0x53, 0x65, 0x6e, 0x64, 0x4d, 0x61, 0x67, 0x69, 0x63, 0x4c, 0x69,
0x6e, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1b, 0x2e, 0x75, 0x73, 0x65, 0x72,
0x2e, 0x53, 0x65, 0x6e, 0x64, 0x4d, 0x61, 0x67, 0x69, 0x63, 0x4c, 0x69, 0x6e, 0x6b, 0x52, 0x65,
0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x30, 0x01, 0x12, 0x44, 0x0a, 0x0b, 0x56, 0x65,
0x72, 0x69, 0x66, 0x79, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x12, 0x18, 0x2e, 0x75, 0x73, 0x65, 0x72,
0x2e, 0x56, 0x65, 0x72, 0x69, 0x66, 0x79, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x52, 0x65, 0x71, 0x75,
0x65, 0x73, 0x74, 0x1a, 0x19, 0x2e, 0x75, 0x73, 0x65, 0x72, 0x2e, 0x56, 0x65, 0x72, 0x69, 0x66,
0x79, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00,
0x42, 0x0e, 0x5a, 0x0c, 0x2e, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x3b, 0x75, 0x73, 0x65, 0x72,
0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x44, 0x0a, 0x0b, 0x56, 0x65, 0x72, 0x69,
0x66, 0x79, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x12, 0x18, 0x2e, 0x75, 0x73, 0x65, 0x72, 0x2e, 0x56,
0x65, 0x72, 0x69, 0x66, 0x79, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73,
0x74, 0x1a, 0x19, 0x2e, 0x75, 0x73, 0x65, 0x72, 0x2e, 0x56, 0x65, 0x72, 0x69, 0x66, 0x79, 0x54,
0x6f, 0x6b, 0x65, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x0e,
0x5a, 0x0c, 0x2e, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x3b, 0x75, 0x73, 0x65, 0x72, 0x62, 0x06,
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
@@ -2185,7 +2184,7 @@ var file_proto_user_proto_depIdxs = []int32{
1, // 5: user.ReadSessionResponse.session:type_name -> user.Session
1, // 6: user.LoginResponse.session:type_name -> user.Session
0, // 7: user.ListResponse.users:type_name -> user.Account
1, // 8: user.SendMagicLinkResponse.session:type_name -> user.Session
1, // 8: user.VerifyTokenResponse.session:type_name -> user.Session
2, // 9: user.User.Create:input_type -> user.CreateRequest
6, // 10: user.User.Read:input_type -> user.ReadRequest
8, // 11: user.User.Update:input_type -> user.UpdateRequest

View File

@@ -55,7 +55,7 @@ type UserService interface {
SendPasswordResetEmail(ctx context.Context, in *SendPasswordResetEmailRequest, opts ...client.CallOption) (*SendPasswordResetEmailResponse, error)
ResetPassword(ctx context.Context, in *ResetPasswordRequest, opts ...client.CallOption) (*ResetPasswordResponse, error)
List(ctx context.Context, in *ListRequest, opts ...client.CallOption) (*ListResponse, error)
SendMagicLink(ctx context.Context, in *SendMagicLinkRequest, opts ...client.CallOption) (User_SendMagicLinkService, error)
SendMagicLink(ctx context.Context, in *SendMagicLinkRequest, opts ...client.CallOption) (*SendMagicLinkResponse, error)
VerifyToken(ctx context.Context, in *VerifyTokenRequest, opts ...client.CallOption) (*VerifyTokenResponse, error)
}
@@ -201,53 +201,14 @@ func (c *userService) List(ctx context.Context, in *ListRequest, opts ...client.
return out, nil
}
func (c *userService) SendMagicLink(ctx context.Context, in *SendMagicLinkRequest, opts ...client.CallOption) (User_SendMagicLinkService, error) {
req := c.c.NewRequest(c.name, "User.SendMagicLink", &SendMagicLinkRequest{})
stream, err := c.c.Stream(ctx, req, opts...)
func (c *userService) SendMagicLink(ctx context.Context, in *SendMagicLinkRequest, opts ...client.CallOption) (*SendMagicLinkResponse, error) {
req := c.c.NewRequest(c.name, "User.SendMagicLink", in)
out := new(SendMagicLinkResponse)
err := c.c.Call(ctx, req, out, opts...)
if err != nil {
return nil, err
}
if err := stream.Send(in); err != nil {
return nil, err
}
return &userServiceSendMagicLink{stream}, nil
}
type User_SendMagicLinkService interface {
Context() context.Context
SendMsg(interface{}) error
RecvMsg(interface{}) error
Close() error
Recv() (*SendMagicLinkResponse, error)
}
type userServiceSendMagicLink struct {
stream client.Stream
}
func (x *userServiceSendMagicLink) Close() error {
return x.stream.Close()
}
func (x *userServiceSendMagicLink) Context() context.Context {
return x.stream.Context()
}
func (x *userServiceSendMagicLink) SendMsg(m interface{}) error {
return x.stream.Send(m)
}
func (x *userServiceSendMagicLink) RecvMsg(m interface{}) error {
return x.stream.Recv(m)
}
func (x *userServiceSendMagicLink) Recv() (*SendMagicLinkResponse, error) {
m := new(SendMagicLinkResponse)
err := x.stream.Recv(m)
if err != nil {
return nil, err
}
return m, nil
return out, nil
}
func (c *userService) VerifyToken(ctx context.Context, in *VerifyTokenRequest, opts ...client.CallOption) (*VerifyTokenResponse, error) {
@@ -276,7 +237,7 @@ type UserHandler interface {
SendPasswordResetEmail(context.Context, *SendPasswordResetEmailRequest, *SendPasswordResetEmailResponse) error
ResetPassword(context.Context, *ResetPasswordRequest, *ResetPasswordResponse) error
List(context.Context, *ListRequest, *ListResponse) error
SendMagicLink(context.Context, *SendMagicLinkRequest, User_SendMagicLinkStream) error
SendMagicLink(context.Context, *SendMagicLinkRequest, *SendMagicLinkResponse) error
VerifyToken(context.Context, *VerifyTokenRequest, *VerifyTokenResponse) error
}
@@ -295,7 +256,7 @@ func RegisterUserHandler(s server.Server, hdlr UserHandler, opts ...server.Handl
SendPasswordResetEmail(ctx context.Context, in *SendPasswordResetEmailRequest, out *SendPasswordResetEmailResponse) error
ResetPassword(ctx context.Context, in *ResetPasswordRequest, out *ResetPasswordResponse) error
List(ctx context.Context, in *ListRequest, out *ListResponse) error
SendMagicLink(ctx context.Context, stream server.Stream) error
SendMagicLink(ctx context.Context, in *SendMagicLinkRequest, out *SendMagicLinkResponse) error
VerifyToken(ctx context.Context, in *VerifyTokenRequest, out *VerifyTokenResponse) error
}
type User struct {
@@ -361,44 +322,8 @@ func (h *userHandler) List(ctx context.Context, in *ListRequest, out *ListRespon
return h.UserHandler.List(ctx, in, out)
}
func (h *userHandler) SendMagicLink(ctx context.Context, stream server.Stream) error {
m := new(SendMagicLinkRequest)
if err := stream.Recv(m); err != nil {
return err
}
return h.UserHandler.SendMagicLink(ctx, m, &userSendMagicLinkStream{stream})
}
type User_SendMagicLinkStream interface {
Context() context.Context
SendMsg(interface{}) error
RecvMsg(interface{}) error
Close() error
Send(*SendMagicLinkResponse) error
}
type userSendMagicLinkStream struct {
stream server.Stream
}
func (x *userSendMagicLinkStream) Close() error {
return x.stream.Close()
}
func (x *userSendMagicLinkStream) Context() context.Context {
return x.stream.Context()
}
func (x *userSendMagicLinkStream) SendMsg(m interface{}) error {
return x.stream.Send(m)
}
func (x *userSendMagicLinkStream) RecvMsg(m interface{}) error {
return x.stream.Recv(m)
}
func (x *userSendMagicLinkStream) Send(m *SendMagicLinkResponse) error {
return x.stream.Send(m)
func (h *userHandler) SendMagicLink(ctx context.Context, in *SendMagicLinkRequest, out *SendMagicLinkResponse) error {
return h.UserHandler.SendMagicLink(ctx, in, out)
}
func (h *userHandler) VerifyToken(ctx context.Context, in *VerifyTokenRequest, out *VerifyTokenResponse) error {

View File

@@ -18,7 +18,7 @@ service User {
rpc SendPasswordResetEmail(SendPasswordResetEmailRequest) returns (SendPasswordResetEmailResponse) {}
rpc ResetPassword(ResetPasswordRequest) returns (ResetPasswordResponse) {}
rpc List(ListRequest) returns(ListResponse) {}
rpc SendMagicLink(SendMagicLinkRequest) returns (stream SendMagicLinkResponse) {}
rpc SendMagicLink(SendMagicLinkRequest) returns (SendMagicLinkResponse) {}
rpc VerifyToken(VerifyTokenRequest) returns (VerifyTokenResponse) {}
}
@@ -258,9 +258,7 @@ message SendMagicLinkRequest {
string endpoint = 6;
}
message SendMagicLinkResponse {
Session session = 1;
}
message SendMagicLinkResponse {}
// Check whether the token attached to MagicLink is valid or not.
// Ideally, you need to call this endpoint from your http request
@@ -272,5 +270,6 @@ message VerifyTokenRequest {
message VerifyTokenResponse {
bool is_valid = 1;
string message = 2;
Session session = 2;
string message = 3;
}