Passwordless (#292)

* 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>

* Update user.proto

* add examples to examples.json | convert isvalid to is_valid | add some extra comments in user.proto

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-10 12:57:00 +03:00
committed by GitHub
parent f82bc634c1
commit 1d6234155a
6 changed files with 827 additions and 99 deletions

View File

@@ -55,6 +55,8 @@ 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)
VerifyToken(ctx context.Context, in *VerifyTokenRequest, opts ...client.CallOption) (*VerifyTokenResponse, error)
}
type userService struct {
@@ -199,6 +201,65 @@ 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...)
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
}
func (c *userService) VerifyToken(ctx context.Context, in *VerifyTokenRequest, opts ...client.CallOption) (*VerifyTokenResponse, error) {
req := c.c.NewRequest(c.name, "User.VerifyToken", in)
out := new(VerifyTokenResponse)
err := c.c.Call(ctx, req, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// Server API for User service
type UserHandler interface {
@@ -215,6 +276,8 @@ 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
VerifyToken(context.Context, *VerifyTokenRequest, *VerifyTokenResponse) error
}
func RegisterUserHandler(s server.Server, hdlr UserHandler, opts ...server.HandlerOption) error {
@@ -232,6 +295,8 @@ 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
VerifyToken(ctx context.Context, in *VerifyTokenRequest, out *VerifyTokenResponse) error
}
type User struct {
user
@@ -295,3 +360,47 @@ func (h *userHandler) ResetPassword(ctx context.Context, in *ResetPasswordReques
func (h *userHandler) List(ctx context.Context, in *ListRequest, out *ListResponse) error {
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) VerifyToken(ctx context.Context, in *VerifyTokenRequest, out *VerifyTokenResponse) error {
return h.UserHandler.VerifyToken(ctx, in, out)
}