Verified Commit c07fbd53 authored by Kamalavelan's avatar Kamalavelan 💬

Update homepage, work on user auth, registration

Signed-off-by: Kamalavelan's avatarKamalavelan <>
parent cbc48692
"name": "thiral",
"version": "1.0.0",
"description": "*thiral* is an experiment in radical transparency & coordinated action for communities rallying around social action",
"main": "index.js",
"directories": {
"test": "test"
"dependencies": {
"leaflet": "^1.4.0",
"shadow-cljs": "^2.8.21"
"devDependencies": {},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"repository": {
"type": "git",
"url": "git+ssh://"
"author": "Kamalavelan",
"license": "AGPL-3.0-or-later",
"bugs": {
"url": ""
"homepage": ""
......@@ -2,7 +2,7 @@
(:require [io.pedestal.http :as http]
[io.pedestal.http.route :as route]
[io.pedestal.http.body-params :as body-params]
[io.pedestal.http.ring-middlewares :as middlewares]
[io.pedestal.http.ring-middlewares :as middlewares]
[io.pedestal.interceptor :as interceptor]
[io.pedestal.interceptor.chain :as interceptor.chain]
[io.pedestal.interceptor.error :refer [error-dispatch]]
......@@ -14,9 +14,7 @@
[buddy.auth.backends :as auth.backends]
[buddy.auth.middleware :as auth.middleware]
;; [mount.core :refer defstate]
(def secret (:secret (clojure.edn/read-string (slurp "resources/env/secret.edn"))))
......@@ -55,24 +53,24 @@
(assoc ctx
(auth.middleware/authorization-error (:request ctx)
(catch Exception e
(assoc ctx ::interceptor.chain/error e)))
:else (assoc ctx ::interceptor.chain/error ex)))
(def common-interceptors [
(def common-interceptors [(body-params/body-params)
(authorization-interceptor backend)
(authorization-interceptor backend)])
;; Tabular routes
(def routes #{["/" :get (conj common-interceptors `home/home-page)]
["/about" :get (conj common-interceptors `about-page)]
["/login" :get (conj common-interceptors `site.auth/login)]})
["/login" :get (conj common-interceptors `site.auth/login-post)]})
;; Map-based routes
;(def routes `{"/" {:interceptors [(body-params/body-params) http/html-body]
......@@ -95,7 +93,7 @@
;; default interceptors will be ignored.
;; ::http/interceptors []
::http/routes routes
;; Uncomment next line to enable CORS support, add
;; string(s) specifying scheme, host and port for
;; allowed source(s):
......@@ -3,25 +3,24 @@
[ :only (html5 include-css include-js)]))
(defn base [title & content]
(defn base [title headers & content]
(html5 {:lang "en"}
[:meta {:charset "utf-8"}]
[:meta {:name "viewport" :content "width=device-width, initial-scale=1"}]
[:link {:rel "icon" :type "image/png" :href "/img/FSHM_logo.png"}]
;; [:link {:rel "icon" :type "image/png" :href "/img/favico.png"}]
[:title title]
(include-css "/css/bulma.min.css")
(include-js "/js/main.js")]
(include-css "/css/bulma.min.css" "")
(vals headers)]
{:aria-label "main navigation", :role "navigation"}
{:href "/"}
{:height "100",
:width "100",
:src "/img/FSHM_logo.png"}]]
;; [:i.fa.fa-activitypub.fa-3x]]
[:img {:src "/img/logo.png"}]]
{:data-target "navbarBasicExample",
:aria-expanded "false",
(:require [hiccup.core :as hiccup]
(:require [buddy.hashers :as hashers]
[hiccup.core :as hiccup]
[ring.util.response :as ring-resp]
[ :as site]))
[ :as site]
[thiral.db.users :as users]))
(defn authenticate [data]
"Authenticates user credentials from db"
(let [datum (users/users-by-email (:email data))]))
(defn login-page [request]
(ring-resp/response (site/base
[:h1 "hello"]
(defn new-user [data]
"Creates a new user in the db"
(println data)
(let [datum
{:email (:email data)
:password (hashers/derive (:password data) {:alg :bcrypt+blake2b-512})}]
(println datum)
(users/users-create datum)))
(defn login [request]
(-> (ring-resp/redirect "/")
(assoc :session {:token "token"})))
(defn login-post [request]
(-> (ring-resp/redirect "/")
(assoc :session {:token "token"})))
(defn register-post [request]
(-> (ring-resp/redirect "/")
(assoc :session {:token "token"})))
(defn register-page [request]
(defn auth-page [request]
(ring-resp/response (site/base
[:h1 "hello"]
"Login or Register"
[:h1 "hello"])))
(defn auth-control []
[:label.label "Email"]
[:input.input {:type "email" :placeholder ""}]]]
[:label.label "Password"]
[:input.input {:type "password" :placeholder ""}]]]))
(:require [hiccup.core :as hiccup]
[ :only (include-js)]
[ring.util.response :as ring-resp]
[ :as site]))
(defn home-page [request]
(-> (ring-resp/response (site/base
[:h1 "hello"]))
(assoc :session {:sexy "cool"}
{:a [:link
{:crossorigin "",
:href "",
:rel "stylesheet"}]
:b [:script {:src ""}]}
;;[:div#mapid {:style "height: 400px;"}]
[:h1 "hello"]
[ (]
;;[:script {:src "/js/main-script.js"}]
;;(assoc :session {:sexy "cool"}
;;:status 401
:cookies {:bird "kek"})))
;; :cookies {:bird "kek"})
......@@ -8,9 +8,9 @@
(::bootstrap/service-fn (bootstrap/create-servlet service/service)))
(deftest home-page-test
(is (=
(:body (response-for service :get "/"))
"Hello World!"))
;; (is (=
;; (:body (response-for service :get "/"))
;; "Hello World!"))
(is (=
(:headers (response-for service :get "/"))
{"Content-Type" "text/html;charset=UTF-8"
......@@ -23,9 +23,9 @@
"Content-Security-Policy" "object-src 'none'; script-src 'unsafe-inline' 'unsafe-eval' 'strict-dynamic' https: http:;"})))
(deftest about-page-test
(is (.contains
(:body (response-for service :get "/about"))
"Clojure 1.9"))
;;(is (.contains
;; (:body (response-for service :get "/about"))
;; "Clojure 1.9"))
(is (=
(:headers (response-for service :get "/about"))
{"Content-Type" "text/html;charset=UTF-8"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment