aboutsummaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorSimon Ser <contact@emersion.fr>2020-07-07 12:47:18 +0200
committerSimon Ser <contact@emersion.fr>2020-07-07 12:47:18 +0200
commit92b30161962579fdd3bc133d8ccba03e4e1420fb (patch)
treec88b72176cc21b8753c78d2e3e7e9753b9838462 /plugins
parent50e131244ad78fd1e4c216770ff69471a6fcb03b (diff)
downloadalps-92b30161962579fdd3bc133d8ccba03e4e1420fb.tar.gz
alps-92b30161962579fdd3bc133d8ccba03e4e1420fb.zip
Fix nil render data on invalid password
This would cause this error: template: head.html:7:15: executing "head.html" at <index .Global.Path 0>: error calling index: index of untyped nil
Diffstat (limited to 'plugins')
-rw-r--r--plugins/base/routes.go19
1 files changed, 10 insertions, 9 deletions
diff --git a/plugins/base/routes.go b/plugins/base/routes.go
index b519a6b..b61b844 100644
--- a/plugins/base/routes.go
+++ b/plugins/base/routes.go
@@ -171,6 +171,14 @@ func handleLogin(ctx *alps.Context) error {
password := ctx.FormValue("password")
remember := ctx.FormValue("remember-me")
+ renderData := struct {
+ alps.BaseRenderData
+ CanRememberMe bool
+ }{
+ BaseRenderData: *alps.NewBaseRenderData(ctx),
+ CanRememberMe: ctx.Server.Options.LoginKey != nil,
+ }
+
if username == "" && password == "" {
username, password = ctx.GetLoginToken()
}
@@ -179,7 +187,7 @@ 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", nil)
+ return ctx.Render(http.StatusOK, "login.html", &renderData)
}
return fmt.Errorf("failed to put connection in pool: %v", err)
}
@@ -195,14 +203,7 @@ func handleLogin(ctx *alps.Context) error {
return ctx.Redirect(http.StatusFound, "/mailbox/INBOX")
}
- return ctx.Render(http.StatusOK, "login.html",
- &struct {
- alps.BaseRenderData
- CanRememberMe bool
- }{
- BaseRenderData: *alps.NewBaseRenderData(ctx),
- CanRememberMe: ctx.Server.Options.LoginKey != nil,
- })
+ return ctx.Render(http.StatusOK, "login.html", &renderData)
}
func handleLogout(ctx *alps.Context) error {