Front-End Stuff

This commit is contained in:
Chris Mann 2023-07-20 17:52:16 +02:00
parent 0caf79a96a
commit c55d1c7bbe
3 changed files with 10 additions and 1 deletions

View file

@ -104,6 +104,7 @@ type NewAccountData struct {
GivenName string
Surname string
Mail string
SuggestPW string
ErrorUsernameTaken bool
ErrorInvalidUsername bool
@ -147,6 +148,8 @@ func handleNewAccount(w http.ResponseWriter, r *http.Request, l *ldap.Conn, invi
// tryCreateAccount(l, data, password1, password2, invitedBy)
} else {
data.SuggestPW = suggestPassword()
}
templateInviteNewAccount.Execute(w, data)

View file

@ -62,6 +62,7 @@
<label for="surname">Nom de famille :</label>
<input type="text" id="surname" name="surname" class="form-control" value="{{ .Surname }}" />
</div>
<a href="#" onclick="javascript:document.getElementById('password').value='{{ .SuggestPW }}';document.getElementById('password2').value='{{ .SuggestPW }}';">Utiliser ce mot de passe :</a> <tt>{{ .SuggestPW }}</tt>
<div class="form-group">
<label for="password">Mot de passe :</label>
<input type="password" id="password" name="password" class="form-control" />

View file

@ -8,7 +8,7 @@ import (
// "bytes"
// "crypto/rand"
// "encoding/binary"
// "encoding/hex"
"encoding/hex"
// "fmt"
// "html/template"
// "log"
@ -43,6 +43,11 @@ func openLdap(config ConfigFile) *ldap.Conn {
}
}
func suggestPassword() string {
random := make([]byte, 32)
return hex.EncodeToString(random[0:4])
}
func addNewUser(newUser NewUser, config *ConfigFile, login *LoginStatus) bool {
log.Printf(fmt.Sprint("Adding New User"))
// l := openLdap(config)