mirror of
https://github.com/Floriansylvain/RenewCMS.git
synced 2026-08-19 11:43:22 +02:00
feat: integration page #41
This commit is contained in:
@@ -147,6 +147,8 @@ func NewPageRouter() http.Handler {
|
||||
r.Post("/post/create", PostPostCreatePage)
|
||||
|
||||
r.Post("/post/{id}/image/create", postImage)
|
||||
|
||||
r.Get("/integration", GetPageIntegration)
|
||||
})
|
||||
|
||||
return r
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"html/template"
|
||||
"net/http"
|
||||
"os"
|
||||
)
|
||||
|
||||
func GetPageIntegration(w http.ResponseWriter, r *http.Request) {
|
||||
navbarTmpl, _ := Container.GetPageUseCase.GetPage("componentNavbar", nil)
|
||||
templ, _ := Container.GetPageUseCase.GetPage("integration", map[string]interface{}{
|
||||
"Navbar": template.HTML(navbarTmpl),
|
||||
"Head": headTmpl,
|
||||
"Host": os.Getenv("HOST"),
|
||||
})
|
||||
_, _ = w.Write(templ)
|
||||
}
|
||||
@@ -32,11 +32,13 @@ func GetLoginPageHandler(loginPage *LoginPage) http.HandlerFunc {
|
||||
return
|
||||
}
|
||||
success, _ := url.QueryUnescape(r.URL.Query().Get("success"))
|
||||
failure, _ := url.QueryUnescape(r.URL.Query().Get("failure"))
|
||||
bs, _ := Container.GetPageUseCase.GetPage("login", map[string]interface{}{
|
||||
"PageError": loginPage.PageError,
|
||||
"Username": loginPage.Username,
|
||||
"Head": headTmpl,
|
||||
"Success": success,
|
||||
"Failure": failure,
|
||||
})
|
||||
_, _ = w.Write(bs)
|
||||
}
|
||||
|
||||
@@ -30,6 +30,9 @@ var EmptyRegisterPage = &RegisterPage{
|
||||
|
||||
func GetRegisterPageHandler(registerPage *RegisterPage) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
if !IsLoggedIn(r) && SomeUsersVerified() {
|
||||
http.Redirect(w, r, "/login?failure=There is already a verified account, please login.", http.StatusSeeOther)
|
||||
}
|
||||
if (IsLoggedIn(r) && IsVerified(r)) || SomeUsersVerified() {
|
||||
http.Redirect(w, r, "/home", http.StatusSeeOther)
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user