wip: create/update/...

This commit is contained in:
Christoph Haas
2020-11-07 20:32:25 +01:00
parent cc06019738
commit 3e92cc8551
15 changed files with 21539 additions and 1 deletions

View File

@@ -8,6 +8,8 @@ import (
"strconv"
"time"
"github.com/h44z/wg-portal/internal/ldap"
"github.com/h44z/wg-portal/internal/common"
"golang.zx2c4.com/wireguard/wgctrl/wgtypes"
@@ -275,6 +277,26 @@ func (s *Server) PostAdminCreatePeer(c *gin.Context) {
c.Redirect(http.StatusSeeOther, "/admin")
}
func (s *Server) GetAdminCreateLdapPeers(c *gin.Context) {
device := s.users.GetDevice()
c.HTML(http.StatusOK, "admin_create_clients.html", struct {
Route string
Alerts AlertData
Session SessionData
Static StaticData
Users []*ldap.UserCacheHolderEntry
Device Device
}{
Route: c.Request.URL.Path,
Alerts: s.getAlertData(c),
Session: s.getSessionData(c),
Static: s.getStaticData(),
Users: s.ldapUsers.GetSortedUsers("sn", "asc"),
Device: device,
})
}
func (s *Server) GetUserQRCode(c *gin.Context) {
user := s.users.GetUserByKey(c.Query("pkey"))
png, err := user.GetQRCode()

View File

@@ -26,6 +26,7 @@ func SetupRoutes(s *Server) {
admin.POST("/peer/edit", s.PostAdminEditPeer)
admin.GET("/peer/create", s.GetAdminCreatePeer)
admin.POST("/peer/create", s.PostAdminCreatePeer)
admin.GET("/peer/createldap", s.GetAdminCreateLdapPeers)
// User routes
user := s.server.Group("/user")