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

* MF-739 - Add ID to the User entity Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Resolve remarks Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Move idp to project root Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Use RetrieveByEmail func and UUIDProvider Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Rm idp.go Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Fix comment Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Rename UserInfo into ViewUser Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com> * Fix ViewUser naming Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
88 lines
1.5 KiB
Go
88 lines
1.5 KiB
Go
// Copyright (c) Mainflux
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
package api
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"github.com/mainflux/mainflux"
|
|
)
|
|
|
|
var (
|
|
_ mainflux.Response = (*tokenRes)(nil)
|
|
_ mainflux.Response = (*viewUserRes)(nil)
|
|
_ mainflux.Response = (*passwChangeRes)(nil)
|
|
)
|
|
|
|
// MailSent message response when link is sent
|
|
const MailSent = "Email with reset link is sent"
|
|
|
|
type tokenRes struct {
|
|
Token string `json:"token,omitempty"`
|
|
}
|
|
|
|
func (res tokenRes) Code() int {
|
|
return http.StatusCreated
|
|
}
|
|
|
|
func (res tokenRes) Headers() map[string]string {
|
|
return map[string]string{}
|
|
}
|
|
|
|
func (res tokenRes) Empty() bool {
|
|
return res.Token == ""
|
|
}
|
|
|
|
type updateUserRes struct{}
|
|
|
|
func (res updateUserRes) Code() int {
|
|
return http.StatusOK
|
|
}
|
|
|
|
func (res updateUserRes) Headers() map[string]string {
|
|
return map[string]string{}
|
|
}
|
|
|
|
func (res updateUserRes) Empty() bool {
|
|
return true
|
|
}
|
|
|
|
type viewUserRes struct {
|
|
ID string `json:"id"`
|
|
Email string `json:"email"`
|
|
Metadata map[string]interface{} `json:"metadata,omitempty"`
|
|
}
|
|
|
|
func (res viewUserRes) Code() int {
|
|
return http.StatusOK
|
|
}
|
|
|
|
func (res viewUserRes) Headers() map[string]string {
|
|
return map[string]string{}
|
|
}
|
|
|
|
func (res viewUserRes) Empty() bool {
|
|
return false
|
|
}
|
|
|
|
type errorRes struct {
|
|
Err string `json:"error"`
|
|
}
|
|
|
|
type passwChangeRes struct {
|
|
Msg string `json:"msg"`
|
|
}
|
|
|
|
func (res passwChangeRes) Code() int {
|
|
return http.StatusCreated
|
|
}
|
|
|
|
func (res passwChangeRes) Headers() map[string]string {
|
|
return map[string]string{}
|
|
}
|
|
|
|
func (res passwChangeRes) Empty() bool {
|
|
return false
|
|
}
|