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 --SET first_name = :first_name, last_name = :last_name, email = :email
--WHERE id = :id --WHERE id = :id
-- :name get-zeus-user :? :1 -- :name get-zeus-user :<! :1
-- :doc retrieve a user on their zeuswpi id -- :doc retrieve a user on their zeuswpi id
SELECT * FROM users SELECT * FROM users
WHERE zeusid = :zeusid WHERE zeusid = :zeusid

View file

@ -5,7 +5,7 @@
[cat.moauth :as mo] [cat.moauth :as mo]
[cat.db.core :refer [*db*] :as db])) [cat.db.core :refer [*db*] :as db]))
(def admins #{1 ;flynn (def admins #{10 ;flynn
}) })
(defn set-user! [user session redirect-url] (defn set-user! [user session redirect-url]
@ -33,7 +33,7 @@
(let [reee (mo/authorize-api-uri)] (let [reee (mo/authorize-api-uri)]
(log/info "authorize uri: " reee) (log/info "authorize uri: " reee)
(-> reee (-> reee
found))) found)))
(defn oauth-callback (defn oauth-callback
"Handles the callback from adams with the access_token "Handles the callback from adams with the access_token
@ -51,14 +51,16 @@
(let [user (mo/get-user-info access_token)] (let [user (mo/get-user-info access_token)]
(log/info "User info: " user) (log/info "User info: " user)
(let [zeususer (db/get-zeus-user {:zeusid (:id 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 (if zeususer
(set-user! zeususer session "/") (set-user! zeususer session "/")
(-> {:name (:username user) (let [user-template {:name (:username user)
:gender nil :gender nil
:zeusid (:id user)} :zeusid (:id user)}
(db/create-user!,,,) generated-key (-> user-template
(set-user!,,, session "/")))))))) (db/create-user!,,,))]
(log/info "Created user: " generated-key)
(set-user! (assoc user-template :id (:generated_key generated-key)) session "/"))))))))
;(catch [:status 401] _ ;(catch [:status 401] _
; (error-page {:status 401 ; (error-page {:status 401