From affddda4be340c811bc61492bc2101191ec7dce9 Mon Sep 17 00:00:00 2001 From: MalinAhlberg Date: Thu, 27 Feb 2025 14:14:13 +0100 Subject: [PATCH] fix: show error msg and standard page when ega login fails setting a viewModel in .View("file.html", viewModel) overrides any previous viewdata calls. --- sda/cmd/auth/cega.go | 5 ----- sda/cmd/auth/main.go | 4 +++- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/sda/cmd/auth/cega.go b/sda/cmd/auth/cega.go index 54f2919bf..57f26fa72 100644 --- a/sda/cmd/auth/cega.go +++ b/sda/cmd/auth/cega.go @@ -11,11 +11,6 @@ import ( bcrypt "golang.org/x/crypto/bcrypt" ) -// EGALoginError is used to store message errors -type EGALoginError struct { - Reason string -} - // CegaUserResponse captures the response list type CegaUserResponse struct { PasswordHash string `json:"passwordHash"` diff --git a/sda/cmd/auth/main.go b/sda/cmd/auth/main.go index 1fe808846..f8822a416 100644 --- a/sda/cmd/auth/main.go +++ b/sda/cmd/auth/main.go @@ -160,6 +160,7 @@ func (auth AuthHandler) postEGA(ctx iris.Context) { s3conf := getS3ConfigMap(token, auth.Config.S3Inbox, username) s.SetFlash("ega", s3conf) + ctx.ViewData("infoUrl", auth.Config.InfoURL) ctx.ViewData("infoText", auth.Config.InfoText) ctx.ViewData("User", username) @@ -210,7 +211,8 @@ func (auth AuthHandler) getEGALogin(ctx iris.Context) { } ctx.ViewData("infoUrl", auth.Config.InfoURL) ctx.ViewData("infoText", auth.Config.InfoText) - err := ctx.View("loginform.html", EGALoginError{Reason: message}) + ctx.ViewData("Reason", message) + err := ctx.View("loginform.html") if err != nil { log.Error("Failed to view invalid credentials form: ", err)