start huge dashboard rework; improve dark theme
This commit is contained in:
parent
14feb47640
commit
f324c249f6
21 changed files with 365 additions and 235 deletions
|
|
@ -45,7 +45,7 @@ func accountIndexHandler(app *model.AppState) http.Handler {
|
|||
}
|
||||
|
||||
accountResponse struct {
|
||||
Session *model.Session
|
||||
adminPageData
|
||||
TOTPs []TOTP
|
||||
}
|
||||
)
|
||||
|
|
@ -66,7 +66,7 @@ func accountIndexHandler(app *model.AppState) http.Handler {
|
|||
session.Error = sessionError
|
||||
|
||||
err = templates.AccountTemplate.Execute(w, accountResponse{
|
||||
Session: session,
|
||||
adminPageData: adminPageData{ Path: r.URL.Path, Session: session },
|
||||
TOTPs: totps,
|
||||
})
|
||||
if err != nil {
|
||||
|
|
@ -170,7 +170,7 @@ func deleteAccountHandler(app *model.AppState) http.Handler {
|
|||
}
|
||||
|
||||
type totpConfirmData struct {
|
||||
Session *model.Session
|
||||
adminPageData
|
||||
TOTP *model.TOTP
|
||||
NameEscaped string
|
||||
QRBase64Image string
|
||||
|
|
@ -179,13 +179,9 @@ type totpConfirmData struct {
|
|||
func totpSetupHandler(app *model.AppState) http.Handler {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
if r.Method == http.MethodGet {
|
||||
type totpSetupData struct {
|
||||
Session *model.Session
|
||||
}
|
||||
|
||||
session := r.Context().Value("session").(*model.Session)
|
||||
|
||||
err := templates.TOTPSetupTemplate.Execute(w, totpSetupData{ Session: session })
|
||||
err := templates.TOTPSetupTemplate.Execute(w, adminPageData{ Path: "/account", Session: session })
|
||||
if err != nil {
|
||||
fmt.Printf("WARN: Failed to render TOTP setup page: %s\n", err)
|
||||
http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
|
||||
|
|
@ -222,7 +218,9 @@ func totpSetupHandler(app *model.AppState) http.Handler {
|
|||
if err != nil {
|
||||
fmt.Printf("WARN: Failed to create TOTP method: %s\n", err)
|
||||
controller.SetSessionError(app.DB, session, "Something went wrong. Please try again.")
|
||||
err := templates.TOTPSetupTemplate.Execute(w, totpConfirmData{ Session: session })
|
||||
err := templates.TOTPSetupTemplate.Execute(w, totpConfirmData{
|
||||
adminPageData: adminPageData{ Path: r.URL.Path, Session: session },
|
||||
})
|
||||
if err != nil {
|
||||
fmt.Printf("WARN: Failed to render TOTP setup page: %s\n", err)
|
||||
http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
|
||||
|
|
@ -237,7 +235,7 @@ func totpSetupHandler(app *model.AppState) http.Handler {
|
|||
}
|
||||
|
||||
err = templates.TOTPConfirmTemplate.Execute(w, totpConfirmData{
|
||||
Session: session,
|
||||
adminPageData: adminPageData{ Path: r.URL.Path, Session: session },
|
||||
TOTP: &totp,
|
||||
NameEscaped: url.PathEscape(totp.Name),
|
||||
QRBase64Image: qrBase64Image,
|
||||
|
|
@ -298,7 +296,7 @@ func totpConfirmHandler(app *model.AppState) http.Handler {
|
|||
if code != confirmCodeOffset {
|
||||
session.Error = sql.NullString{ Valid: true, String: "Incorrect TOTP code. Please try again." }
|
||||
err = templates.TOTPConfirmTemplate.Execute(w, totpConfirmData{
|
||||
Session: session,
|
||||
adminPageData: adminPageData{ Path: r.URL.Path, Session: session },
|
||||
TOTP: totp,
|
||||
NameEscaped: url.PathEscape(totp.Name),
|
||||
QRBase64Image: qrBase64Image,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue