Should (mostly) fix the new history page.

This commit is contained in:
2023-01-11 14:09:08 -08:00
parent 045aa01edc
commit b096863842
4 changed files with 82 additions and 82 deletions

View File

@@ -39,22 +39,25 @@
:user/provider-id (:id profile)
:user/role :user-role/none
:user/name (:name profile)})
auth {:user (:name profile)
:exp (time/plus (time/now) (time/days 30))
:user/clients (map (fn [c]
(select-keys c [:client/code :db/id :client/name :client/locations]))
(:user/clients user))
:user/role (name (:user/role user))
:user/name (:name profile)}
]
(log/info "authenticated as user" user)
;; TODO - these namespaces are not being transmitted/deserialized properly
(if (and token user)
(let [jwt (jwt/sign {:user (:name profile)
:exp (time/plus (time/now) (time/days 30))
:user/clients (map (fn [c]
(select-keys c [:client/code :db/id :client/name :client/locations]))
(:user/clients user))
:user/role (name (:user/role user))
:user/name (:name profile)}
(let [jwt (jwt/sign auth
(:jwt-secret env)
{:alg :hs512})]
{:status 301
:headers {"Location" (str "/?jwt=" jwt)}})
:headers {"Location" (str "/?jwt=" jwt)}
:session {:identity auth}})
{:status 401
:body "Couldn't authenticate"}))
(catch Exception e