From 4aa94b06e2d44a6d896180b7b699cb8aab66abb6 Mon Sep 17 00:00:00 2001 From: Denis Arh Date: Sat, 6 Mar 2021 08:41:31 +0100 Subject: [PATCH] Add security page --- auth/assets/templates/inc_nav.html.tpl | 4 +--- auth/assets/templates/security.html.tpl | 10 ++++++++++ auth/handlers/handle_security.go | 10 ++++++++++ auth/handlers/handler.go | 1 + auth/handlers/links.go | 4 ++++ auth/handlers/routes.go | 1 + 6 files changed, 27 insertions(+), 3 deletions(-) create mode 100644 auth/assets/templates/security.html.tpl create mode 100644 auth/handlers/handle_security.go diff --git a/auth/assets/templates/inc_nav.html.tpl b/auth/assets/templates/inc_nav.html.tpl index ccbaeb901..618569aef 100644 --- a/auth/assets/templates/inc_nav.html.tpl +++ b/auth/assets/templates/inc_nav.html.tpl @@ -18,11 +18,9 @@ - {{ if .settings.LocalEnabled }} - {{ end }} diff --git a/auth/assets/templates/security.html.tpl b/auth/assets/templates/security.html.tpl new file mode 100644 index 000000000..163b0b329 --- /dev/null +++ b/auth/assets/templates/security.html.tpl @@ -0,0 +1,10 @@ +{{ template "inc_header.html.tpl" set . "activeNav" "security" }} +
+

Security

+ +
+{{ template "inc_footer.html.tpl" . }} diff --git a/auth/handlers/handle_security.go b/auth/handlers/handle_security.go new file mode 100644 index 000000000..f73d57071 --- /dev/null +++ b/auth/handlers/handle_security.go @@ -0,0 +1,10 @@ +package handlers + +import ( + "github.com/cortezaproject/corteza-server/auth/request" +) + +func (h *AuthHandlers) security(req *request.AuthReq) error { + req.Template = TmplSecurity + return nil +} diff --git a/auth/handlers/handler.go b/auth/handlers/handler.go index 4d053ca90..bacd4c2ab 100644 --- a/auth/handlers/handler.go +++ b/auth/handlers/handler.go @@ -84,6 +84,7 @@ const ( TmplRequestPasswordReset = "request-password-reset.html.tpl" TmplPasswordResetRequested = "password-reset-requested.html.tpl" TmplResetPassword = "reset-password.html.tpl" + TmplSecurity = "security.html.tpl" TmplProfile = "profile.html.tpl" TmplSessions = "sessions.html.tpl" TmplSignup = "signup.html.tpl" diff --git a/auth/handlers/links.go b/auth/handlers/links.go index 0252e0cad..20f19785a 100644 --- a/auth/handlers/links.go +++ b/auth/handlers/links.go @@ -7,7 +7,10 @@ type ( ConfirmEmail, PendingEmailConfirmation, Login, + + Security, ChangePassword, + RequestPasswordReset, PasswordResetRequested, ResetPassword, @@ -34,6 +37,7 @@ func GetLinks() Links { ConfirmEmail: "/auth/confirm-email", PendingEmailConfirmation: "/auth/pending-email-confirmation", Login: "/auth/login", + Security: "/auth/security", ChangePassword: "/auth/change-password", RequestPasswordReset: "/auth/request-password-reset", PasswordResetRequested: "/auth/password-reset-requested", diff --git a/auth/handlers/routes.go b/auth/handlers/routes.go index 9e770c8e9..a3108bf84 100644 --- a/auth/handlers/routes.go +++ b/auth/handlers/routes.go @@ -69,6 +69,7 @@ func (h *AuthHandlers) MountHttpRoutes(r chi.Router) { r.Get(l.ResetPassword, h.handle(h.onlyIfPasswordResetEnabled(h.resetPasswordForm))) r.Post(l.ResetPassword, h.handle(h.onlyIfPasswordResetEnabled(authOnly(h.resetPasswordProc)))) + r.Get(l.Security, h.handle(authOnly(h.security))) r.Get(l.ChangePassword, h.handle(h.onlyIfLocalEnabled(authOnly(h.changePasswordForm)))) r.Post(l.ChangePassword, h.handle(h.onlyIfLocalEnabled(authOnly(h.changePasswordProc)))) })