This commit is contained in:
flynn 2019-02-14 04:44:26 +01:00
parent db828547aa
commit 7569d55191
2 changed files with 11 additions and 9 deletions

View file

@ -10,7 +10,7 @@ VALUES (:name, :gender, :zeusid)
--SET first_name = :first_name, last_name = :last_name, email = :email
--WHERE id = :id
-- :name get-zeus-user :? :1
-- :name get-zeus-user :<! :1
-- :doc retrieve a user on their zeuswpi id
SELECT * FROM users
WHERE zeusid = :zeusid

View file

@ -5,7 +5,7 @@
[cat.moauth :as mo]
[cat.db.core :refer [*db*] :as db]))
(def admins #{1 ;flynn
(def admins #{10 ;flynn
})
(defn set-user! [user session redirect-url]
@ -51,14 +51,16 @@
(let [user (mo/get-user-info access_token)]
(log/info "User info: " user)
(let [zeususer (db/get-zeus-user {:zeusid (:id user)})]
(println "Zeus user from db: " zeususer)
(log/info "Zeus user from db: " zeususer)
(if zeususer
(set-user! zeususer session "/")
(-> {:name (:username user)
(let [user-template {:name (:username user)
:gender nil
:zeusid (:id user)}
(db/create-user!,,,)
(set-user!,,, session "/"))))))))
generated-key (-> user-template
(db/create-user!,,,))]
(log/info "Created user: " generated-key)
(set-user! (assoc user-template :id (:generated_key generated-key)) session "/"))))))))
;(catch [:status 401] _
; (error-page {:status 401