wip: create/update/delete...

This commit is contained in:
Christoph Haas 2020-11-09 11:17:19 +01:00
parent 5a933f20c9
commit 7d7af70346
2 changed files with 11 additions and 0 deletions

View File

@ -336,6 +336,16 @@ func (s *Server) PostAdminCreateLdapPeers(c *gin.Context) {
c.Redirect(http.StatusSeeOther, "/admin/peer/createldap")
}
func (s *Server) GetAdminDeletePeer(c *gin.Context) {
currentUser := s.users.GetUserByKey(c.Query("pkey"))
if err := s.DeleteUser(currentUser); err != nil {
s.HandleError(c, http.StatusInternalServerError, "Deletion error", err.Error())
return
}
s.setAlert(c, "user deleted successfully", "success")
c.Redirect(http.StatusSeeOther, "/admin")
}
func (s *Server) GetUserQRCode(c *gin.Context) {
user := s.users.GetUserByKey(c.Query("pkey"))
png, err := user.GetQRCode()

View File

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