mirror of
https://codeberg.org/scip/ephemerup.git
synced 2025-12-17 04:30:57 +01:00
changes:
- added unit tests
- put all subcmds into one file
- use io.Writer for output, better for testing
- added upload form support
- added api docs
- generalized db engine
- added mail notify support for forms
- enhanced server/SetupAuthStore() to also look up form ids
- added form template (put into .go file by Makefile
- renamed project
This commit is contained in:
25
api/utils.go
25
api/utils.go
@@ -20,8 +20,8 @@ package api
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/gofiber/fiber/v2"
|
||||
"github.com/tlinden/cenophane/cfg"
|
||||
"github.com/tlinden/cenophane/common"
|
||||
"github.com/tlinden/ephemerup/cfg"
|
||||
"github.com/tlinden/ephemerup/common"
|
||||
"time"
|
||||
)
|
||||
|
||||
@@ -55,7 +55,7 @@ func Ts() string {
|
||||
|
||||
If there's no apicontext in the session, assume unauth user, return ""
|
||||
*/
|
||||
func GetApicontext(c *fiber.Ctx) (string, error) {
|
||||
func SessionGetApicontext(c *fiber.Ctx) (string, error) {
|
||||
sess, err := Sessionstore.Get(c)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("Unable to initialize session store from context: " + err.Error())
|
||||
@@ -69,6 +69,25 @@ func GetApicontext(c *fiber.Ctx) (string, error) {
|
||||
return "", nil
|
||||
}
|
||||
|
||||
/*
|
||||
Retrieve the formid (aka onetime api key) from the session. It is
|
||||
configured if an upload request has been successfully authenticated
|
||||
using a onetime key.
|
||||
*/
|
||||
func SessionGetFormId(c *fiber.Ctx) (string, error) {
|
||||
sess, err := Sessionstore.Get(c)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("Unable to initialize session store from context: " + err.Error())
|
||||
}
|
||||
|
||||
formid := sess.Get("formid")
|
||||
if formid != nil {
|
||||
return formid.(string), nil
|
||||
}
|
||||
|
||||
return "", nil
|
||||
}
|
||||
|
||||
/*
|
||||
Calculate if time is up based on start time.Time and
|
||||
duration. Returns true if time is expired. Start time comes from
|
||||
|
||||
Reference in New Issue
Block a user