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

@@ -467,15 +467,11 @@ func (domain *Domain) List(ctx context.Context, o, l int32) ([]*user.Account, er
return ret, nil
}
func (domain *Domain) CacheToken(ctx context.Context, token, id, email string, ttl int) error {
obj := &tokenObject{
Id: id,
Email: email,
}
func (domain *Domain) CacheToken(ctx context.Context, token, email string, ttl int) error {
expires := time.Now().Add(time.Duration(ttl) * time.Second)
err := cache.Context(ctx).Set(token, obj, expires)
err := cache.Context(ctx).Set(token, email, expires)
return err
}
@@ -495,28 +491,23 @@ func (domain *Domain) SendMLE(fromName, toAddress, toUsername, subject, textCont
return err
}
func (domain *Domain) CacheReadToken(ctx context.Context, token string) (string, string, error) {
func (domain *Domain) CacheReadToken(ctx context.Context, token string) (string, error) {
if token == "" {
return "", "", errors.New("token empty")
return "", errors.New("token empty")
}
var obj tokenObject
var email string
expires, err := cache.Context(ctx).Get(token, obj)
expires, err := cache.Context(ctx).Get(token, email)
if err == cache.ErrNotFound {
return "", "", errors.New("token not found")
return "", errors.New("token not found")
} else if time.Until(expires).Seconds() < 0 {
return "", "", errors.New("token expired")
return "", errors.New("token expired")
} else if err != nil {
return "", "", microerr.InternalServerError("CacheReadToken", err.Error())
return "", microerr.InternalServerError("CacheReadToken", err.Error())
}
return obj.Id, obj.Email, nil
}
type tokenObject struct {
Id string
Email string
return email, nil
}