Skip to content

APIV2.VerifyEmail and APIV2.SetPassword invalidate all service tokens #121

@kzalys

Description

@kzalys

Currently if VerifyEmail and SetPassword operations are called with a service token, the token gets invalidated if the operation is successful (this is done to make the auth tokens sent in emails single use). This makes both of the operations unusable with service tokens.

We should update EmailServiceV2 to use tokens dedicated to emails. We'd need to introduce an Email token type on the authorizer. Then we could create a middleware that would invalidate email tokens if the gin.Context contains a 2xx status code and use the middleware at the router level for operations where we want to invalidate email tokens. The end result would look something like this:
usersGroup.PUT("/:id/email/verify", r.authorizer.WithAuthMiddleware(r, r.VerifyEmail), r.authorizer.InvalidateEmailTokenOnSuccess)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions