From 9553724c8286eea7d7e8217d5f9f1c762c9b7c82 Mon Sep 17 00:00:00 2001 From: Jonas Mueller Date: Fri, 25 Feb 2022 15:02:30 +0000 Subject: Show notice & error code on failed login Upon failed login, this patch sets the status code to 401 and provides a Notice to show in login.html --- plugins/base/routes.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'plugins') diff --git a/plugins/base/routes.go b/plugins/base/routes.go index f426c96..255faa5 100644 --- a/plugins/base/routes.go +++ b/plugins/base/routes.go @@ -366,7 +366,8 @@ func handleLogin(ctx *alps.Context) error { s, err := ctx.Server.Sessions.Put(username, password) if err != nil { if _, ok := err.(alps.AuthError); ok { - return ctx.Render(http.StatusOK, "login.html", &renderData) + renderData.BaseRenderData.GlobalData.Notice = "Failed to login!" + return ctx.Render(http.StatusUnauthorized, "login.html", &renderData) } return fmt.Errorf("failed to put connection in pool: %v", err) } -- cgit v1.2.3 From f4523b51af0787795973b403b978ff74737a47ef Mon Sep 17 00:00:00 2001 From: Conrad Hoffmann Date: Tue, 1 Mar 2022 11:04:31 +0100 Subject: carddav: fix accidental shadowing of variables The statement changed here creates new variables, whereas it means to assign values to the previously declared `ao` to be used outside of the if statement. This lead to PUT requests always being sent to a URL containing a new UUID, causing problems with some CardDAV servers. --- plugins/carddav/routes.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins') diff --git a/plugins/carddav/routes.go b/plugins/carddav/routes.go index fe7c37d..6c8a85f 100644 --- a/plugins/carddav/routes.go +++ b/plugins/carddav/routes.go @@ -141,7 +141,7 @@ func registerRoutes(p *plugin) { var ao *carddav.AddressObject var card vcard.Card if addressObjectPath != "" { - ao, err := c.GetAddressObject(addressObjectPath) + ao, err = c.GetAddressObject(addressObjectPath) if err != nil { return fmt.Errorf("failed to query CardDAV address: %v", err) } -- cgit v1.2.3 From 7cb145748a4ef9a74a95cf0eaeace354950bfd32 Mon Sep 17 00:00:00 2001 From: Alex McGrath Date: Sat, 7 May 2022 09:17:12 +0100 Subject: gracefully fail when no messages are selected for deletion or moving --- plugins/base/routes.go | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'plugins') diff --git a/plugins/base/routes.go b/plugins/base/routes.go index 255faa5..52d1681 100644 --- a/plugins/base/routes.go +++ b/plugins/base/routes.go @@ -1024,6 +1024,11 @@ func handleMove(ctx *alps.Context) error { return echo.NewHTTPError(http.StatusBadRequest, err) } + if len(uids) == 0 { + ctx.Session.PutNotice("No messages selected.") + return ctx.Redirect(http.StatusFound, fmt.Sprintf("/mailbox/%v", url.PathEscape(mboxName))) + } + to := formOrQueryParam(ctx, "to") if to == "" { return echo.NewHTTPError(http.StatusBadRequest, "missing 'to' form parameter") @@ -1071,6 +1076,11 @@ func handleDelete(ctx *alps.Context) error { return echo.NewHTTPError(http.StatusBadRequest, err) } + if len(uids) == 0 { + ctx.Session.PutNotice("No messages selected.") + return ctx.Redirect(http.StatusFound, fmt.Sprintf("/mailbox/%v", url.PathEscape(mboxName))) + } + err = ctx.Session.DoIMAP(func(c *imapclient.Client) error { if err := ensureMailboxSelected(c, mboxName); err != nil { return err -- cgit v1.2.3