1
0
mirror of https://github.com/mainflux/mainflux.git synced 2025-04-29 13:49:28 +08:00

145 lines
4.7 KiB
Go
Raw Normal View History

// Copyright (c) Mainflux
// SPDX-License-Identifier: Apache-2.0
2018-05-10 23:53:25 +02:00
package api
import (
2019-07-18 15:01:09 +02:00
"context"
2018-05-10 23:53:25 +02:00
"fmt"
"time"
MF-538 - Improve logging and API errors (#866) * user service - wraping errors Signed-off-by: Ivan Milošević <iva@blokovi.com> * wrapping more errors unwrap only wrapped errors Signed-off-by: Ivan Milošević <iva@blokovi.com> * Add internal database error Wrap internal database error Signed-off-by: Ivan Milošević <iva@blokovi.com> * Wrap user not found error Signed-off-by: Ivan Milošević <iva@blokovi.com> * Wrapping errors in idp and hasher Signed-off-by: Ivan Milošević <iva@blokovi.com> * Use error.Is for testing errors in Identify test Signed-off-by: Ivan Milošević <iva@blokovi.com> * Get wraper from wrapped errors Signed-off-by: Ivan Milošević <iva@blokovi.com> * Switch order of wrapping errors Remove dead code (comments) Signed-off-by: Ivan Milošević <iva@blokovi.com> * assert true in tests Signed-off-by: Ivan Milošević <iva@blokovi.com> * Change comparing errors in tests (assert.True) Signed-off-by: Ivan Milošević <iva@blokovi.com> * Add errorRes structure to API responses in body in things service Signed-off-by: Ivan Milošević <iva@blokovi.com> * resolve conflicts after rebasing Signed-off-by: Ivan Milošević <iva@blokovi.com> * Create errors package Signed-off-by: Ivan Milošević <iva@blokovi.com> * implement new errors package Signed-off-by: Ivan Milošević <iva@blokovi.com> * Modify tests Signed-off-by: Ivan Milošević <iva@blokovi.com> * return copyright comments Signed-off-by: Ivan Milošević <iva@blokovi.com> * remove changes from .gitignore Signed-off-by: Ivan Milošević <iva@blokovi.com> * Move logging to encode errors Comment exported vars and methods Formatting Signed-off-by: Ivan Milošević <iva@blokovi.com> * Login function returns errors.Error Signed-off-by: Ivan Milošević <iva@blokovi.com> * Modify login tests to meet login returning errors.Error Signed-off-by: Ivan Milošević <iva@blokovi.com> * Error interface Signed-off-by: Ivan Milošević <iva@blokovi.com> * Change parameter in Wrapper to interface Error Signed-off-by: Ivan Milošević <iva@blokovi.com> * implement new error interface Signed-off-by: Ivan Milošević <iva@blokovi.com> * Modify tests to use new Error interface Signed-off-by: Ivan Milošević <iva@blokovi.com> * Fix Login Signed-off-by: Ivan Milošević <iva@blokovi.com> * Remove unnecessary errir casting Signed-off-by: Ivan Milošević <iva@blokovi.com> * new error interface implementation Signed-off-by: Ivan Milošević <iva@blokovi.com> * check if Error is empty in registrationEndpoint Signed-off-by: Ivan Milošević <iva@blokovi.com> * Add Empty factory function Use new Empty factory function Use isEmpty method Signed-off-by: Ivan Milošević <iva@blokovi.com> * Lose else in encodeError Signed-off-by: Ivan Milošević <iva@blokovi.com> * Modify tests Signed-off-by: Ivan Milošević <iva@blokovi.com> * Remove *json.UnmarshalTypeError and *json.SyntaxError types from encodeError type switch Signed-off-by: Ivan Milošević <iva@blokovi.com> * Fix nil error value in jwtIdentityProvider Signed-off-by: Ivan Milošević <iva@blokovi.com> * Fix gprc to use new error package Signed-off-by: Ivan Milošević <iva@blokovi.com> * rename receiver in errors package grpc errors Signed-off-by: Ivan Milošević <iva@blokovi.com> * remove debugging code Signed-off-by: Ivan Milošević <iva@blokovi.com> * Resolving conflicts after rebase Signed-off-by: Ivan Milošević <iva@blokovi.com> * Remove comment Signed-off-by: Ivan Milošević <iva@blokovi.com> * Remove Empty from custom error Implement custom error on new methods Signed-off-by: Ivan Milošević <iva@blokovi.com> * WIP tests Signed-off-by: Ivan Milošević <iva@blokovi.com> * remove wrap from Error interface Signed-off-by: Ivan Milošević <iva@blokovi.com> * password-change related tests remove debug code Signed-off-by: Ivan Milošević <iva@blokovi.com> * remove dead code Signed-off-by: Ivan Milošević <iva@blokovi.com> * Move all errors casting to errors package Signed-off-by: Ivan Milošević <iva@blokovi.com> * Fix comment in error package Signed-off-by: Ivan Milošević <iva@blokovi.com> * Change struct pointer to interface in package methods Signed-off-by: Ivan Milošević <iva@blokovi.com> * resolving reviews Signed-off-by: Ivan Milošević <iva@blokovi.com> * fix return in database.go Signed-off-by: Ivan Milošević <iva@blokovi.com> * Fix copyright header Signed-off-by: Ivan Milošević <iva@blokovi.com> * Fix comment in hasher Signed-off-by: Ivan Milošević <iva@blokovi.com>
2019-11-20 14:43:41 +01:00
"github.com/mainflux/mainflux/errors"
2018-05-10 23:53:25 +02:00
log "github.com/mainflux/mainflux/logger"
"github.com/mainflux/mainflux/users"
)
var _ users.Service = (*loggingMiddleware)(nil)
type loggingMiddleware struct {
logger log.Logger
svc users.Service
}
// LoggingMiddleware adds logging facilities to the core service.
func LoggingMiddleware(svc users.Service, logger log.Logger) users.Service {
return &loggingMiddleware{logger, svc}
}
MF-538 - Improve logging and API errors (#866) * user service - wraping errors Signed-off-by: Ivan Milošević <iva@blokovi.com> * wrapping more errors unwrap only wrapped errors Signed-off-by: Ivan Milošević <iva@blokovi.com> * Add internal database error Wrap internal database error Signed-off-by: Ivan Milošević <iva@blokovi.com> * Wrap user not found error Signed-off-by: Ivan Milošević <iva@blokovi.com> * Wrapping errors in idp and hasher Signed-off-by: Ivan Milošević <iva@blokovi.com> * Use error.Is for testing errors in Identify test Signed-off-by: Ivan Milošević <iva@blokovi.com> * Get wraper from wrapped errors Signed-off-by: Ivan Milošević <iva@blokovi.com> * Switch order of wrapping errors Remove dead code (comments) Signed-off-by: Ivan Milošević <iva@blokovi.com> * assert true in tests Signed-off-by: Ivan Milošević <iva@blokovi.com> * Change comparing errors in tests (assert.True) Signed-off-by: Ivan Milošević <iva@blokovi.com> * Add errorRes structure to API responses in body in things service Signed-off-by: Ivan Milošević <iva@blokovi.com> * resolve conflicts after rebasing Signed-off-by: Ivan Milošević <iva@blokovi.com> * Create errors package Signed-off-by: Ivan Milošević <iva@blokovi.com> * implement new errors package Signed-off-by: Ivan Milošević <iva@blokovi.com> * Modify tests Signed-off-by: Ivan Milošević <iva@blokovi.com> * return copyright comments Signed-off-by: Ivan Milošević <iva@blokovi.com> * remove changes from .gitignore Signed-off-by: Ivan Milošević <iva@blokovi.com> * Move logging to encode errors Comment exported vars and methods Formatting Signed-off-by: Ivan Milošević <iva@blokovi.com> * Login function returns errors.Error Signed-off-by: Ivan Milošević <iva@blokovi.com> * Modify login tests to meet login returning errors.Error Signed-off-by: Ivan Milošević <iva@blokovi.com> * Error interface Signed-off-by: Ivan Milošević <iva@blokovi.com> * Change parameter in Wrapper to interface Error Signed-off-by: Ivan Milošević <iva@blokovi.com> * implement new error interface Signed-off-by: Ivan Milošević <iva@blokovi.com> * Modify tests to use new Error interface Signed-off-by: Ivan Milošević <iva@blokovi.com> * Fix Login Signed-off-by: Ivan Milošević <iva@blokovi.com> * Remove unnecessary errir casting Signed-off-by: Ivan Milošević <iva@blokovi.com> * new error interface implementation Signed-off-by: Ivan Milošević <iva@blokovi.com> * check if Error is empty in registrationEndpoint Signed-off-by: Ivan Milošević <iva@blokovi.com> * Add Empty factory function Use new Empty factory function Use isEmpty method Signed-off-by: Ivan Milošević <iva@blokovi.com> * Lose else in encodeError Signed-off-by: Ivan Milošević <iva@blokovi.com> * Modify tests Signed-off-by: Ivan Milošević <iva@blokovi.com> * Remove *json.UnmarshalTypeError and *json.SyntaxError types from encodeError type switch Signed-off-by: Ivan Milošević <iva@blokovi.com> * Fix nil error value in jwtIdentityProvider Signed-off-by: Ivan Milošević <iva@blokovi.com> * Fix gprc to use new error package Signed-off-by: Ivan Milošević <iva@blokovi.com> * rename receiver in errors package grpc errors Signed-off-by: Ivan Milošević <iva@blokovi.com> * remove debugging code Signed-off-by: Ivan Milošević <iva@blokovi.com> * Resolving conflicts after rebase Signed-off-by: Ivan Milošević <iva@blokovi.com> * Remove comment Signed-off-by: Ivan Milošević <iva@blokovi.com> * Remove Empty from custom error Implement custom error on new methods Signed-off-by: Ivan Milošević <iva@blokovi.com> * WIP tests Signed-off-by: Ivan Milošević <iva@blokovi.com> * remove wrap from Error interface Signed-off-by: Ivan Milošević <iva@blokovi.com> * password-change related tests remove debug code Signed-off-by: Ivan Milošević <iva@blokovi.com> * remove dead code Signed-off-by: Ivan Milošević <iva@blokovi.com> * Move all errors casting to errors package Signed-off-by: Ivan Milošević <iva@blokovi.com> * Fix comment in error package Signed-off-by: Ivan Milošević <iva@blokovi.com> * Change struct pointer to interface in package methods Signed-off-by: Ivan Milošević <iva@blokovi.com> * resolving reviews Signed-off-by: Ivan Milošević <iva@blokovi.com> * fix return in database.go Signed-off-by: Ivan Milošević <iva@blokovi.com> * Fix copyright header Signed-off-by: Ivan Milošević <iva@blokovi.com> * Fix comment in hasher Signed-off-by: Ivan Milošević <iva@blokovi.com>
2019-11-20 14:43:41 +01:00
func (lm *loggingMiddleware) Register(ctx context.Context, user users.User) (err errors.Error) {
2018-05-10 23:53:25 +02:00
defer func(begin time.Time) {
message := fmt.Sprintf("Method register for user %s took %s to complete", user.Email, time.Since(begin))
if err != nil {
lm.logger.Warn(fmt.Sprintf("%s with error: %s.", message, err))
return
}
lm.logger.Info(fmt.Sprintf("%s without errors.", message))
}(time.Now())
2019-07-18 15:01:09 +02:00
return lm.svc.Register(ctx, user)
2018-05-10 23:53:25 +02:00
}
MF-538 - Improve logging and API errors (#866) * user service - wraping errors Signed-off-by: Ivan Milošević <iva@blokovi.com> * wrapping more errors unwrap only wrapped errors Signed-off-by: Ivan Milošević <iva@blokovi.com> * Add internal database error Wrap internal database error Signed-off-by: Ivan Milošević <iva@blokovi.com> * Wrap user not found error Signed-off-by: Ivan Milošević <iva@blokovi.com> * Wrapping errors in idp and hasher Signed-off-by: Ivan Milošević <iva@blokovi.com> * Use error.Is for testing errors in Identify test Signed-off-by: Ivan Milošević <iva@blokovi.com> * Get wraper from wrapped errors Signed-off-by: Ivan Milošević <iva@blokovi.com> * Switch order of wrapping errors Remove dead code (comments) Signed-off-by: Ivan Milošević <iva@blokovi.com> * assert true in tests Signed-off-by: Ivan Milošević <iva@blokovi.com> * Change comparing errors in tests (assert.True) Signed-off-by: Ivan Milošević <iva@blokovi.com> * Add errorRes structure to API responses in body in things service Signed-off-by: Ivan Milošević <iva@blokovi.com> * resolve conflicts after rebasing Signed-off-by: Ivan Milošević <iva@blokovi.com> * Create errors package Signed-off-by: Ivan Milošević <iva@blokovi.com> * implement new errors package Signed-off-by: Ivan Milošević <iva@blokovi.com> * Modify tests Signed-off-by: Ivan Milošević <iva@blokovi.com> * return copyright comments Signed-off-by: Ivan Milošević <iva@blokovi.com> * remove changes from .gitignore Signed-off-by: Ivan Milošević <iva@blokovi.com> * Move logging to encode errors Comment exported vars and methods Formatting Signed-off-by: Ivan Milošević <iva@blokovi.com> * Login function returns errors.Error Signed-off-by: Ivan Milošević <iva@blokovi.com> * Modify login tests to meet login returning errors.Error Signed-off-by: Ivan Milošević <iva@blokovi.com> * Error interface Signed-off-by: Ivan Milošević <iva@blokovi.com> * Change parameter in Wrapper to interface Error Signed-off-by: Ivan Milošević <iva@blokovi.com> * implement new error interface Signed-off-by: Ivan Milošević <iva@blokovi.com> * Modify tests to use new Error interface Signed-off-by: Ivan Milošević <iva@blokovi.com> * Fix Login Signed-off-by: Ivan Milošević <iva@blokovi.com> * Remove unnecessary errir casting Signed-off-by: Ivan Milošević <iva@blokovi.com> * new error interface implementation Signed-off-by: Ivan Milošević <iva@blokovi.com> * check if Error is empty in registrationEndpoint Signed-off-by: Ivan Milošević <iva@blokovi.com> * Add Empty factory function Use new Empty factory function Use isEmpty method Signed-off-by: Ivan Milošević <iva@blokovi.com> * Lose else in encodeError Signed-off-by: Ivan Milošević <iva@blokovi.com> * Modify tests Signed-off-by: Ivan Milošević <iva@blokovi.com> * Remove *json.UnmarshalTypeError and *json.SyntaxError types from encodeError type switch Signed-off-by: Ivan Milošević <iva@blokovi.com> * Fix nil error value in jwtIdentityProvider Signed-off-by: Ivan Milošević <iva@blokovi.com> * Fix gprc to use new error package Signed-off-by: Ivan Milošević <iva@blokovi.com> * rename receiver in errors package grpc errors Signed-off-by: Ivan Milošević <iva@blokovi.com> * remove debugging code Signed-off-by: Ivan Milošević <iva@blokovi.com> * Resolving conflicts after rebase Signed-off-by: Ivan Milošević <iva@blokovi.com> * Remove comment Signed-off-by: Ivan Milošević <iva@blokovi.com> * Remove Empty from custom error Implement custom error on new methods Signed-off-by: Ivan Milošević <iva@blokovi.com> * WIP tests Signed-off-by: Ivan Milošević <iva@blokovi.com> * remove wrap from Error interface Signed-off-by: Ivan Milošević <iva@blokovi.com> * password-change related tests remove debug code Signed-off-by: Ivan Milošević <iva@blokovi.com> * remove dead code Signed-off-by: Ivan Milošević <iva@blokovi.com> * Move all errors casting to errors package Signed-off-by: Ivan Milošević <iva@blokovi.com> * Fix comment in error package Signed-off-by: Ivan Milošević <iva@blokovi.com> * Change struct pointer to interface in package methods Signed-off-by: Ivan Milošević <iva@blokovi.com> * resolving reviews Signed-off-by: Ivan Milošević <iva@blokovi.com> * fix return in database.go Signed-off-by: Ivan Milošević <iva@blokovi.com> * Fix copyright header Signed-off-by: Ivan Milošević <iva@blokovi.com> * Fix comment in hasher Signed-off-by: Ivan Milošević <iva@blokovi.com>
2019-11-20 14:43:41 +01:00
func (lm *loggingMiddleware) Login(ctx context.Context, user users.User) (token string, err errors.Error) {
2018-05-10 23:53:25 +02:00
defer func(begin time.Time) {
message := fmt.Sprintf("Method login for user %s took %s to complete", user.Email, time.Since(begin))
if err != nil {
lm.logger.Warn(fmt.Sprintf("%s with error: %s.", message, err))
return
}
lm.logger.Info(fmt.Sprintf("%s without errors.", message))
}(time.Now())
2019-07-18 15:01:09 +02:00
return lm.svc.Login(ctx, user)
2018-05-10 23:53:25 +02:00
}
MF-538 - Improve logging and API errors (#866) * user service - wraping errors Signed-off-by: Ivan Milošević <iva@blokovi.com> * wrapping more errors unwrap only wrapped errors Signed-off-by: Ivan Milošević <iva@blokovi.com> * Add internal database error Wrap internal database error Signed-off-by: Ivan Milošević <iva@blokovi.com> * Wrap user not found error Signed-off-by: Ivan Milošević <iva@blokovi.com> * Wrapping errors in idp and hasher Signed-off-by: Ivan Milošević <iva@blokovi.com> * Use error.Is for testing errors in Identify test Signed-off-by: Ivan Milošević <iva@blokovi.com> * Get wraper from wrapped errors Signed-off-by: Ivan Milošević <iva@blokovi.com> * Switch order of wrapping errors Remove dead code (comments) Signed-off-by: Ivan Milošević <iva@blokovi.com> * assert true in tests Signed-off-by: Ivan Milošević <iva@blokovi.com> * Change comparing errors in tests (assert.True) Signed-off-by: Ivan Milošević <iva@blokovi.com> * Add errorRes structure to API responses in body in things service Signed-off-by: Ivan Milošević <iva@blokovi.com> * resolve conflicts after rebasing Signed-off-by: Ivan Milošević <iva@blokovi.com> * Create errors package Signed-off-by: Ivan Milošević <iva@blokovi.com> * implement new errors package Signed-off-by: Ivan Milošević <iva@blokovi.com> * Modify tests Signed-off-by: Ivan Milošević <iva@blokovi.com> * return copyright comments Signed-off-by: Ivan Milošević <iva@blokovi.com> * remove changes from .gitignore Signed-off-by: Ivan Milošević <iva@blokovi.com> * Move logging to encode errors Comment exported vars and methods Formatting Signed-off-by: Ivan Milošević <iva@blokovi.com> * Login function returns errors.Error Signed-off-by: Ivan Milošević <iva@blokovi.com> * Modify login tests to meet login returning errors.Error Signed-off-by: Ivan Milošević <iva@blokovi.com> * Error interface Signed-off-by: Ivan Milošević <iva@blokovi.com> * Change parameter in Wrapper to interface Error Signed-off-by: Ivan Milošević <iva@blokovi.com> * implement new error interface Signed-off-by: Ivan Milošević <iva@blokovi.com> * Modify tests to use new Error interface Signed-off-by: Ivan Milošević <iva@blokovi.com> * Fix Login Signed-off-by: Ivan Milošević <iva@blokovi.com> * Remove unnecessary errir casting Signed-off-by: Ivan Milošević <iva@blokovi.com> * new error interface implementation Signed-off-by: Ivan Milošević <iva@blokovi.com> * check if Error is empty in registrationEndpoint Signed-off-by: Ivan Milošević <iva@blokovi.com> * Add Empty factory function Use new Empty factory function Use isEmpty method Signed-off-by: Ivan Milošević <iva@blokovi.com> * Lose else in encodeError Signed-off-by: Ivan Milošević <iva@blokovi.com> * Modify tests Signed-off-by: Ivan Milošević <iva@blokovi.com> * Remove *json.UnmarshalTypeError and *json.SyntaxError types from encodeError type switch Signed-off-by: Ivan Milošević <iva@blokovi.com> * Fix nil error value in jwtIdentityProvider Signed-off-by: Ivan Milošević <iva@blokovi.com> * Fix gprc to use new error package Signed-off-by: Ivan Milošević <iva@blokovi.com> * rename receiver in errors package grpc errors Signed-off-by: Ivan Milošević <iva@blokovi.com> * remove debugging code Signed-off-by: Ivan Milošević <iva@blokovi.com> * Resolving conflicts after rebase Signed-off-by: Ivan Milošević <iva@blokovi.com> * Remove comment Signed-off-by: Ivan Milošević <iva@blokovi.com> * Remove Empty from custom error Implement custom error on new methods Signed-off-by: Ivan Milošević <iva@blokovi.com> * WIP tests Signed-off-by: Ivan Milošević <iva@blokovi.com> * remove wrap from Error interface Signed-off-by: Ivan Milošević <iva@blokovi.com> * password-change related tests remove debug code Signed-off-by: Ivan Milošević <iva@blokovi.com> * remove dead code Signed-off-by: Ivan Milošević <iva@blokovi.com> * Move all errors casting to errors package Signed-off-by: Ivan Milošević <iva@blokovi.com> * Fix comment in error package Signed-off-by: Ivan Milošević <iva@blokovi.com> * Change struct pointer to interface in package methods Signed-off-by: Ivan Milošević <iva@blokovi.com> * resolving reviews Signed-off-by: Ivan Milošević <iva@blokovi.com> * fix return in database.go Signed-off-by: Ivan Milošević <iva@blokovi.com> * Fix copyright header Signed-off-by: Ivan Milošević <iva@blokovi.com> * Fix comment in hasher Signed-off-by: Ivan Milošević <iva@blokovi.com>
2019-11-20 14:43:41 +01:00
func (lm *loggingMiddleware) Identify(key string) (id string, err errors.Error) {
2018-05-10 23:53:25 +02:00
defer func(begin time.Time) {
MF-858 Users metadata (#861) * add users metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add users metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add metadata to users Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add metadata to users Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * run.sh Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add metadata to users Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add default value for metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add default value for metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * when metadata is not set dont save 'null' string Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * when metadata is not set dont save 'null' string Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * change metadata type, add error handling Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add pause Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * remove extra char Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * retype from string to []byte Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add wait logic for gnatsd Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * few small fixes Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix identityRes Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add users metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add users metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * revert run.sh for now as gnats availability check is solved in other PR Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * revert changes Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * change metadata database/sql handling Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix commit issues Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * small change to errors handling Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * minor comment change Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
2019-09-28 11:15:41 +00:00
message := fmt.Sprintf("Method identity for user %s took %s to complete", id, time.Since(begin))
2018-05-10 23:53:25 +02:00
if err != nil {
lm.logger.Warn(fmt.Sprintf("%s with error: %s.", message, err))
return
}
lm.logger.Info(fmt.Sprintf("%s without errors.", message))
}(time.Now())
return lm.svc.Identify(key)
}
MF-858 Users metadata (#861) * add users metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add users metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add metadata to users Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add metadata to users Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * run.sh Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add metadata to users Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add default value for metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add default value for metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * when metadata is not set dont save 'null' string Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * when metadata is not set dont save 'null' string Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * change metadata type, add error handling Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add pause Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * remove extra char Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * retype from string to []byte Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add wait logic for gnatsd Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * few small fixes Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix identityRes Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add users metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add users metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * revert run.sh for now as gnats availability check is solved in other PR Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * revert changes Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * change metadata database/sql handling Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix commit issues Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * small change to errors handling Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * minor comment change Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
2019-09-28 11:15:41 +00:00
MF-538 - Improve logging and API errors (#866) * user service - wraping errors Signed-off-by: Ivan Milošević <iva@blokovi.com> * wrapping more errors unwrap only wrapped errors Signed-off-by: Ivan Milošević <iva@blokovi.com> * Add internal database error Wrap internal database error Signed-off-by: Ivan Milošević <iva@blokovi.com> * Wrap user not found error Signed-off-by: Ivan Milošević <iva@blokovi.com> * Wrapping errors in idp and hasher Signed-off-by: Ivan Milošević <iva@blokovi.com> * Use error.Is for testing errors in Identify test Signed-off-by: Ivan Milošević <iva@blokovi.com> * Get wraper from wrapped errors Signed-off-by: Ivan Milošević <iva@blokovi.com> * Switch order of wrapping errors Remove dead code (comments) Signed-off-by: Ivan Milošević <iva@blokovi.com> * assert true in tests Signed-off-by: Ivan Milošević <iva@blokovi.com> * Change comparing errors in tests (assert.True) Signed-off-by: Ivan Milošević <iva@blokovi.com> * Add errorRes structure to API responses in body in things service Signed-off-by: Ivan Milošević <iva@blokovi.com> * resolve conflicts after rebasing Signed-off-by: Ivan Milošević <iva@blokovi.com> * Create errors package Signed-off-by: Ivan Milošević <iva@blokovi.com> * implement new errors package Signed-off-by: Ivan Milošević <iva@blokovi.com> * Modify tests Signed-off-by: Ivan Milošević <iva@blokovi.com> * return copyright comments Signed-off-by: Ivan Milošević <iva@blokovi.com> * remove changes from .gitignore Signed-off-by: Ivan Milošević <iva@blokovi.com> * Move logging to encode errors Comment exported vars and methods Formatting Signed-off-by: Ivan Milošević <iva@blokovi.com> * Login function returns errors.Error Signed-off-by: Ivan Milošević <iva@blokovi.com> * Modify login tests to meet login returning errors.Error Signed-off-by: Ivan Milošević <iva@blokovi.com> * Error interface Signed-off-by: Ivan Milošević <iva@blokovi.com> * Change parameter in Wrapper to interface Error Signed-off-by: Ivan Milošević <iva@blokovi.com> * implement new error interface Signed-off-by: Ivan Milošević <iva@blokovi.com> * Modify tests to use new Error interface Signed-off-by: Ivan Milošević <iva@blokovi.com> * Fix Login Signed-off-by: Ivan Milošević <iva@blokovi.com> * Remove unnecessary errir casting Signed-off-by: Ivan Milošević <iva@blokovi.com> * new error interface implementation Signed-off-by: Ivan Milošević <iva@blokovi.com> * check if Error is empty in registrationEndpoint Signed-off-by: Ivan Milošević <iva@blokovi.com> * Add Empty factory function Use new Empty factory function Use isEmpty method Signed-off-by: Ivan Milošević <iva@blokovi.com> * Lose else in encodeError Signed-off-by: Ivan Milošević <iva@blokovi.com> * Modify tests Signed-off-by: Ivan Milošević <iva@blokovi.com> * Remove *json.UnmarshalTypeError and *json.SyntaxError types from encodeError type switch Signed-off-by: Ivan Milošević <iva@blokovi.com> * Fix nil error value in jwtIdentityProvider Signed-off-by: Ivan Milošević <iva@blokovi.com> * Fix gprc to use new error package Signed-off-by: Ivan Milošević <iva@blokovi.com> * rename receiver in errors package grpc errors Signed-off-by: Ivan Milošević <iva@blokovi.com> * remove debugging code Signed-off-by: Ivan Milošević <iva@blokovi.com> * Resolving conflicts after rebase Signed-off-by: Ivan Milošević <iva@blokovi.com> * Remove comment Signed-off-by: Ivan Milošević <iva@blokovi.com> * Remove Empty from custom error Implement custom error on new methods Signed-off-by: Ivan Milošević <iva@blokovi.com> * WIP tests Signed-off-by: Ivan Milošević <iva@blokovi.com> * remove wrap from Error interface Signed-off-by: Ivan Milošević <iva@blokovi.com> * password-change related tests remove debug code Signed-off-by: Ivan Milošević <iva@blokovi.com> * remove dead code Signed-off-by: Ivan Milošević <iva@blokovi.com> * Move all errors casting to errors package Signed-off-by: Ivan Milošević <iva@blokovi.com> * Fix comment in error package Signed-off-by: Ivan Milošević <iva@blokovi.com> * Change struct pointer to interface in package methods Signed-off-by: Ivan Milošević <iva@blokovi.com> * resolving reviews Signed-off-by: Ivan Milošević <iva@blokovi.com> * fix return in database.go Signed-off-by: Ivan Milošević <iva@blokovi.com> * Fix copyright header Signed-off-by: Ivan Milošević <iva@blokovi.com> * Fix comment in hasher Signed-off-by: Ivan Milošević <iva@blokovi.com>
2019-11-20 14:43:41 +01:00
func (lm *loggingMiddleware) UserInfo(ctx context.Context, token string) (u users.User, err errors.Error) {
MF-858 Users metadata (#861) * add users metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add users metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add metadata to users Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add metadata to users Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * run.sh Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add metadata to users Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add default value for metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add default value for metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * when metadata is not set dont save 'null' string Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * when metadata is not set dont save 'null' string Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * change metadata type, add error handling Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add pause Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * remove extra char Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * retype from string to []byte Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add wait logic for gnatsd Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * few small fixes Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix identityRes Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add users metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add users metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * revert run.sh for now as gnats availability check is solved in other PR Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * revert changes Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * change metadata database/sql handling Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix commit issues Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * small change to errors handling Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * minor comment change Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
2019-09-28 11:15:41 +00:00
defer func(begin time.Time) {
message := fmt.Sprintf("Method user_info for user %s took %s to complete", u.Email, time.Since(begin))
if err != nil {
lm.logger.Warn(fmt.Sprintf("%s with error: %s.", message, err))
return
}
lm.logger.Info(fmt.Sprintf("%s without errors.", message))
}(time.Now())
MF-922 - Add UpdateUser endpoint (#923) * MF-922 - Add User Update endpoint Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Fix reviews Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Revert Update function Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Fix typo Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Update swagger Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Fix Things swagger Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Fix swagger Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * update Things swagger Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Fix users swagger Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Fix mocks Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Fix method name Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Fix swagger Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Fix swagger Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Fix swagger Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Fix typo Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Use User instead of metadata Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Fix reviews Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Fix reviews Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Fix reviews Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Fix reviews Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
2019-10-31 16:36:19 +01:00
return lm.svc.UserInfo(ctx, token)
}
MF-538 - Improve logging and API errors (#866) * user service - wraping errors Signed-off-by: Ivan Milošević <iva@blokovi.com> * wrapping more errors unwrap only wrapped errors Signed-off-by: Ivan Milošević <iva@blokovi.com> * Add internal database error Wrap internal database error Signed-off-by: Ivan Milošević <iva@blokovi.com> * Wrap user not found error Signed-off-by: Ivan Milošević <iva@blokovi.com> * Wrapping errors in idp and hasher Signed-off-by: Ivan Milošević <iva@blokovi.com> * Use error.Is for testing errors in Identify test Signed-off-by: Ivan Milošević <iva@blokovi.com> * Get wraper from wrapped errors Signed-off-by: Ivan Milošević <iva@blokovi.com> * Switch order of wrapping errors Remove dead code (comments) Signed-off-by: Ivan Milošević <iva@blokovi.com> * assert true in tests Signed-off-by: Ivan Milošević <iva@blokovi.com> * Change comparing errors in tests (assert.True) Signed-off-by: Ivan Milošević <iva@blokovi.com> * Add errorRes structure to API responses in body in things service Signed-off-by: Ivan Milošević <iva@blokovi.com> * resolve conflicts after rebasing Signed-off-by: Ivan Milošević <iva@blokovi.com> * Create errors package Signed-off-by: Ivan Milošević <iva@blokovi.com> * implement new errors package Signed-off-by: Ivan Milošević <iva@blokovi.com> * Modify tests Signed-off-by: Ivan Milošević <iva@blokovi.com> * return copyright comments Signed-off-by: Ivan Milošević <iva@blokovi.com> * remove changes from .gitignore Signed-off-by: Ivan Milošević <iva@blokovi.com> * Move logging to encode errors Comment exported vars and methods Formatting Signed-off-by: Ivan Milošević <iva@blokovi.com> * Login function returns errors.Error Signed-off-by: Ivan Milošević <iva@blokovi.com> * Modify login tests to meet login returning errors.Error Signed-off-by: Ivan Milošević <iva@blokovi.com> * Error interface Signed-off-by: Ivan Milošević <iva@blokovi.com> * Change parameter in Wrapper to interface Error Signed-off-by: Ivan Milošević <iva@blokovi.com> * implement new error interface Signed-off-by: Ivan Milošević <iva@blokovi.com> * Modify tests to use new Error interface Signed-off-by: Ivan Milošević <iva@blokovi.com> * Fix Login Signed-off-by: Ivan Milošević <iva@blokovi.com> * Remove unnecessary errir casting Signed-off-by: Ivan Milošević <iva@blokovi.com> * new error interface implementation Signed-off-by: Ivan Milošević <iva@blokovi.com> * check if Error is empty in registrationEndpoint Signed-off-by: Ivan Milošević <iva@blokovi.com> * Add Empty factory function Use new Empty factory function Use isEmpty method Signed-off-by: Ivan Milošević <iva@blokovi.com> * Lose else in encodeError Signed-off-by: Ivan Milošević <iva@blokovi.com> * Modify tests Signed-off-by: Ivan Milošević <iva@blokovi.com> * Remove *json.UnmarshalTypeError and *json.SyntaxError types from encodeError type switch Signed-off-by: Ivan Milošević <iva@blokovi.com> * Fix nil error value in jwtIdentityProvider Signed-off-by: Ivan Milošević <iva@blokovi.com> * Fix gprc to use new error package Signed-off-by: Ivan Milošević <iva@blokovi.com> * rename receiver in errors package grpc errors Signed-off-by: Ivan Milošević <iva@blokovi.com> * remove debugging code Signed-off-by: Ivan Milošević <iva@blokovi.com> * Resolving conflicts after rebase Signed-off-by: Ivan Milošević <iva@blokovi.com> * Remove comment Signed-off-by: Ivan Milošević <iva@blokovi.com> * Remove Empty from custom error Implement custom error on new methods Signed-off-by: Ivan Milošević <iva@blokovi.com> * WIP tests Signed-off-by: Ivan Milošević <iva@blokovi.com> * remove wrap from Error interface Signed-off-by: Ivan Milošević <iva@blokovi.com> * password-change related tests remove debug code Signed-off-by: Ivan Milošević <iva@blokovi.com> * remove dead code Signed-off-by: Ivan Milošević <iva@blokovi.com> * Move all errors casting to errors package Signed-off-by: Ivan Milošević <iva@blokovi.com> * Fix comment in error package Signed-off-by: Ivan Milošević <iva@blokovi.com> * Change struct pointer to interface in package methods Signed-off-by: Ivan Milošević <iva@blokovi.com> * resolving reviews Signed-off-by: Ivan Milošević <iva@blokovi.com> * fix return in database.go Signed-off-by: Ivan Milošević <iva@blokovi.com> * Fix copyright header Signed-off-by: Ivan Milošević <iva@blokovi.com> * Fix comment in hasher Signed-off-by: Ivan Milošević <iva@blokovi.com>
2019-11-20 14:43:41 +01:00
func (lm *loggingMiddleware) UpdateUser(ctx context.Context, token string, u users.User) (err errors.Error) {
MF-922 - Add UpdateUser endpoint (#923) * MF-922 - Add User Update endpoint Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Fix reviews Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Revert Update function Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Fix typo Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Update swagger Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Fix Things swagger Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Fix swagger Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * update Things swagger Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Fix users swagger Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Fix mocks Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Fix method name Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Fix swagger Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Fix swagger Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Fix swagger Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Fix typo Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Use User instead of metadata Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Fix reviews Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Fix reviews Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Fix reviews Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Fix reviews Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
2019-10-31 16:36:19 +01:00
defer func(begin time.Time) {
message := fmt.Sprintf("Method update_user for user %s took %s to complete", u.Email, time.Since(begin))
if err != nil {
lm.logger.Warn(fmt.Sprintf("%s with error: %s.", message, err))
return
}
lm.logger.Info(fmt.Sprintf("%s without errors.", message))
}(time.Now())
return lm.svc.UpdateUser(ctx, token, u)
MF-858 Users metadata (#861) * add users metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add users metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add metadata to users Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add metadata to users Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * run.sh Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add metadata to users Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add default value for metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add default value for metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * when metadata is not set dont save 'null' string Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * when metadata is not set dont save 'null' string Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * change metadata type, add error handling Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add pause Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * remove extra char Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * retype from string to []byte Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add wait logic for gnatsd Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * few small fixes Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix identityRes Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add users metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add users metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * revert run.sh for now as gnats availability check is solved in other PR Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * revert changes Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * change metadata database/sql handling Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix commit issues Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * small change to errors handling Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * minor comment change Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
2019-09-28 11:15:41 +00:00
}
MF-532 - Password reset (#873) * add users metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add users metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add users metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add users metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add users metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add users metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add users metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add users metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add metadata to users Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add metadata to users Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add metadata to users Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add metadata to users Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add metadata to users Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add metadata to users Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add metadata to users Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add metadata to users Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add metadata to users Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add metadata to users Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add metadata to users Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add default value for metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add default value for metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add default value for metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add default value for metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add default value for metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add default value for metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * when metadata is not set dont save 'null' string Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * when metadata is not set dont save 'null' string Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * when metadata is not set dont save 'null' string Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * change metadata type, add error handling Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * change metadata type, add error handling Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * change metadata type, add error handling Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * remove extra char Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * remove extra char Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * remove extra char Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * few small fixes Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * few small fixes Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * few small fixes Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix identityRes Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix identityRes Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix identityRes Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add users metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add users metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add users metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * password reset, sketching Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * password reset, sketching Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * password reset, sketching Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * password reset, sketching Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * password reset, sketching Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * password reset, sketching Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * password reset, sketching Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * password reset, sketching Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * password reset, sketching Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * password reset, sketching Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * password reset, sketching Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * password reset, sketching Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * mail Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * mail Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * reset request endpoint Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * reset request endpoint Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * reset request endpoint Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add token Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add token Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add token Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add token methods Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add token methods Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add token methods Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * adding token endpoints Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * adding token endpoints Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * adding token endpoints Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * adding reset passw endpoint Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * adding reset passw endpoint Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * adding reset passw endpoint Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add logic for token verifying Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add logic for token verifying Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add logic for token verifying Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * remove mail from main Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * remove mail from main Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * remove mail from main Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * token and passwd update logic Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * token and passwd update logic Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * token and passwd update logic Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * reorganize mailing code Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add comments for password reset flow Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add comments for password reset flow Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * change struct members to private Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * small changes Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * small changes Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * small changes Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add space Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add space Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add space Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * revert back changes used for testing Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * revert back changes used for testing Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * revert back changes used for testing Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * reorganize endpoints, extract host for link from Referer Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * reorganize endpoints, extract host for link from Referer Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * adding swagger docs for reset passw Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * adding swagger docs for reset passw Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix imports and some typos Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix imports and some typos Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * adding swagger docs for reset passw Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * reorganize endpoints, extract host for link from Referer Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * reorganize endpoints, extract host for link from Referer Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * addint test and update swagger for pass reset Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * addint test and update swagger for pass reset Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * addint test and update swagger for pass reset Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * adding test for endpoint Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * adding test for endpoint Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * adding test for endpoint Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * adding test for endpoint Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * adding endpoint test Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * adding endpoint test Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * adding endpoint test Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * change token generation Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * change token generation Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * change token generation Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * reorganize and change token gen Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * reorganize and change token gen Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * reorganize and change token gen Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * addint token and mail Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * adding token env Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * adding token env Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix error reporting Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix some comments and update readme Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix some comments and update readme Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix some comments and update readme Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * update readme Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix problmes due merge Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix problmes due merge Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix typos Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix typos Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add trusted certificates Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add endpoint for password change of currently authenticated user Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add env variable for conf reset endpoint Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add metadata to users Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add default value for metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add default value for metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * when metadata is not set dont save 'null' string Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * change metadata type, add error handling Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * remove extra char Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * few small fixes Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix identityRes Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add users metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * password reset, sketching Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * password reset, sketching Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * password reset, sketching Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * password reset, sketching Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * reset request endpoint Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * adding token endpoints Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * adding reset passw endpoint Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add logic for token verifying Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * remove mail from main Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * small changes Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add space Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * revert back changes used for testing Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * reorganize endpoints, extract host for link from Referer Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * reorganize endpoints, extract host for link from Referer Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * addint test and update swagger for pass reset Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * adding endpoint test Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix some comments and update readme Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add env variable for conf reset endpoint Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix tests Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * resolving some style comments Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * minor fixes due to bad merge Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix problem with unsigned commits Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix problem with unsigned commits Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix call to users.New Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix call to users.New Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * rename file Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * rename to email.go Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * additional comments Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * additional comments Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * refactor email util Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * refactor email util Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * refactor email util Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * refactor email util Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * remove debug bin Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add driver conf for mail Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * refactor email Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * refactor email Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix failing tests Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add testify Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * small fix Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add token conf Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * small fix Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * small fix Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * configurable email template Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix missing var Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add env for email template file Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add env for email template file Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix tests Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix test Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix test Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * revert to master Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * remove dev container Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * small fixes, typos, namings Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix typo Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * resolving comments Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * resolving comments Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * resolving comments Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * resolving comments Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * resolving comments Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add line Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * return err from email New() Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * change MF_TOKEN_RESET_ENDPOINT Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add and remove env vars Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * separate password logic into two methods Change and Reset Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * update comments Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * remove blank line Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * update docs Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * dont use camel case Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * small fix Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * reorganize email template for passw reset Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * reorganize email template for passw reset Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
2019-10-22 14:53:14 +02:00
MF-538 - Improve logging and API errors (#866) * user service - wraping errors Signed-off-by: Ivan Milošević <iva@blokovi.com> * wrapping more errors unwrap only wrapped errors Signed-off-by: Ivan Milošević <iva@blokovi.com> * Add internal database error Wrap internal database error Signed-off-by: Ivan Milošević <iva@blokovi.com> * Wrap user not found error Signed-off-by: Ivan Milošević <iva@blokovi.com> * Wrapping errors in idp and hasher Signed-off-by: Ivan Milošević <iva@blokovi.com> * Use error.Is for testing errors in Identify test Signed-off-by: Ivan Milošević <iva@blokovi.com> * Get wraper from wrapped errors Signed-off-by: Ivan Milošević <iva@blokovi.com> * Switch order of wrapping errors Remove dead code (comments) Signed-off-by: Ivan Milošević <iva@blokovi.com> * assert true in tests Signed-off-by: Ivan Milošević <iva@blokovi.com> * Change comparing errors in tests (assert.True) Signed-off-by: Ivan Milošević <iva@blokovi.com> * Add errorRes structure to API responses in body in things service Signed-off-by: Ivan Milošević <iva@blokovi.com> * resolve conflicts after rebasing Signed-off-by: Ivan Milošević <iva@blokovi.com> * Create errors package Signed-off-by: Ivan Milošević <iva@blokovi.com> * implement new errors package Signed-off-by: Ivan Milošević <iva@blokovi.com> * Modify tests Signed-off-by: Ivan Milošević <iva@blokovi.com> * return copyright comments Signed-off-by: Ivan Milošević <iva@blokovi.com> * remove changes from .gitignore Signed-off-by: Ivan Milošević <iva@blokovi.com> * Move logging to encode errors Comment exported vars and methods Formatting Signed-off-by: Ivan Milošević <iva@blokovi.com> * Login function returns errors.Error Signed-off-by: Ivan Milošević <iva@blokovi.com> * Modify login tests to meet login returning errors.Error Signed-off-by: Ivan Milošević <iva@blokovi.com> * Error interface Signed-off-by: Ivan Milošević <iva@blokovi.com> * Change parameter in Wrapper to interface Error Signed-off-by: Ivan Milošević <iva@blokovi.com> * implement new error interface Signed-off-by: Ivan Milošević <iva@blokovi.com> * Modify tests to use new Error interface Signed-off-by: Ivan Milošević <iva@blokovi.com> * Fix Login Signed-off-by: Ivan Milošević <iva@blokovi.com> * Remove unnecessary errir casting Signed-off-by: Ivan Milošević <iva@blokovi.com> * new error interface implementation Signed-off-by: Ivan Milošević <iva@blokovi.com> * check if Error is empty in registrationEndpoint Signed-off-by: Ivan Milošević <iva@blokovi.com> * Add Empty factory function Use new Empty factory function Use isEmpty method Signed-off-by: Ivan Milošević <iva@blokovi.com> * Lose else in encodeError Signed-off-by: Ivan Milošević <iva@blokovi.com> * Modify tests Signed-off-by: Ivan Milošević <iva@blokovi.com> * Remove *json.UnmarshalTypeError and *json.SyntaxError types from encodeError type switch Signed-off-by: Ivan Milošević <iva@blokovi.com> * Fix nil error value in jwtIdentityProvider Signed-off-by: Ivan Milošević <iva@blokovi.com> * Fix gprc to use new error package Signed-off-by: Ivan Milošević <iva@blokovi.com> * rename receiver in errors package grpc errors Signed-off-by: Ivan Milošević <iva@blokovi.com> * remove debugging code Signed-off-by: Ivan Milošević <iva@blokovi.com> * Resolving conflicts after rebase Signed-off-by: Ivan Milošević <iva@blokovi.com> * Remove comment Signed-off-by: Ivan Milošević <iva@blokovi.com> * Remove Empty from custom error Implement custom error on new methods Signed-off-by: Ivan Milošević <iva@blokovi.com> * WIP tests Signed-off-by: Ivan Milošević <iva@blokovi.com> * remove wrap from Error interface Signed-off-by: Ivan Milošević <iva@blokovi.com> * password-change related tests remove debug code Signed-off-by: Ivan Milošević <iva@blokovi.com> * remove dead code Signed-off-by: Ivan Milošević <iva@blokovi.com> * Move all errors casting to errors package Signed-off-by: Ivan Milošević <iva@blokovi.com> * Fix comment in error package Signed-off-by: Ivan Milošević <iva@blokovi.com> * Change struct pointer to interface in package methods Signed-off-by: Ivan Milošević <iva@blokovi.com> * resolving reviews Signed-off-by: Ivan Milošević <iva@blokovi.com> * fix return in database.go Signed-off-by: Ivan Milošević <iva@blokovi.com> * Fix copyright header Signed-off-by: Ivan Milošević <iva@blokovi.com> * Fix comment in hasher Signed-off-by: Ivan Milošević <iva@blokovi.com>
2019-11-20 14:43:41 +01:00
func (lm *loggingMiddleware) GenerateResetToken(ctx context.Context, email, host string) (err errors.Error) {
MF-532 - Password reset (#873) * add users metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add users metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add users metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add users metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add users metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add users metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add users metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add users metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add metadata to users Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add metadata to users Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add metadata to users Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add metadata to users Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add metadata to users Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add metadata to users Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add metadata to users Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add metadata to users Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add metadata to users Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add metadata to users Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add metadata to users Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add default value for metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add default value for metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add default value for metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add default value for metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add default value for metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add default value for metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * when metadata is not set dont save 'null' string Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * when metadata is not set dont save 'null' string Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * when metadata is not set dont save 'null' string Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * change metadata type, add error handling Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * change metadata type, add error handling Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * change metadata type, add error handling Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * remove extra char Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * remove extra char Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * remove extra char Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * few small fixes Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * few small fixes Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * few small fixes Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix identityRes Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix identityRes Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix identityRes Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add users metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add users metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add users metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * password reset, sketching Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * password reset, sketching Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * password reset, sketching Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * password reset, sketching Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * password reset, sketching Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * password reset, sketching Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * password reset, sketching Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * password reset, sketching Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * password reset, sketching Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * password reset, sketching Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * password reset, sketching Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * password reset, sketching Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * mail Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * mail Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * reset request endpoint Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * reset request endpoint Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * reset request endpoint Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add token Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add token Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add token Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add token methods Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add token methods Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add token methods Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * adding token endpoints Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * adding token endpoints Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * adding token endpoints Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * adding reset passw endpoint Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * adding reset passw endpoint Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * adding reset passw endpoint Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add logic for token verifying Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add logic for token verifying Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add logic for token verifying Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * remove mail from main Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * remove mail from main Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * remove mail from main Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * token and passwd update logic Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * token and passwd update logic Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * token and passwd update logic Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * reorganize mailing code Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add comments for password reset flow Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add comments for password reset flow Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * change struct members to private Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * small changes Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * small changes Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * small changes Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add space Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add space Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add space Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * revert back changes used for testing Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * revert back changes used for testing Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * revert back changes used for testing Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * reorganize endpoints, extract host for link from Referer Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * reorganize endpoints, extract host for link from Referer Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * adding swagger docs for reset passw Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * adding swagger docs for reset passw Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix imports and some typos Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix imports and some typos Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * adding swagger docs for reset passw Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * reorganize endpoints, extract host for link from Referer Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * reorganize endpoints, extract host for link from Referer Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * addint test and update swagger for pass reset Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * addint test and update swagger for pass reset Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * addint test and update swagger for pass reset Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * adding test for endpoint Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * adding test for endpoint Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * adding test for endpoint Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * adding test for endpoint Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * adding endpoint test Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * adding endpoint test Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * adding endpoint test Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * change token generation Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * change token generation Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * change token generation Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * reorganize and change token gen Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * reorganize and change token gen Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * reorganize and change token gen Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * addint token and mail Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * adding token env Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * adding token env Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix error reporting Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix some comments and update readme Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix some comments and update readme Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix some comments and update readme Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * update readme Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix problmes due merge Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix problmes due merge Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix typos Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix typos Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add trusted certificates Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add endpoint for password change of currently authenticated user Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add env variable for conf reset endpoint Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add metadata to users Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add default value for metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add default value for metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * when metadata is not set dont save 'null' string Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * change metadata type, add error handling Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * remove extra char Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * few small fixes Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix identityRes Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add users metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * password reset, sketching Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * password reset, sketching Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * password reset, sketching Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * password reset, sketching Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * reset request endpoint Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * adding token endpoints Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * adding reset passw endpoint Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add logic for token verifying Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * remove mail from main Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * small changes Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add space Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * revert back changes used for testing Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * reorganize endpoints, extract host for link from Referer Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * reorganize endpoints, extract host for link from Referer Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * addint test and update swagger for pass reset Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * adding endpoint test Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix some comments and update readme Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add env variable for conf reset endpoint Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix tests Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * resolving some style comments Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * minor fixes due to bad merge Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix problem with unsigned commits Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix problem with unsigned commits Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix call to users.New Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix call to users.New Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * rename file Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * rename to email.go Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * additional comments Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * additional comments Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * refactor email util Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * refactor email util Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * refactor email util Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * refactor email util Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * remove debug bin Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add driver conf for mail Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * refactor email Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * refactor email Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix failing tests Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add testify Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * small fix Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add token conf Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * small fix Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * small fix Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * configurable email template Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix missing var Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add env for email template file Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add env for email template file Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix tests Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix test Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix test Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * revert to master Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * remove dev container Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * small fixes, typos, namings Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix typo Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * resolving comments Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * resolving comments Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * resolving comments Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * resolving comments Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * resolving comments Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add line Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * return err from email New() Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * change MF_TOKEN_RESET_ENDPOINT Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add and remove env vars Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * separate password logic into two methods Change and Reset Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * update comments Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * remove blank line Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * update docs Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * dont use camel case Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * small fix Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * reorganize email template for passw reset Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * reorganize email template for passw reset Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
2019-10-22 14:53:14 +02:00
defer func(begin time.Time) {
message := fmt.Sprintf("Method generate_reset_token for user %s took %s to complete", email, time.Since(begin))
if err != nil {
lm.logger.Warn(fmt.Sprintf("%s with error: %s.", message, err))
return
}
lm.logger.Info(fmt.Sprintf("%s without errors.", message))
}(time.Now())
return lm.svc.GenerateResetToken(ctx, email, host)
}
MF-538 - Improve logging and API errors (#866) * user service - wraping errors Signed-off-by: Ivan Milošević <iva@blokovi.com> * wrapping more errors unwrap only wrapped errors Signed-off-by: Ivan Milošević <iva@blokovi.com> * Add internal database error Wrap internal database error Signed-off-by: Ivan Milošević <iva@blokovi.com> * Wrap user not found error Signed-off-by: Ivan Milošević <iva@blokovi.com> * Wrapping errors in idp and hasher Signed-off-by: Ivan Milošević <iva@blokovi.com> * Use error.Is for testing errors in Identify test Signed-off-by: Ivan Milošević <iva@blokovi.com> * Get wraper from wrapped errors Signed-off-by: Ivan Milošević <iva@blokovi.com> * Switch order of wrapping errors Remove dead code (comments) Signed-off-by: Ivan Milošević <iva@blokovi.com> * assert true in tests Signed-off-by: Ivan Milošević <iva@blokovi.com> * Change comparing errors in tests (assert.True) Signed-off-by: Ivan Milošević <iva@blokovi.com> * Add errorRes structure to API responses in body in things service Signed-off-by: Ivan Milošević <iva@blokovi.com> * resolve conflicts after rebasing Signed-off-by: Ivan Milošević <iva@blokovi.com> * Create errors package Signed-off-by: Ivan Milošević <iva@blokovi.com> * implement new errors package Signed-off-by: Ivan Milošević <iva@blokovi.com> * Modify tests Signed-off-by: Ivan Milošević <iva@blokovi.com> * return copyright comments Signed-off-by: Ivan Milošević <iva@blokovi.com> * remove changes from .gitignore Signed-off-by: Ivan Milošević <iva@blokovi.com> * Move logging to encode errors Comment exported vars and methods Formatting Signed-off-by: Ivan Milošević <iva@blokovi.com> * Login function returns errors.Error Signed-off-by: Ivan Milošević <iva@blokovi.com> * Modify login tests to meet login returning errors.Error Signed-off-by: Ivan Milošević <iva@blokovi.com> * Error interface Signed-off-by: Ivan Milošević <iva@blokovi.com> * Change parameter in Wrapper to interface Error Signed-off-by: Ivan Milošević <iva@blokovi.com> * implement new error interface Signed-off-by: Ivan Milošević <iva@blokovi.com> * Modify tests to use new Error interface Signed-off-by: Ivan Milošević <iva@blokovi.com> * Fix Login Signed-off-by: Ivan Milošević <iva@blokovi.com> * Remove unnecessary errir casting Signed-off-by: Ivan Milošević <iva@blokovi.com> * new error interface implementation Signed-off-by: Ivan Milošević <iva@blokovi.com> * check if Error is empty in registrationEndpoint Signed-off-by: Ivan Milošević <iva@blokovi.com> * Add Empty factory function Use new Empty factory function Use isEmpty method Signed-off-by: Ivan Milošević <iva@blokovi.com> * Lose else in encodeError Signed-off-by: Ivan Milošević <iva@blokovi.com> * Modify tests Signed-off-by: Ivan Milošević <iva@blokovi.com> * Remove *json.UnmarshalTypeError and *json.SyntaxError types from encodeError type switch Signed-off-by: Ivan Milošević <iva@blokovi.com> * Fix nil error value in jwtIdentityProvider Signed-off-by: Ivan Milošević <iva@blokovi.com> * Fix gprc to use new error package Signed-off-by: Ivan Milošević <iva@blokovi.com> * rename receiver in errors package grpc errors Signed-off-by: Ivan Milošević <iva@blokovi.com> * remove debugging code Signed-off-by: Ivan Milošević <iva@blokovi.com> * Resolving conflicts after rebase Signed-off-by: Ivan Milošević <iva@blokovi.com> * Remove comment Signed-off-by: Ivan Milošević <iva@blokovi.com> * Remove Empty from custom error Implement custom error on new methods Signed-off-by: Ivan Milošević <iva@blokovi.com> * WIP tests Signed-off-by: Ivan Milošević <iva@blokovi.com> * remove wrap from Error interface Signed-off-by: Ivan Milošević <iva@blokovi.com> * password-change related tests remove debug code Signed-off-by: Ivan Milošević <iva@blokovi.com> * remove dead code Signed-off-by: Ivan Milošević <iva@blokovi.com> * Move all errors casting to errors package Signed-off-by: Ivan Milošević <iva@blokovi.com> * Fix comment in error package Signed-off-by: Ivan Milošević <iva@blokovi.com> * Change struct pointer to interface in package methods Signed-off-by: Ivan Milošević <iva@blokovi.com> * resolving reviews Signed-off-by: Ivan Milošević <iva@blokovi.com> * fix return in database.go Signed-off-by: Ivan Milošević <iva@blokovi.com> * Fix copyright header Signed-off-by: Ivan Milošević <iva@blokovi.com> * Fix comment in hasher Signed-off-by: Ivan Milošević <iva@blokovi.com>
2019-11-20 14:43:41 +01:00
func (lm *loggingMiddleware) ChangePassword(ctx context.Context, email, password, oldPassword string) (err errors.Error) {
MF-532 - Password reset (#873) * add users metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add users metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add users metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add users metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add users metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add users metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add users metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add users metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add metadata to users Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add metadata to users Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add metadata to users Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add metadata to users Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add metadata to users Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add metadata to users Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add metadata to users Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add metadata to users Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add metadata to users Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add metadata to users Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add metadata to users Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add default value for metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add default value for metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add default value for metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add default value for metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add default value for metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add default value for metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * when metadata is not set dont save 'null' string Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * when metadata is not set dont save 'null' string Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * when metadata is not set dont save 'null' string Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * change metadata type, add error handling Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * change metadata type, add error handling Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * change metadata type, add error handling Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * remove extra char Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * remove extra char Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * remove extra char Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * few small fixes Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * few small fixes Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * few small fixes Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix identityRes Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix identityRes Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix identityRes Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add users metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add users metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add users metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * password reset, sketching Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * password reset, sketching Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * password reset, sketching Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * password reset, sketching Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * password reset, sketching Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * password reset, sketching Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * password reset, sketching Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * password reset, sketching Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * password reset, sketching Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * password reset, sketching Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * password reset, sketching Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * password reset, sketching Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * mail Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * mail Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * reset request endpoint Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * reset request endpoint Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * reset request endpoint Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add token Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add token Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add token Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add token methods Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add token methods Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add token methods Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * adding token endpoints Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * adding token endpoints Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * adding token endpoints Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * adding reset passw endpoint Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * adding reset passw endpoint Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * adding reset passw endpoint Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add logic for token verifying Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add logic for token verifying Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add logic for token verifying Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * remove mail from main Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * remove mail from main Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * remove mail from main Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * token and passwd update logic Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * token and passwd update logic Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * token and passwd update logic Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * reorganize mailing code Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add comments for password reset flow Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add comments for password reset flow Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * change struct members to private Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * small changes Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * small changes Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * small changes Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add space Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add space Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add space Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * revert back changes used for testing Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * revert back changes used for testing Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * revert back changes used for testing Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * reorganize endpoints, extract host for link from Referer Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * reorganize endpoints, extract host for link from Referer Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * adding swagger docs for reset passw Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * adding swagger docs for reset passw Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix imports and some typos Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix imports and some typos Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * adding swagger docs for reset passw Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * reorganize endpoints, extract host for link from Referer Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * reorganize endpoints, extract host for link from Referer Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * addint test and update swagger for pass reset Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * addint test and update swagger for pass reset Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * addint test and update swagger for pass reset Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * adding test for endpoint Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * adding test for endpoint Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * adding test for endpoint Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * adding test for endpoint Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * adding endpoint test Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * adding endpoint test Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * adding endpoint test Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * change token generation Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * change token generation Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * change token generation Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * reorganize and change token gen Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * reorganize and change token gen Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * reorganize and change token gen Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * addint token and mail Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * adding token env Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * adding token env Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix error reporting Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix some comments and update readme Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix some comments and update readme Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix some comments and update readme Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * update readme Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix problmes due merge Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix problmes due merge Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix typos Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix typos Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add trusted certificates Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add endpoint for password change of currently authenticated user Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add env variable for conf reset endpoint Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add metadata to users Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add default value for metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add default value for metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * when metadata is not set dont save 'null' string Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * change metadata type, add error handling Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * remove extra char Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * few small fixes Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix identityRes Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add users metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * password reset, sketching Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * password reset, sketching Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * password reset, sketching Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * password reset, sketching Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * reset request endpoint Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * adding token endpoints Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * adding reset passw endpoint Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add logic for token verifying Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * remove mail from main Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * small changes Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add space Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * revert back changes used for testing Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * reorganize endpoints, extract host for link from Referer Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * reorganize endpoints, extract host for link from Referer Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * addint test and update swagger for pass reset Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * adding endpoint test Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix some comments and update readme Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add env variable for conf reset endpoint Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix tests Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * resolving some style comments Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * minor fixes due to bad merge Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix problem with unsigned commits Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix problem with unsigned commits Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix call to users.New Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix call to users.New Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * rename file Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * rename to email.go Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * additional comments Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * additional comments Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * refactor email util Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * refactor email util Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * refactor email util Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * refactor email util Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * remove debug bin Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add driver conf for mail Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * refactor email Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * refactor email Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix failing tests Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add testify Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * small fix Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add token conf Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * small fix Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * small fix Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * configurable email template Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix missing var Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add env for email template file Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add env for email template file Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix tests Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix test Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix test Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * revert to master Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * remove dev container Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * small fixes, typos, namings Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix typo Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * resolving comments Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * resolving comments Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * resolving comments Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * resolving comments Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * resolving comments Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add line Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * return err from email New() Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * change MF_TOKEN_RESET_ENDPOINT Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add and remove env vars Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * separate password logic into two methods Change and Reset Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * update comments Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * remove blank line Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * update docs Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * dont use camel case Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * small fix Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * reorganize email template for passw reset Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * reorganize email template for passw reset Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
2019-10-22 14:53:14 +02:00
defer func(begin time.Time) {
message := fmt.Sprintf("Method change_password for user %s took %s to complete", email, time.Since(begin))
if err != nil {
lm.logger.Warn(fmt.Sprintf("%s with error: %s.", message, err))
return
}
lm.logger.Info(fmt.Sprintf("%s without errors.", message))
}(time.Now())
return lm.svc.ChangePassword(ctx, email, password, oldPassword)
}
MF-538 - Improve logging and API errors (#866) * user service - wraping errors Signed-off-by: Ivan Milošević <iva@blokovi.com> * wrapping more errors unwrap only wrapped errors Signed-off-by: Ivan Milošević <iva@blokovi.com> * Add internal database error Wrap internal database error Signed-off-by: Ivan Milošević <iva@blokovi.com> * Wrap user not found error Signed-off-by: Ivan Milošević <iva@blokovi.com> * Wrapping errors in idp and hasher Signed-off-by: Ivan Milošević <iva@blokovi.com> * Use error.Is for testing errors in Identify test Signed-off-by: Ivan Milošević <iva@blokovi.com> * Get wraper from wrapped errors Signed-off-by: Ivan Milošević <iva@blokovi.com> * Switch order of wrapping errors Remove dead code (comments) Signed-off-by: Ivan Milošević <iva@blokovi.com> * assert true in tests Signed-off-by: Ivan Milošević <iva@blokovi.com> * Change comparing errors in tests (assert.True) Signed-off-by: Ivan Milošević <iva@blokovi.com> * Add errorRes structure to API responses in body in things service Signed-off-by: Ivan Milošević <iva@blokovi.com> * resolve conflicts after rebasing Signed-off-by: Ivan Milošević <iva@blokovi.com> * Create errors package Signed-off-by: Ivan Milošević <iva@blokovi.com> * implement new errors package Signed-off-by: Ivan Milošević <iva@blokovi.com> * Modify tests Signed-off-by: Ivan Milošević <iva@blokovi.com> * return copyright comments Signed-off-by: Ivan Milošević <iva@blokovi.com> * remove changes from .gitignore Signed-off-by: Ivan Milošević <iva@blokovi.com> * Move logging to encode errors Comment exported vars and methods Formatting Signed-off-by: Ivan Milošević <iva@blokovi.com> * Login function returns errors.Error Signed-off-by: Ivan Milošević <iva@blokovi.com> * Modify login tests to meet login returning errors.Error Signed-off-by: Ivan Milošević <iva@blokovi.com> * Error interface Signed-off-by: Ivan Milošević <iva@blokovi.com> * Change parameter in Wrapper to interface Error Signed-off-by: Ivan Milošević <iva@blokovi.com> * implement new error interface Signed-off-by: Ivan Milošević <iva@blokovi.com> * Modify tests to use new Error interface Signed-off-by: Ivan Milošević <iva@blokovi.com> * Fix Login Signed-off-by: Ivan Milošević <iva@blokovi.com> * Remove unnecessary errir casting Signed-off-by: Ivan Milošević <iva@blokovi.com> * new error interface implementation Signed-off-by: Ivan Milošević <iva@blokovi.com> * check if Error is empty in registrationEndpoint Signed-off-by: Ivan Milošević <iva@blokovi.com> * Add Empty factory function Use new Empty factory function Use isEmpty method Signed-off-by: Ivan Milošević <iva@blokovi.com> * Lose else in encodeError Signed-off-by: Ivan Milošević <iva@blokovi.com> * Modify tests Signed-off-by: Ivan Milošević <iva@blokovi.com> * Remove *json.UnmarshalTypeError and *json.SyntaxError types from encodeError type switch Signed-off-by: Ivan Milošević <iva@blokovi.com> * Fix nil error value in jwtIdentityProvider Signed-off-by: Ivan Milošević <iva@blokovi.com> * Fix gprc to use new error package Signed-off-by: Ivan Milošević <iva@blokovi.com> * rename receiver in errors package grpc errors Signed-off-by: Ivan Milošević <iva@blokovi.com> * remove debugging code Signed-off-by: Ivan Milošević <iva@blokovi.com> * Resolving conflicts after rebase Signed-off-by: Ivan Milošević <iva@blokovi.com> * Remove comment Signed-off-by: Ivan Milošević <iva@blokovi.com> * Remove Empty from custom error Implement custom error on new methods Signed-off-by: Ivan Milošević <iva@blokovi.com> * WIP tests Signed-off-by: Ivan Milošević <iva@blokovi.com> * remove wrap from Error interface Signed-off-by: Ivan Milošević <iva@blokovi.com> * password-change related tests remove debug code Signed-off-by: Ivan Milošević <iva@blokovi.com> * remove dead code Signed-off-by: Ivan Milošević <iva@blokovi.com> * Move all errors casting to errors package Signed-off-by: Ivan Milošević <iva@blokovi.com> * Fix comment in error package Signed-off-by: Ivan Milošević <iva@blokovi.com> * Change struct pointer to interface in package methods Signed-off-by: Ivan Milošević <iva@blokovi.com> * resolving reviews Signed-off-by: Ivan Milošević <iva@blokovi.com> * fix return in database.go Signed-off-by: Ivan Milošević <iva@blokovi.com> * Fix copyright header Signed-off-by: Ivan Milošević <iva@blokovi.com> * Fix comment in hasher Signed-off-by: Ivan Milošević <iva@blokovi.com>
2019-11-20 14:43:41 +01:00
func (lm *loggingMiddleware) ResetPassword(ctx context.Context, email, password string) (err errors.Error) {
MF-532 - Password reset (#873) * add users metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add users metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add users metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add users metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add users metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add users metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add users metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add users metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add metadata to users Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add metadata to users Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add metadata to users Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add metadata to users Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add metadata to users Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add metadata to users Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add metadata to users Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add metadata to users Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add metadata to users Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add metadata to users Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add metadata to users Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add default value for metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add default value for metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add default value for metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add default value for metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add default value for metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add default value for metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * when metadata is not set dont save 'null' string Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * when metadata is not set dont save 'null' string Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * when metadata is not set dont save 'null' string Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * change metadata type, add error handling Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * change metadata type, add error handling Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * change metadata type, add error handling Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * remove extra char Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * remove extra char Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * remove extra char Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * few small fixes Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * few small fixes Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * few small fixes Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix identityRes Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix identityRes Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix identityRes Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add users metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add users metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add users metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * password reset, sketching Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * password reset, sketching Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * password reset, sketching Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * password reset, sketching Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * password reset, sketching Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * password reset, sketching Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * password reset, sketching Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * password reset, sketching Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * password reset, sketching Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * password reset, sketching Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * password reset, sketching Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * password reset, sketching Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * mail Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * mail Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * reset request endpoint Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * reset request endpoint Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * reset request endpoint Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add token Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add token Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add token Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add token methods Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add token methods Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add token methods Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * adding token endpoints Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * adding token endpoints Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * adding token endpoints Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * adding reset passw endpoint Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * adding reset passw endpoint Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * adding reset passw endpoint Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add logic for token verifying Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add logic for token verifying Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add logic for token verifying Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * remove mail from main Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * remove mail from main Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * remove mail from main Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * token and passwd update logic Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * token and passwd update logic Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * token and passwd update logic Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * reorganize mailing code Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add comments for password reset flow Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add comments for password reset flow Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * change struct members to private Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * small changes Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * small changes Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * small changes Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add space Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add space Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add space Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * revert back changes used for testing Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * revert back changes used for testing Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * revert back changes used for testing Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * reorganize endpoints, extract host for link from Referer Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * reorganize endpoints, extract host for link from Referer Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * adding swagger docs for reset passw Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * adding swagger docs for reset passw Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix imports and some typos Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix imports and some typos Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * adding swagger docs for reset passw Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * reorganize endpoints, extract host for link from Referer Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * reorganize endpoints, extract host for link from Referer Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * addint test and update swagger for pass reset Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * addint test and update swagger for pass reset Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * addint test and update swagger for pass reset Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * adding test for endpoint Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * adding test for endpoint Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * adding test for endpoint Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * adding test for endpoint Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * adding endpoint test Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * adding endpoint test Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * adding endpoint test Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * change token generation Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * change token generation Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * change token generation Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * reorganize and change token gen Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * reorganize and change token gen Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * reorganize and change token gen Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * addint token and mail Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * adding token env Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * adding token env Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix error reporting Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix some comments and update readme Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix some comments and update readme Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix some comments and update readme Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * update readme Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix problmes due merge Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix problmes due merge Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix typos Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix typos Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add trusted certificates Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add endpoint for password change of currently authenticated user Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add env variable for conf reset endpoint Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add metadata to users Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add default value for metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add default value for metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * when metadata is not set dont save 'null' string Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * change metadata type, add error handling Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * remove extra char Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * few small fixes Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix identityRes Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add users metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * password reset, sketching Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * password reset, sketching Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * password reset, sketching Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * password reset, sketching Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * reset request endpoint Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * adding token endpoints Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * adding reset passw endpoint Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add logic for token verifying Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * remove mail from main Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * small changes Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add space Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * revert back changes used for testing Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * reorganize endpoints, extract host for link from Referer Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * reorganize endpoints, extract host for link from Referer Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * addint test and update swagger for pass reset Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * adding endpoint test Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix some comments and update readme Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add env variable for conf reset endpoint Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix tests Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * resolving some style comments Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * minor fixes due to bad merge Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix problem with unsigned commits Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix problem with unsigned commits Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix call to users.New Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix call to users.New Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * rename file Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * rename to email.go Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * additional comments Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * additional comments Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * refactor email util Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * refactor email util Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * refactor email util Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * refactor email util Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * remove debug bin Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add driver conf for mail Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * refactor email Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * refactor email Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix failing tests Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add testify Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * small fix Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add token conf Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * small fix Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * small fix Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * configurable email template Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix missing var Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add env for email template file Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add env for email template file Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix tests Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix test Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix test Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * revert to master Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * remove dev container Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * small fixes, typos, namings Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix typo Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * resolving comments Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * resolving comments Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * resolving comments Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * resolving comments Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * resolving comments Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add line Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * return err from email New() Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * change MF_TOKEN_RESET_ENDPOINT Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add and remove env vars Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * separate password logic into two methods Change and Reset Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * update comments Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * remove blank line Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * update docs Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * dont use camel case Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * small fix Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * reorganize email template for passw reset Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * reorganize email template for passw reset Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
2019-10-22 14:53:14 +02:00
defer func(begin time.Time) {
message := fmt.Sprintf("Method reset_password for user %s took %s to complete", email, time.Since(begin))
if err != nil {
lm.logger.Warn(fmt.Sprintf("%s with error: %s.", message, err))
return
}
lm.logger.Info(fmt.Sprintf("%s without errors.", message))
}(time.Now())
return lm.svc.ResetPassword(ctx, email, password)
}
MF-538 - Improve logging and API errors (#866) * user service - wraping errors Signed-off-by: Ivan Milošević <iva@blokovi.com> * wrapping more errors unwrap only wrapped errors Signed-off-by: Ivan Milošević <iva@blokovi.com> * Add internal database error Wrap internal database error Signed-off-by: Ivan Milošević <iva@blokovi.com> * Wrap user not found error Signed-off-by: Ivan Milošević <iva@blokovi.com> * Wrapping errors in idp and hasher Signed-off-by: Ivan Milošević <iva@blokovi.com> * Use error.Is for testing errors in Identify test Signed-off-by: Ivan Milošević <iva@blokovi.com> * Get wraper from wrapped errors Signed-off-by: Ivan Milošević <iva@blokovi.com> * Switch order of wrapping errors Remove dead code (comments) Signed-off-by: Ivan Milošević <iva@blokovi.com> * assert true in tests Signed-off-by: Ivan Milošević <iva@blokovi.com> * Change comparing errors in tests (assert.True) Signed-off-by: Ivan Milošević <iva@blokovi.com> * Add errorRes structure to API responses in body in things service Signed-off-by: Ivan Milošević <iva@blokovi.com> * resolve conflicts after rebasing Signed-off-by: Ivan Milošević <iva@blokovi.com> * Create errors package Signed-off-by: Ivan Milošević <iva@blokovi.com> * implement new errors package Signed-off-by: Ivan Milošević <iva@blokovi.com> * Modify tests Signed-off-by: Ivan Milošević <iva@blokovi.com> * return copyright comments Signed-off-by: Ivan Milošević <iva@blokovi.com> * remove changes from .gitignore Signed-off-by: Ivan Milošević <iva@blokovi.com> * Move logging to encode errors Comment exported vars and methods Formatting Signed-off-by: Ivan Milošević <iva@blokovi.com> * Login function returns errors.Error Signed-off-by: Ivan Milošević <iva@blokovi.com> * Modify login tests to meet login returning errors.Error Signed-off-by: Ivan Milošević <iva@blokovi.com> * Error interface Signed-off-by: Ivan Milošević <iva@blokovi.com> * Change parameter in Wrapper to interface Error Signed-off-by: Ivan Milošević <iva@blokovi.com> * implement new error interface Signed-off-by: Ivan Milošević <iva@blokovi.com> * Modify tests to use new Error interface Signed-off-by: Ivan Milošević <iva@blokovi.com> * Fix Login Signed-off-by: Ivan Milošević <iva@blokovi.com> * Remove unnecessary errir casting Signed-off-by: Ivan Milošević <iva@blokovi.com> * new error interface implementation Signed-off-by: Ivan Milošević <iva@blokovi.com> * check if Error is empty in registrationEndpoint Signed-off-by: Ivan Milošević <iva@blokovi.com> * Add Empty factory function Use new Empty factory function Use isEmpty method Signed-off-by: Ivan Milošević <iva@blokovi.com> * Lose else in encodeError Signed-off-by: Ivan Milošević <iva@blokovi.com> * Modify tests Signed-off-by: Ivan Milošević <iva@blokovi.com> * Remove *json.UnmarshalTypeError and *json.SyntaxError types from encodeError type switch Signed-off-by: Ivan Milošević <iva@blokovi.com> * Fix nil error value in jwtIdentityProvider Signed-off-by: Ivan Milošević <iva@blokovi.com> * Fix gprc to use new error package Signed-off-by: Ivan Milošević <iva@blokovi.com> * rename receiver in errors package grpc errors Signed-off-by: Ivan Milošević <iva@blokovi.com> * remove debugging code Signed-off-by: Ivan Milošević <iva@blokovi.com> * Resolving conflicts after rebase Signed-off-by: Ivan Milošević <iva@blokovi.com> * Remove comment Signed-off-by: Ivan Milošević <iva@blokovi.com> * Remove Empty from custom error Implement custom error on new methods Signed-off-by: Ivan Milošević <iva@blokovi.com> * WIP tests Signed-off-by: Ivan Milošević <iva@blokovi.com> * remove wrap from Error interface Signed-off-by: Ivan Milošević <iva@blokovi.com> * password-change related tests remove debug code Signed-off-by: Ivan Milošević <iva@blokovi.com> * remove dead code Signed-off-by: Ivan Milošević <iva@blokovi.com> * Move all errors casting to errors package Signed-off-by: Ivan Milošević <iva@blokovi.com> * Fix comment in error package Signed-off-by: Ivan Milošević <iva@blokovi.com> * Change struct pointer to interface in package methods Signed-off-by: Ivan Milošević <iva@blokovi.com> * resolving reviews Signed-off-by: Ivan Milošević <iva@blokovi.com> * fix return in database.go Signed-off-by: Ivan Milošević <iva@blokovi.com> * Fix copyright header Signed-off-by: Ivan Milošević <iva@blokovi.com> * Fix comment in hasher Signed-off-by: Ivan Milošević <iva@blokovi.com>
2019-11-20 14:43:41 +01:00
func (lm *loggingMiddleware) SendPasswordReset(ctx context.Context, host, email, token string) (err errors.Error) {
MF-532 - Password reset (#873) * add users metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add users metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add users metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add users metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add users metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add users metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add users metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add users metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add metadata to users Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add metadata to users Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add metadata to users Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add metadata to users Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add metadata to users Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add metadata to users Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add metadata to users Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add metadata to users Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add metadata to users Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add metadata to users Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add metadata to users Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add default value for metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add default value for metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add default value for metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add default value for metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add default value for metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add default value for metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * when metadata is not set dont save 'null' string Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * when metadata is not set dont save 'null' string Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * when metadata is not set dont save 'null' string Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * change metadata type, add error handling Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * change metadata type, add error handling Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * change metadata type, add error handling Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * remove extra char Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * remove extra char Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * remove extra char Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * few small fixes Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * few small fixes Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * few small fixes Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix identityRes Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix identityRes Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix identityRes Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add users metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add users metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add users metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * password reset, sketching Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * password reset, sketching Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * password reset, sketching Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * password reset, sketching Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * password reset, sketching Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * password reset, sketching Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * password reset, sketching Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * password reset, sketching Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * password reset, sketching Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * password reset, sketching Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * password reset, sketching Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * password reset, sketching Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * mail Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * mail Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * reset request endpoint Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * reset request endpoint Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * reset request endpoint Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add token Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add token Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add token Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add token methods Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add token methods Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add token methods Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * adding token endpoints Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * adding token endpoints Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * adding token endpoints Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * adding reset passw endpoint Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * adding reset passw endpoint Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * adding reset passw endpoint Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add logic for token verifying Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add logic for token verifying Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add logic for token verifying Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * remove mail from main Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * remove mail from main Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * remove mail from main Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * token and passwd update logic Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * token and passwd update logic Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * token and passwd update logic Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * reorganize mailing code Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add comments for password reset flow Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add comments for password reset flow Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * change struct members to private Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * small changes Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * small changes Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * small changes Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add space Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add space Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add space Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * revert back changes used for testing Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * revert back changes used for testing Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * revert back changes used for testing Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * reorganize endpoints, extract host for link from Referer Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * reorganize endpoints, extract host for link from Referer Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * adding swagger docs for reset passw Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * adding swagger docs for reset passw Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix imports and some typos Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix imports and some typos Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * adding swagger docs for reset passw Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * reorganize endpoints, extract host for link from Referer Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * reorganize endpoints, extract host for link from Referer Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * addint test and update swagger for pass reset Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * addint test and update swagger for pass reset Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * addint test and update swagger for pass reset Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * adding test for endpoint Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * adding test for endpoint Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * adding test for endpoint Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * adding test for endpoint Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * adding endpoint test Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * adding endpoint test Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * adding endpoint test Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * change token generation Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * change token generation Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * change token generation Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * reorganize and change token gen Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * reorganize and change token gen Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * reorganize and change token gen Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * addint token and mail Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * adding token env Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * adding token env Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix error reporting Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix some comments and update readme Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix some comments and update readme Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix some comments and update readme Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * update readme Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix problmes due merge Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix problmes due merge Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix typos Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix typos Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add trusted certificates Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add endpoint for password change of currently authenticated user Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add env variable for conf reset endpoint Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add metadata to users Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add default value for metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add default value for metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * when metadata is not set dont save 'null' string Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * change metadata type, add error handling Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * remove extra char Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * few small fixes Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix identityRes Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add users metadata Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * password reset, sketching Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * password reset, sketching Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * password reset, sketching Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * password reset, sketching Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * reset request endpoint Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * adding token endpoints Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * adding reset passw endpoint Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add logic for token verifying Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * remove mail from main Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * small changes Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add space Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * revert back changes used for testing Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * reorganize endpoints, extract host for link from Referer Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * reorganize endpoints, extract host for link from Referer Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * addint test and update swagger for pass reset Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * adding endpoint test Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix some comments and update readme Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add env variable for conf reset endpoint Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix tests Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * resolving some style comments Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * minor fixes due to bad merge Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix problem with unsigned commits Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix problem with unsigned commits Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix call to users.New Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix call to users.New Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * rename file Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * rename to email.go Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * additional comments Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * additional comments Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * refactor email util Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * refactor email util Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * refactor email util Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * refactor email util Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * remove debug bin Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add driver conf for mail Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * refactor email Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * refactor email Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix failing tests Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add testify Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * small fix Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add token conf Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * small fix Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * small fix Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * configurable email template Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix missing var Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add env for email template file Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add env for email template file Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix tests Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix test Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix test Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * revert to master Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * remove dev container Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * small fixes, typos, namings Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * fix typo Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * resolving comments Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * resolving comments Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * resolving comments Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * resolving comments Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * resolving comments Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add line Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * return err from email New() Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * change MF_TOKEN_RESET_ENDPOINT Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * add and remove env vars Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * separate password logic into two methods Change and Reset Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * update comments Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * remove blank line Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * update docs Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * dont use camel case Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * small fix Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * reorganize email template for passw reset Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com> * reorganize email template for passw reset Signed-off-by: Mirko Teodorovic <mirko.teodorovic@gmail.com>
2019-10-22 14:53:14 +02:00
defer func(begin time.Time) {
message := fmt.Sprintf("Method send_password_reset for user %s took %s to complete", email, time.Since(begin))
if err != nil {
lm.logger.Warn(fmt.Sprintf("%s with error: %s.", message, err))
return
}
lm.logger.Info(fmt.Sprintf("%s without errors.", message))
}(time.Now())
return lm.svc.SendPasswordReset(ctx, host, email, token)
}