fix an error when calling VerifyToken with valid Token (#327)

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

* fix an error in user.VerifyToken

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

* OSD add another check for err in user CacheReadToken

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 21:47:24 +03:00
committed by GitHub
parent ff49510a73
commit 5220d7fade
2 changed files with 4 additions and 4 deletions

View File

@@ -501,7 +501,7 @@ func (domain *Domain) CacheReadToken(ctx context.Context, token string) (string,
expires, err := cache.Context(ctx).Get(token, email)
if err == cache.ErrNotFound {
if err != nil && err == cache.ErrNotFound {
return "", errors.New("token not found")
} else if time.Until(expires).Seconds() < 0 {
return "", errors.New("token expired")

View File

@@ -437,15 +437,15 @@ func (s *User) VerifyToken(ctx context.Context, req *pb.VerifyTokenRequest, rsp
// check if token is valid
email, err := s.domain.CacheReadToken(ctx, token)
if err.Error() == "token not found" {
if err != nil && err.Error() == "token not found" {
rsp.IsValid = false
rsp.Message = err.Error()
return nil
} else if err.Error() == "token expired" {
} else if err != nil && err.Error() == "token expired" {
rsp.IsValid = false
rsp.Message = err.Error()
return nil
} else if err.Error() == "token empty" {
} else if err != nil && err.Error() == "token empty" {
rsp.IsValid = false
rsp.Message = err.Error()
return nil