feat(identity): register accounts and resend verification mail
This commit is contained in:
1 parent
5e202ac972
commit
4436f626a3
55 files changed
+3227
-88
No files matched your search
@@ -32,19 +32,55 @@ type Handler struct {
|
||||
api.UnimplementedHandler
|
||||
|
||||
health *HealthHandler
|
||||
identity *IdentityHandler
|
||||
problems *problem.Responder
|
||||
}
|
||||
|
||||
var _ api.Handler = (*Handler)(nil)
|
||||
|
||||
func NewHandler(health *HealthHandler, problems *problem.Responder) *Handler {
|
||||
return &Handler{health: health, problems: problems}
|
||||
// HandlerOption adds the handler of a business area to Handler.
|
||||
type HandlerOption func(*Handler)
|
||||
|
||||
// WithIdentity serves the registration operations. A nil handler leaves them
|
||||
// to the embedded api.UnimplementedHandler, as when no database is
|
||||
// configured.
|
||||
func WithIdentity(identity *IdentityHandler) HandlerOption {
|
||||
return func(handler *Handler) { handler.identity = identity }
|
||||
}
|
||||
|
||||
func NewHandler(health *HealthHandler, problems *problem.Responder, options ...HandlerOption) *Handler {
|
||||
handler := &Handler{health: health, problems: problems}
|
||||
for _, option := range options {
|
||||
option(handler)
|
||||
}
|
||||
return handler
|
||||
}
|
||||
|
||||
func (handler *Handler) GetHealthz(ctx context.Context) (*api.HealthResponse, error) {
|
||||
return handler.health.GetHealthz(ctx)
|
||||
}
|
||||
|
||||
func (handler *Handler) RegisterAccount(
|
||||
ctx context.Context,
|
||||
request *api.RegistrationRequest,
|
||||
params api.RegisterAccountParams,
|
||||
) (api.RegisterAccountRes, error) {
|
||||
if handler.identity == nil {
|
||||
return handler.UnimplementedHandler.RegisterAccount(ctx, request, params)
|
||||
}
|
||||
return handler.identity.RegisterAccount(ctx, request, params)
|
||||
}
|
||||
|
||||
func (handler *Handler) ResendEmailVerification(
|
||||
ctx context.Context,
|
||||
request *api.EmailVerificationResendRequest,
|
||||
) (api.ResendEmailVerificationRes, error) {
|
||||
if handler.identity == nil {
|
||||
return handler.UnimplementedHandler.ResendEmailVerification(ctx, request)
|
||||
}
|
||||
return handler.identity.ResendEmailVerification(ctx, request)
|
||||
}
|
||||
|
||||
// NewError implements api.Handler for errors returned by operations.
|
||||
func (handler *Handler) NewError(ctx context.Context, err error) *api.ProblemStatusCode {
|
||||
return handler.problems.HandlerError(ctx, err)
|
||||
|
||||
Reference in new issue
Block a user