mirror of
https://github.com/h44z/wg-portal
synced 2025-02-26 05:49:14 +00:00
Merge branch 'h44z:master' into master
This commit is contained in:
commit
383fc8cb58
@ -420,10 +420,9 @@ func (s *Server) PostUserCreatePeer(c *gin.Context) {
|
|||||||
formPeer = currentSession.FormData.(wireguard.Peer)
|
formPeer = currentSession.FormData.(wireguard.Peer)
|
||||||
}
|
}
|
||||||
|
|
||||||
formPeer.Email = currentSession.Email;
|
formPeer.Email = currentSession.Email
|
||||||
formPeer.Identifier = currentSession.Email;
|
formPeer.Identifier = currentSession.Email
|
||||||
formPeer.DeviceType = wireguard.DeviceTypeServer;
|
formPeer.DeviceType = wireguard.DeviceTypeServer
|
||||||
formPeer.PrivateKey = "";
|
|
||||||
|
|
||||||
if err := c.ShouldBind(&formPeer); err != nil {
|
if err := c.ShouldBind(&formPeer); err != nil {
|
||||||
_ = s.updateFormInSession(c, formPeer)
|
_ = s.updateFormInSession(c, formPeer)
|
||||||
@ -432,6 +431,11 @@ func (s *Server) PostUserCreatePeer(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if public key was manually set, remove the incorrect private key
|
||||||
|
if formPeer.PublicKey != currentSession.FormData.(wireguard.Peer).PublicKey {
|
||||||
|
formPeer.PrivateKey = ""
|
||||||
|
}
|
||||||
|
|
||||||
disabled := c.PostForm("isdisabled") != ""
|
disabled := c.PostForm("isdisabled") != ""
|
||||||
now := time.Now()
|
now := time.Now()
|
||||||
if disabled {
|
if disabled {
|
||||||
@ -452,7 +456,6 @@ func (s *Server) PostUserCreatePeer(c *gin.Context) {
|
|||||||
func (s *Server) GetUserEditPeer(c *gin.Context) {
|
func (s *Server) GetUserEditPeer(c *gin.Context) {
|
||||||
peer := s.peers.GetPeerByKey(c.Query("pkey"))
|
peer := s.peers.GetPeerByKey(c.Query("pkey"))
|
||||||
|
|
||||||
|
|
||||||
currentSession, err := s.setFormInSession(c, peer)
|
currentSession, err := s.setFormInSession(c, peer)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
s.GetHandleError(c, http.StatusInternalServerError, "Session error", err.Error())
|
s.GetHandleError(c, http.StatusInternalServerError, "Session error", err.Error())
|
||||||
@ -461,7 +464,7 @@ func (s *Server) GetUserEditPeer(c *gin.Context) {
|
|||||||
|
|
||||||
if peer.Email != currentSession.Email {
|
if peer.Email != currentSession.Email {
|
||||||
s.GetHandleError(c, http.StatusUnauthorized, "No permissions", "You don't have permissions to view this resource!")
|
s.GetHandleError(c, http.StatusUnauthorized, "No permissions", "You don't have permissions to view this resource!")
|
||||||
return;
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
c.HTML(http.StatusOK, "user_edit_client.html", gin.H{
|
c.HTML(http.StatusOK, "user_edit_client.html", gin.H{
|
||||||
@ -486,7 +489,7 @@ func (s *Server) PostUserEditPeer(c *gin.Context) {
|
|||||||
|
|
||||||
if currentPeer.Email != currentSession.Email {
|
if currentPeer.Email != currentSession.Email {
|
||||||
s.GetHandleError(c, http.StatusUnauthorized, "No permissions", "You don't have permissions to view this resource!")
|
s.GetHandleError(c, http.StatusUnauthorized, "No permissions", "You don't have permissions to view this resource!")
|
||||||
return;
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
disabled := c.PostForm("isdisabled") != ""
|
disabled := c.PostForm("isdisabled") != ""
|
||||||
|
Loading…
Reference in New Issue
Block a user