surtur
6b45213649
All checks were successful
continuous-integration/drone/push Build is passing
* add user onboarding workflow * fix user editing (no edits of passwords of regular users after onboarding) * refresh HIBP breach cache in DB on app start-up * display HIBP breach details * fix request scheduling to prevent panics (this still needs some love..) * fix middleware auth * add TODOs * update head.tmpl * reword some error messages
44 lines
807 B
Go
44 lines
807 B
Go
// Copyright 2023 wanderer <a_mirre at utb dot cz>
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
package handlers
|
|
|
|
import (
|
|
"errors"
|
|
"fmt"
|
|
"strconv"
|
|
|
|
moduser "git.dotya.ml/mirre-mt/pcmt/modules/user"
|
|
"github.com/labstack/echo/v4"
|
|
)
|
|
|
|
var (
|
|
ErrNoSession = errors.New("No session found, please log in")
|
|
ErrSessionExpired = errors.New("Session expired, log in again")
|
|
)
|
|
|
|
func renderErrorPage(c echo.Context, status int, statusText, error string) error {
|
|
addHeaders(c)
|
|
|
|
strStatus := strconv.Itoa(status)
|
|
|
|
p := newPage()
|
|
|
|
p.Title = fmt.Sprintf("Error %s - %s", strStatus, statusText)
|
|
p.Current = strStatus
|
|
p.Error = error
|
|
p.Status = strStatus
|
|
p.StatusText = statusText
|
|
|
|
u, ok := c.Get("sessUsr").(moduser.User)
|
|
if ok {
|
|
p.User = u
|
|
}
|
|
|
|
return c.Render(
|
|
status,
|
|
"errorPage.tmpl",
|
|
p,
|
|
)
|
|
}
|