werk
This commit is contained in:
parent
8851cac17b
commit
cd78975f1a
9
go.mod
9
go.mod
|
@ -3,10 +3,13 @@ module git.teamworkapps.com/shortcut/docker-mailserver-passwords
|
|||
go 1.22.0
|
||||
|
||||
require (
|
||||
git.teamworkapps.com/shortcut/forms v0.0.0-20240202203738-c42dc9446449 // indirect
|
||||
git.teamworkapps.com/shortcut/forms v0.0.0-20240202203738-c42dc9446449
|
||||
github.com/gorilla/mux v1.8.1
|
||||
github.com/knadh/go-pop3 v0.3.0
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/emersion/go-message v0.18.0 // indirect
|
||||
github.com/emersion/go-textwrapper v0.0.0-20200911093747-65d896831594 // indirect
|
||||
github.com/gorilla/mux v1.8.1 // indirect
|
||||
github.com/knadh/go-pop3 v0.3.0 // indirect
|
||||
github.com/shopspring/decimal v1.3.1 // indirect
|
||||
)
|
||||
|
|
2
go.sum
2
go.sum
|
@ -11,6 +11,8 @@ github.com/knadh/go-pop3 v0.3.0 h1:h6wh28lyT/vUBMSiSwDDUXZjHH6zL8CM8WYCPbETM4Y=
|
|||
github.com/knadh/go-pop3 v0.3.0/go.mod h1:a5kUJzrBB6kec+tNJl+3Z64ROgByKBdcyub+mhZMAfI=
|
||||
github.com/shopspring/decimal v1.3.1 h1:2Usl1nmF/WZucqkFZhnfFYxxxu8LG21F6nPQBE5gKV8=
|
||||
github.com/shopspring/decimal v1.3.1/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=
|
||||
github.com/vincent-petithory/dataurl v1.0.0 h1:cXw+kPto8NLuJtlMsI152irrVw9fRDX8AbShPRpg2CI=
|
||||
github.com/vincent-petithory/dataurl v1.0.0/go.mod h1:FHafX5vmDzyP+1CQATJn7WFKc9CvnvxyvZy6I1MrG/U=
|
||||
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||
|
|
20
main.go
20
main.go
|
@ -4,6 +4,7 @@ import (
|
|||
"log"
|
||||
"net/http"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path"
|
||||
"text/template"
|
||||
"time"
|
||||
|
@ -28,8 +29,6 @@ func mwLog(next http.Handler) http.Handler {
|
|||
})
|
||||
}
|
||||
|
||||
|
||||
|
||||
func main() {
|
||||
|
||||
forms.GlobalStyles.ContainerClasses = "w-full bg-gray-100 justify-center py-6 rounded-lg shadow flex"
|
||||
|
@ -42,6 +41,7 @@ func main() {
|
|||
e.Label = "Email Address"
|
||||
e.Type = "text"
|
||||
e.Validator = "email"
|
||||
e.FailMessage = "Must be a valid email address"
|
||||
e.Name = "email"
|
||||
f.Add(e)
|
||||
|
||||
|
@ -49,12 +49,14 @@ func main() {
|
|||
e.Label = "Old Password"
|
||||
e.Type = "password"
|
||||
e.Validator = ""
|
||||
e.FailMessage = "Passsword Incorrect"
|
||||
e.Name = "oldpassword"
|
||||
f.Add(e)
|
||||
|
||||
e = forms.NewElement()
|
||||
e.Label = "New Password"
|
||||
e.Type = "password"
|
||||
e.FailMessage = "Password must be at least 8 characters long and contain at least one uppercase letter, one lowercase letter and one digit"
|
||||
e.Validator = "minlength=8;haslowercase;hasuppercase;hasdigit"
|
||||
e.Name = "newpassword"
|
||||
f.Add(e)
|
||||
|
@ -62,6 +64,7 @@ func main() {
|
|||
e = forms.NewElement()
|
||||
e.Label = "Confirm Password"
|
||||
e.Type = "password"
|
||||
e.FailMessage = "Passwords do not match"
|
||||
e.Validator = "mustmatch=newpassword"
|
||||
e.Name = "confirmpassword"
|
||||
f.Add(e)
|
||||
|
@ -107,7 +110,7 @@ func main() {
|
|||
c, err := p.NewConn()
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
d.Body="Internal error"
|
||||
d.Body = "Internal error"
|
||||
tmpl.Execute(w, d)
|
||||
return
|
||||
}
|
||||
|
@ -120,7 +123,16 @@ func main() {
|
|||
tmpl.Execute(w, d)
|
||||
return
|
||||
}
|
||||
w.Write([]byte("I want to change the password"))
|
||||
cm := exec.Command("/root/docker/mail/setup.sh", "email", "update", f.GetValue("email"), f.GetValue("newpassword"))
|
||||
err = cm.Run()
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
d.Body = "Internal error"
|
||||
tmpl.Execute(w, d)
|
||||
return
|
||||
}
|
||||
d.Body = "Password changed"
|
||||
tmpl.Execute(w, d)
|
||||
})
|
||||
d.Time = time.Now().Unix()
|
||||
d.Body = f.Render(true)
|
||||
|
|
Loading…
Reference in New Issue