Fix login page

This commit is contained in:
Achim Rohn
2025-07-27 21:55:32 +02:00
parent 47f45ea0ce
commit dc1719b309
2 changed files with 12 additions and 19 deletions
+11 -18
View File
@@ -1,34 +1,29 @@
package authentication
import (
"ersteller-lib"
"github.com/labstack/echo/v4"
"maragu.dev/gomponents"
. "maragu.dev/gomponents/html"
"salezenify/google"
"salezenify/html_components/components"
"salezenify/html_components/route"
"salezenify/layout"
"salezenify/user"
)
const LoginPath = "/login"
type LoginPage struct {
createPage layout.CreatePageFunc
LoginRoute route.GetRoute
createPage ersteller_lib.CreatePageFunc
LoginRoute ersteller_lib.GetRoute
googleLoginUrl string
}
func NewLoginPage(e *echo.Echo, createPage layout.CreatePageFunc) *LoginPage {
page := &LoginPage{createPage: createPage}
page.LoginRoute = route.NewGetRoute(LoginPath, page.Render).Add(e)
func NewLoginPage(e *echo.Echo, createPage ersteller_lib.CreatePageFunc, googleLoginUrl string) *LoginPage {
page := &LoginPage{createPage: createPage, googleLoginUrl: googleLoginUrl}
page.LoginRoute = ersteller_lib.NewGetRoute(LoginPath, page.Render).Add(e)
return page
}
func (l *LoginPage) Render(c echo.Context) error {
return l.createPage(c, layout.PageWebsiteMetaData{
WebsiteMetaData: components.WebsiteMetaData{
Title: "Login",
},
return l.createPage(c, ersteller_lib.PageWebsiteMetaData{
Title: "Login",
HideNavigation: true,
}, l.getLoginPage())
}
@@ -37,9 +32,8 @@ func (l *LoginPage) getLoginPage() gomponents.Group {
return []gomponents.Node{
P(
A(
Href(user.OpenIdConnectPath),
Href(OpenIdConnectPath),
Button(
Class(components.ButtonClass()),
Type("button"),
gomponents.Text("Login"),
),
@@ -47,9 +41,8 @@ func (l *LoginPage) getLoginPage() gomponents.Group {
),
P(
A(
Href(google.GoogleLogin),
Href(l.googleLoginUrl),
Button(
Class(components.ButtonClass()),
Type("button"),
gomponents.Text("Google Login"),
),