diff --git a/resources/flexiana/xiana_unstable/build/src/backend/app_name/controllers/auth.tmpl b/resources/flexiana/xiana_unstable/build/src/backend/app_name/controllers/auth.tmpl new file mode 100644 index 0000000..d533536 --- /dev/null +++ b/resources/flexiana/xiana_unstable/build/src/backend/app_name/controllers/auth.tmpl @@ -0,0 +1,11 @@ +(ns {{main/ns}}.controllers.auth + (:require + [ring.util.response :refer [response]])) + +;;; TODO +;;; Authenticate fn is just a placeholder you need to implement the logic to handle the login data sent from the login page + +(defn authenticate + [state] + (let [req-form-params (get-in state [:request :form-params])] + (assoc state :response (response (str req-form-params))))) diff --git a/resources/flexiana/xiana_unstable/build/src/backend/app_name/controllers/login.tmpl b/resources/flexiana/xiana_unstable/build/src/backend/app_name/controllers/login.tmpl new file mode 100644 index 0000000..4893d3a --- /dev/null +++ b/resources/flexiana/xiana_unstable/build/src/backend/app_name/controllers/login.tmpl @@ -0,0 +1,39 @@ +(ns {{main/ns}}.controllers.login + (:require + [ring.util.response :refer [response]] + [hiccup.page :as hp])) + +(defn page + [] + (hp/html5 + [:body {:style {:height "400px"}} + [:div {:style {:height "100%" + :display "flex" + :align-items "center" + :justify-content "center" + :flex-direction "column"}} + [:h1 {:style {:margin-bottom "80px"}} + (str "{{main/ns}}")] + [:form {:action "/auth" + :method "post"} + [:div {:style {:display "flex" + :flex-direction "column"}} + [:label "Username"] + [:input {:type "text" + :id "username" + :name "username" + :placeholder "Username"}]] + + [:div {:style {:display "flex" + :flex-direction "column"}} + [:label "Password"] + [:input {:type "password" + :id "password" + :name "password" + :placeholder "Password"}]] + [:input {:type "submit" + :value (str "Login")}]]]])) + +(defn login-page + [state] + (assoc state :response (response (page)))) diff --git a/resources/flexiana/xiana_unstable/build/src/backend/app_name/core.tmpl b/resources/flexiana/xiana_unstable/build/src/backend/app_name/core.tmpl index 2df1812..693247d 100644 --- a/resources/flexiana/xiana_unstable/build/src/backend/app_name/core.tmpl +++ b/resources/flexiana/xiana_unstable/build/src/backend/app_name/core.tmpl @@ -4,6 +4,8 @@ [{{main/ns}}.controllers.index :as index] [{{main/ns}}.controllers.re-frame :as re-frame] [{{main/ns}}.controllers.swagger :as swc] + [{{main/ns}}.controllers.auth :refer [authenticate]] + [{{main/ns}}.controllers.login :refer [login-page]] [xiana.config :as config] [xiana.db :as db] [xiana.interceptor :as interceptors] @@ -21,6 +23,8 @@ ^:no-doc ["/re-frame" {:action #'re-frame/handle-index :swagger {:produces ["text/html"]}}] ^:no-doc ["/assets/*" (ring/create-resource-handler {:path "/"})] + ["/login" {:get {:action #'login-page}}] + ["/auth" {:post {:action #'authenticate}}] ["/api" {:post {:action #'index/handle-post :parameters {:body {:first-name string? :last-name string? diff --git a/resources/flexiana/xiana_unstable/template.edn b/resources/flexiana/xiana_unstable/template.edn index b4ff60e..2fb68b9 100644 --- a/resources/flexiana/xiana_unstable/template.edn +++ b/resources/flexiana/xiana_unstable/template.edn @@ -14,6 +14,8 @@ ["build/src/backend/app_name/controllers" "src/backend/{{main/file}}/controllers" {"re_frame.tmpl" "re_frame.clj" + "login.tmpl" "login.clj" + "auth.tmpl" "auth.clj" "index.tmpl" "index.clj" "swagger.tmpl" "swagger.clj"}]