Split "auth" and "user" routes

This commit is contained in:
Tom Wiesing 2023-01-05 13:55:05 +01:00
parent f3939c5016
commit 59b565ae19
No known key found for this signature in database
15 changed files with 148 additions and 99 deletions

View file

@ -6,10 +6,8 @@ import (
"encoding/base64"
"fmt"
"image/png"
"net/http"
"github.com/FAU-CDI/wisski-distillery/internal/models"
"github.com/FAU-CDI/wisski-distillery/pkg/httpx"
"github.com/pkg/errors"
"github.com/pquerna/otp"
"github.com/pquerna/otp/totp"
@ -292,18 +290,3 @@ 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
}