mirror of
https://github.com/grafana/grafana.git
synced 2024-12-29 10:21:41 -06:00
121631daae
* fix: email and username trimming and invitation validation * Trim leading and trailing whitespaces from email and username on signup * Check whether the provided email address is the same as where the invitation sent * Align tests Co-authored-by: Mihaly Gyongyosi <mgyongyosi@users.noreply.github.com>
26 lines
409 B
Go
26 lines
409 B
Go
package api
|
|
|
|
import (
|
|
"encoding/json"
|
|
"net/mail"
|
|
)
|
|
|
|
func jsonMap(data []byte) (map[string]string, error) {
|
|
jsonMap := make(map[string]string)
|
|
err := json.Unmarshal(data, &jsonMap)
|
|
return jsonMap, err
|
|
}
|
|
|
|
func ValidateAndNormalizeEmail(email string) (string, error) {
|
|
if email == "" {
|
|
return "", nil
|
|
}
|
|
|
|
e, err := mail.ParseAddress(email)
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
|
|
return e.Address, nil
|
|
}
|