leo
dbd0e9d01d
All checks were successful
continuous-integration/drone/push Build is passing
* simplify protection of endpoints * role discernment still occures in respective handlers * db client needs to be passed into handlers as a global var now
39 lines
786 B
Go
39 lines
786 B
Go
// Copyright 2023 wanderer <a_mirre at utb dot cz>
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
package handlers
|
|
|
|
import (
|
|
"errors"
|
|
"fmt"
|
|
"strconv"
|
|
|
|
"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)
|
|
|
|
return c.Render(
|
|
status,
|
|
"errorPage.tmpl",
|
|
page{
|
|
AppName: setting.AppName(),
|
|
AppVer: appver,
|
|
Title: fmt.Sprintf("Error %s - %s", strStatus, statusText),
|
|
DevelMode: setting.IsDevel(),
|
|
Current: strStatus,
|
|
Error: error,
|
|
Status: strStatus,
|
|
StatusText: statusText,
|
|
},
|
|
)
|
|
}
|