Merge branch 'master' into try-tailwind
This commit is contained in:
@@ -5,7 +5,8 @@
|
||||
[clj-http.client :as http]
|
||||
[clj-time.core :as time]
|
||||
[clojure.tools.logging :as log]
|
||||
[config.core :refer [env]]))
|
||||
[config.core :refer [env]]
|
||||
[com.brunobonacci.mulog :as mu]))
|
||||
|
||||
(def google-client-id "264081895820-0nndcfo3pbtqf30sro82vgq5r27h8736.apps.googleusercontent.com")
|
||||
(def google-client-secret "OC-WemHurPXYpuIw5cT-B90g")
|
||||
@@ -30,13 +31,17 @@
|
||||
"grant_type" "authorization_code"}
|
||||
:as :json})
|
||||
:body)
|
||||
|
||||
token (:access_token auth)
|
||||
profile (-> (http/get "https://www.googleapis.com/oauth2/v1/userinfo"
|
||||
{:headers {"Authorization" (str "Bearer " token)} :as :json})
|
||||
:body)
|
||||
_ (mu/log ::got-profile
|
||||
:profile profile)
|
||||
user (users/find-or-insert! {:user/provider "google"
|
||||
:user/provider-id (:id profile)
|
||||
:user/role :user-role/none
|
||||
:user/email (:email profile)
|
||||
:user/profile-image-url (:picture profile)
|
||||
:user/name (:name profile)})
|
||||
auth {:user (:name profile)
|
||||
:exp (time/plus (time/now) (time/days 30))
|
||||
@@ -45,8 +50,8 @@
|
||||
(:user/clients user))
|
||||
:user/role (name (:user/role user))
|
||||
:user/name (:name profile)}
|
||||
]
|
||||
(log/info "authenticated as user" user)
|
||||
_ (mu/log ::logged-in-as
|
||||
:auth auth)]
|
||||
;; TODO - these namespaces are not being transmitted/deserialized properly
|
||||
|
||||
(if (and token user)
|
||||
|
||||
Reference in New Issue
Block a user