This commit is contained in:
Chris Mann 2023-07-23 12:00:02 +02:00
parent d749c615b3
commit 4bd314864c
5 changed files with 46 additions and 3 deletions

15
gpas.go
View file

@ -19,6 +19,12 @@ import (
// "strings"
)
// type InvitationAccount struct {
// UID string
// Password string
// BaseDN string
// }
// var EMAIL_REGEXP := regexp.MustCompile("^[a-zA-Z0-9.!#$%&'*+\\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$")
func passwordLost(user User, config *ConfigFile, ldapConn *ldap.Conn) error {
@ -76,3 +82,12 @@ func passwordLost(user User, config *ConfigFile, ldapConn *ldap.Conn) error {
log.Printf("Mail sent.")
return nil
}
func passwordFound(user User, config *ConfigFile, ldapConn *ldap.Conn) (bool, error) {
l := openLdap(*config)
err := l.Bind(user.DN, user.Password)
if err != nil {
return false, err
}
return true, nil
}

View file

@ -38,7 +38,21 @@ func checkInviterLogin(w http.ResponseWriter, r *http.Request) *LoginStatus {
// New account creation directly from interface
type LostPasswordData struct {
type PasswordFoundData struct {
ErrorMessage string
Success bool
Username string
Mail string
OtherMailbox string
}
func handleFoundPassword(w http.ResponseWriter, r *http.Request) {
templateFoundPasswordPage := getTemplate("passwd.html")
data := PasswordFoundData{}
templateFoundPasswordPage.Execute(w, data)
}
type PasswordLostData struct {
ErrorMessage string
Success bool
Username string
@ -47,8 +61,8 @@ type LostPasswordData struct {
}
func handleLostPassword(w http.ResponseWriter, r *http.Request) {
templateLostPasswordPage := getTemplate("lost_password.html")
data := LostPasswordData{}
templateLostPasswordPage := getTemplate("password_lost.html")
data := PasswordLostData{}
l, err := ldapOpen(w)
if err != nil {
log.Printf(fmt.Sprintf("handleLostPassword : %v %v", err, l))

View file

@ -75,6 +75,7 @@ func main() {
r.HandleFunc("/invite/new_account", handleInviteNewAccount)
r.HandleFunc("/invite/send_code", handleInviteSendCode)
r.HandleFunc("/gpassword/{code}", handleFoundPassword)
r.HandleFunc("/gpas", handleLostPassword)
r.HandleFunc("/invitation/{code}", handleInvitationCode)

View file

@ -0,0 +1,13 @@
From: {{.From}}
To: {{.To}}
Subject: Code d'invitation GVoisin.com
Content-type: text/plain; charset=utf-8
Une refonte de mot de passe avait été demandé sur GVoisin.com
Pour créer votre compte, rendez-vous à l'addresse suivante:
...
À bientôt sur GVoisin.com !