mirror of
https://github.com/Threnklyn/wg-ui.git
synced 2026-05-28 01:28:28 +02:00
Fix bug responding when user has no clients
This commit is contained in:
@@ -366,7 +366,13 @@ func (s *Server) WhoAmI(w http.ResponseWriter, r *http.Request, ps httprouter.Pa
|
||||
func (s *Server) GetClients(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
|
||||
user := r.Context().Value("user").(string)
|
||||
log.Debug(user)
|
||||
err := json.NewEncoder(w).Encode(s.Config.Users[user].Clients)
|
||||
clients := map[string]*ClientConfig{}
|
||||
userConfig := s.Config.Users[user]
|
||||
if userConfig != nil {
|
||||
clients = userConfig.Clients
|
||||
}
|
||||
|
||||
err := json.NewEncoder(w).Encode(clients)
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
|
||||
Reference in New Issue
Block a user