netmaker/logic/users.go

23 lines
450 B
Go
Raw Normal View History

2021-10-27 00:27:29 +08:00
package logic
import (
"encoding/json"
"github.com/gravitl/netmaker/database"
"github.com/gravitl/netmaker/models"
)
// GetUser - gets a user
func GetUser(username string) (models.User, error) {
var user models.User
record, err := database.FetchRecord(database.USERS_TABLE_NAME, username)
if err != nil {
return user, err
}
if err = json.Unmarshal([]byte(record), &user); err != nil {
return models.User{}, err
}
return user, err
}