TOTP fully functioning, account settings done!
This commit is contained in:
parent
50cbce92fc
commit
e004491b55
11 changed files with 143 additions and 48 deletions
|
@ -30,15 +30,30 @@ func accountIndexHandler(app *model.AppState) http.Handler {
|
|||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
session := r.Context().Value("session").(*model.Session)
|
||||
|
||||
totps, err := controller.GetTOTPsForAccount(app.DB, session.Account.ID)
|
||||
dbTOTPs, err := controller.GetTOTPsForAccount(app.DB, session.Account.ID)
|
||||
if err != nil {
|
||||
fmt.Printf("WARN: Failed to fetch TOTPs: %v\n", err)
|
||||
http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
type accountResponse struct {
|
||||
Session *model.Session
|
||||
TOTPs []model.TOTP
|
||||
type (
|
||||
TOTP struct {
|
||||
model.TOTP
|
||||
CreatedAtString string
|
||||
}
|
||||
|
||||
accountResponse struct {
|
||||
Session *model.Session
|
||||
TOTPs []TOTP
|
||||
}
|
||||
)
|
||||
|
||||
totps := []TOTP{}
|
||||
for _, totp := range dbTOTPs {
|
||||
totps = append(totps, TOTP{
|
||||
TOTP: totp,
|
||||
CreatedAtString: totp.CreatedAt.Format("02 Jan 2006, 15:04:05"),
|
||||
})
|
||||
}
|
||||
|
||||
sessionMessage := session.Message
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue