Add password protected links

This commit is contained in:
Andrey Chervyakov 2021-04-03 22:25:11 +06:00
parent 2baa74d520
commit a01f540a29
6 changed files with 67 additions and 28 deletions

View file

@ -11,13 +11,14 @@ import (
func redirectHandler(ctx echo.Context, serv Service) error {
linkId := ctx.Param("id")
linkPassword := ctx.QueryParam("password")
link, err := serv.GetById(linkId)
redirectUrl, err := serv.AccessLink(linkId, linkPassword)
if err != nil {
return err
}
return ctx.Redirect(http.StatusSeeOther, link.RedirectURL.String())
return ctx.Redirect(http.StatusSeeOther, redirectUrl.String())
}
func creationHandler(ctx echo.Context, serv Service) error {