Skip to content
Snippets Groups Projects
Verified Commit 75808857 authored by Gabriel Zachmann's avatar Gabriel Zachmann
Browse files

implement calendar remove code

parent 1079498a
No related branches found
No related tags found
No related merge requests found
......@@ -86,3 +86,14 @@ func AddRemoveFromCalendarCode(
)
return
}
// UseRemoveCalendarCode uses a calendar remove ActionCode to remove a token from a calendar and then deletes the
// code from the database
func UseRemoveCalendarCode(rlog log.Ext1FieldLogger, tx *sqlx.Tx, code string) error {
return db.RunWithinTransaction(
rlog, tx, func(tx *sqlx.Tx) error {
_, err := tx.Exec(`CALL ActionCodes_UseRemoveFromCalendar(?)`, code)
return errors.WithStack(err)
},
)
}
......@@ -23,8 +23,6 @@ func HandleActions(ctx *fiber.Ctx) error {
switch actionInfo.Action {
case pkg.ActionRecreate:
return handleRecreate(ctx, actionInfo.Code)
case pkg.ActionManageNotification:
return handleManageNotification(ctx, actionInfo.Code)
case pkg.ActionVerifyEmail:
return handleVerifyEmail(ctx, actionInfo.Code)
case pkg.ActionRemoveFromCalendar:
......@@ -53,11 +51,15 @@ func handleVerifyEmail(ctx *fiber.Ctx, code string) error {
)
}
func handleManageNotification(ctx *fiber.Ctx, code string) error {
return ctxutils.RenderErrorPage(ctx, fiber.StatusNotImplemented, api.ErrorNYI.CombinedMessage())
}
func handleRemoveFromCalendar(ctx *fiber.Ctx, code string) error {
return ctxutils.RenderErrorPage(ctx, fiber.StatusNotImplemented, api.ErrorNYI.CombinedMessage())
rlog := logger.GetRequestLogger(ctx)
err := actionrepo.UseRemoveCalendarCode(rlog, nil, code)
if err != nil {
return ctxutils.RenderInternalServerErrorPage(ctx, err)
}
return ctxutils.RenderErrorPage(
ctx, http.StatusOK, "The token was successfully removed from the calendar.", "Token Removed from Calendar",
)
}
// CreateVerifyEmail creates an action url for verifying a mail address
......
......@@ -9,13 +9,11 @@ import (
const (
ActionRecreate = "recreate_token"
ActionVerifyEmail = "verify_email"
ActionManageNotification = "manage_notification"
ActionRemoveFromCalendar = "remove_from_calendar"
)
// CodeLifetimes holds the default lifetime of the different action codes
var CodeLifetimes = map[string]int{
ActionManageNotification: 0,
ActionVerifyEmail: 3600,
ActionRecreate: 0,
ActionRemoveFromCalendar: 0,
......
......@@ -34,7 +34,7 @@
<script src="{{instance-url}}/static/js/create-mt.js"></script>
<script src="{{instance-url}}/static/js/capabilities.js"></script>
<script src="{{instance-url}}/static/js/notifications.js"></script>
<!-- <script src="{{instance-url}}/static/js/settings-notifications.js"></script>-->
<script src="{{instance-url}}/static/js/settings-notifications.js"></script>
{{/home}}
{{#settings}}
<script src="{{instance-url}}/static/js/tokeninfo.js"></script>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment