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

* Init commit - implement errors package on things service Signed-off-by: Ivan Milošević <iva@blokovi.com> * things service errors issue Signed-off-by: Ivan Milošević <iva@blokovi.com> * Decode errors Add authn service to run script Signed-off-by: Ivan Milošević <iva@blokovi.com> * Modify tests Signed-off-by: Ivan Milošević <iva@blokovi.com> * service_test Signed-off-by: Ivan Milošević <iva@blokovi.com> * debug lines Signed-off-by: Ivan Milošević <iva@blokovi.com> * Regulate tests Signed-off-by: Ivan Milošević <iva@blokovi.com> * Improve errors in Redis Signed-off-by: Ivan Milošević <iva@blokovi.com> * Remove dead code Inline if conditions Rename err var Signed-off-by: Ivan Milošević <iva@blokovi.com> * Transform errors messages to lowercase Signed-off-by: Ivan Milošević <iva@blokovi.com> * improve errors package Signed-off-by: Ivan Milošević <iva@blokovi.com> * modify wrap method inline wrapping errors in redis Signed-off-by: Ivan Milošević <iva@blokovi.com> * Add copyright to errors package Signed-off-by: Ivan Milošević <iva@blokovi.com> * wrapping nil error returns wrapper (instead of nil) Signed-off-by: Ivan Milošević <iva@blokovi.com> * move response messages in test to vars Signed-off-by: Ivan Milošević <iva@blokovi.com> * golangcibot review fix Signed-off-by: Ivan Milošević <iva@blokovi.com> * golangbot fix review in transport Signed-off-by: Ivan Milošević <iva@blokovi.com>
33 lines
748 B
Go
33 lines
748 B
Go
// Copyright (c) Mainflux
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
package emailer
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/mainflux/mainflux/internal/email"
|
|
"github.com/mainflux/mainflux/users"
|
|
)
|
|
|
|
var _ users.Emailer = (*emailer)(nil)
|
|
|
|
type emailer struct {
|
|
resetURL string
|
|
agent *email.Agent
|
|
}
|
|
|
|
// New creates new emailer utility
|
|
func New(url string, c *email.Config) (users.Emailer, error) {
|
|
e, err := email.New(c)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &emailer{resetURL: url, agent: e}, nil
|
|
}
|
|
|
|
func (e *emailer) SendPasswordReset(To []string, host string, token string) error {
|
|
url := fmt.Sprintf("%s%s?token=%s", host, e.resetURL, token)
|
|
content := fmt.Sprintf("%s", url)
|
|
return e.agent.Send(To, "", "Password reset", "", content, "")
|
|
}
|