0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-23 23:18:48 -05:00

Merge pull request #4983 from penpot/niwinz-backports-1

🐛 Backport bugfixes from develop
This commit is contained in:
Alejandro 2024-08-13 08:25:10 +02:00 committed by GitHub
commit ea5c22c244
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 31 additions and 23 deletions

View file

@ -407,6 +407,7 @@
(ex/raise :type :not-found (ex/raise :type :not-found
:code :object-not-found :code :object-not-found
:table table :table table
:params params
:hint "database object not found")) :hint "database object not found"))
row)) row))

View file

@ -355,16 +355,22 @@
profile (if-let [profile-id (:profile-id claims)] profile (if-let [profile-id (:profile-id claims)]
(profile/get-profile conn profile-id) (profile/get-profile conn profile-id)
(let [is-active (or (boolean (:is-active claims)) ;; NOTE: we first try to match existing profile
(not (contains? cf/flags :email-verification))) ;; by email, that in normal circumstances will
params (-> params ;; not return anything, but when a user tries to
(assoc :is-active is-active) ;; reuse the same token multiple times, we need
(update :password #(profile/derive-password cfg %)))] ;; to detect if the profile is already registered
(->> (create-profile! conn params) (or (profile/get-profile-by-email conn (:email claims))
(create-profile-rels! conn)))) (let [is-active (or (boolean (:is-active claims))
(not (contains? cf/flags :email-verification)))
params (-> params
(assoc :is-active is-active)
(update :password #(profile/derive-password cfg %)))
profile (->> (create-profile! conn params)
(create-profile-rels! conn))]
(vary-meta profile assoc :created true))))
;; When no profile-id comes on claims means a new register created? (-> profile meta :created true?)
created? (not (:profile-id claims))
invitation (when-let [token (:invitation-token params)] invitation (when-let [token (:invitation-token params)]
(tokens/verify (::setup/props cfg) {:token token :iss :team-invitation})) (tokens/verify (::setup/props cfg) {:token token :iss :team-invitation}))
@ -422,13 +428,13 @@
::audit/profile-id (:id profile)}))) ::audit/profile-id (:id profile)})))
:else :else
(let [elapsed? (elapsed-verify-threshold? profile) (let [elapsed? (elapsed-verify-threshold? profile)
complaints? (eml/has-reports? conn (:email profile)) reports? (eml/has-reports? conn (:email profile))
action (if complaints? action (if reports?
"ignore-because-complaints" "ignore-because-complaints"
(if elapsed? (if elapsed?
"resend-email-verification" "resend-email-verification"
"ignore"))] "ignore"))]
(l/wrn :hint "repeated registry detected" (l/wrn :hint "repeated registry detected"
:profile-id (str (:id profile)) :profile-id (str (:id profile))

View file

@ -55,14 +55,15 @@
(.replace js/location redirect-uri) (.replace js/location redirect-uri)
(log/error :hint "unexpected response from OIDC method" (log/error :hint "unexpected response from OIDC method"
:resp (pr-str rsp)))) :resp (pr-str rsp))))
(fn [{:keys [type code] :as error}] (fn [cause]
(cond (let [{:keys [type code] :as error} (ex-data cause)]
(and (= type :restriction) (cond
(= code :provider-not-configured)) (and (= type :restriction)
(st/emit! (msg/error (tr "errors.auth-provider-not-configured"))) (= code :provider-not-configured))
(st/emit! (msg/error (tr "errors.auth-provider-not-configured")))
:else :else
(st/emit! (msg/error (tr "errors.generic")))))))) (st/emit! (msg/error (tr "errors.generic")))))))))
(s/def ::email ::us/email) (s/def ::email ::us/email)
(s/def ::password ::us/not-empty-string) (s/def ::password ::us/not-empty-string)