Update URL routes

This commit is contained in:
Tom Wiesing 2023-01-03 13:02:42 +01:00
parent dab7a5c4ae
commit b3039768af
No known key found for this signature in database
21 changed files with 152 additions and 96 deletions

View file

@ -7,8 +7,10 @@ import (
"errors"
"fmt"
"image/png"
"net/http"
"github.com/FAU-CDI/wisski-distillery/internal/models"
"github.com/FAU-CDI/wisski-distillery/pkg/httpx"
"github.com/pquerna/otp"
"github.com/pquerna/otp/totp"
"golang.org/x/crypto/bcrypt"
@ -288,3 +290,18 @@ func (au *AuthUser) Delete(ctx context.Context) error {
return table.Delete(&au.User).Error
}
type userFormContext struct {
httpx.FormContext
User *models.User
}
func (au *Auth) UserFormContext(ctx httpx.FormContext, r *http.Request) any {
user, err := au.UserOf(r)
uctx := userFormContext{FormContext: ctx}
if err == nil {
uctx.User = &user.User
}
return uctx
}