Can delete own aliases
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
e6a4271a75
commit
daab7bf699
3 changed files with 62 additions and 9 deletions
8
login.go
8
login.go
|
|
@ -50,17 +50,21 @@ func tryLogin(w http.ResponseWriter, r *http.Request) {
|
|||
log.Println(err)
|
||||
displayTmplError(w, http.StatusInternalServerError, "login.html", map[string]interface{}{"error": err.Error()})
|
||||
} else {
|
||||
apiToken := AddyAPIToken(r.PostFormValue("login"))
|
||||
|
||||
cnt := "<ul>"
|
||||
for _, e := range entries {
|
||||
for _, v := range e.Values {
|
||||
for i, v := range e.Values {
|
||||
if e.Name == "userPassword" {
|
||||
cnt += "<li><strong>" + e.Name + ":</strong> <em>[...]</em></li>"
|
||||
} else if e.Name == "mailAlias" && len(strings.SplitN(v, "@", 2)[0]) == 10 {
|
||||
cnt += "<li id='" + fmt.Sprintf("mailAlias-%d", i) + "'><strong>" + e.Name + ":</strong> " + v + `<button type="button" class="mx-1 btn btn-sm btn-danger" onclick="fetch('/api/v1/aliases/` + v + `', {'method': 'delete', 'headers': {'Authorization': 'Bearer ` + apiToken + `'}}).then((res) => { if (res.ok) document.getElementById('` + fmt.Sprintf("mailAlias-%d", i) + `').remove(); });">Supprimer</a></li>`
|
||||
} else {
|
||||
cnt += "<li><strong>" + e.Name + ":</strong> " + v + "</li>"
|
||||
}
|
||||
}
|
||||
}
|
||||
displayTmpl(w, "message.html", map[string]interface{}{"details": template.HTML(`Login ok<br><br>Here are the information we have about you:` + cnt + "</ul><p>To use our Addy.io compatible API, use the following token: <code>" + AddyAPIToken(r.PostFormValue("login")) + "</code></p>")})
|
||||
displayTmpl(w, "message.html", map[string]interface{}{"details": template.HTML(`Login ok<br><br>Here are the information we have about you:` + cnt + "</ul><p>To use our Addy.io compatible API, use the following token: <code>" + apiToken + "</code></p>")})
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue