0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-03-13 00:01:51 -05:00

Merge pull request #1889 from penpot/palba-canceled-invitation-page

🎉 Show an error page when the user uses a cancelled/invalid/expired invitation
This commit is contained in:
Eva Marco 2022-05-11 16:39:39 +02:00 committed by GitHub
commit 5bdea086e9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 37 additions and 58 deletions

View file

@ -12,7 +12,7 @@
[app.loggers.audit :as audit] [app.loggers.audit :as audit]
[app.rpc.mutations.teams :as teams] [app.rpc.mutations.teams :as teams]
[app.rpc.queries.profile :as profile] [app.rpc.queries.profile :as profile]
[app.util.services :as sv] [app.util.services :as sv]
[clojure.spec.alpha :as s] [clojure.spec.alpha :as s]
[cuerdas.core :as str])) [cuerdas.core :as str]))
@ -114,15 +114,25 @@
{:is-active true} {:is-active true}
{:id member-id})) {:id member-id}))
(assoc member :is-active true) (assoc member :is-active true)
;; Delete the invitation ;; Delete the invitation
(db/delete! conn :team-invitation (db/delete! conn :team-invitation
{:team-id team-id :email-to (str/lower member-email)}))) {:team-id team-id :email-to (str/lower member-email)})))
(defmethod process-token :team-invitation (defmethod process-token :team-invitation
[cfg {:keys [profile-id token]} {:keys [member-id] :as claims}] [cfg {:keys [profile-id token]} {:keys [member-id] :as claims}]
(us/assert ::team-invitation-claims claims) (us/assert ::team-invitation-claims claims)
#_(let [conn (:conn cfg)
team-id (:team-id claims)
member-email (:member-email claims)
invitation (db/get-by-params conn :team-invitation
{:team-id team-id :email-to (str/lower member-email)}
{:check-not-found false})]
(when (nil? invitation)
(ex/raise :type :validation
:code :invalid-token)))
(cond (cond
;; This happens when token is filled with member-id and current ;; This happens when token is filled with member-id and current
;; user is already logged in with exactly invited account. ;; user is already logged in with exactly invited account.

View file

@ -11,6 +11,7 @@
[app.main.repo :as rp] [app.main.repo :as rp]
[app.main.store :as st] [app.main.store :as st]
[app.main.ui.icons :as i] [app.main.ui.icons :as i]
[app.main.ui.static :as static]
[app.util.dom :as dom] [app.util.dom :as dom]
[app.util.i18n :as i18n :refer [tr]] [app.util.i18n :as i18n :refer [tr]]
[app.util.router :as rt] [app.util.router :as rt]
@ -59,7 +60,8 @@
(mf/defc verify-token (mf/defc verify-token
[{:keys [route] :as props}] [{:keys [route] :as props}]
(let [token (get-in route [:query-params :token])] (let [token (get-in route [:query-params :token])
bad-token (mf/use-state false)]
(mf/use-effect (mf/use-effect
(fn [] (fn []
(dom/set-html-title (tr "title.default")) (dom/set-html-title (tr "title.default"))
@ -69,13 +71,10 @@
(handle-token tdata)) (handle-token tdata))
(fn [{:keys [type code] :as error}] (fn [{:keys [type code] :as error}]
(cond (cond
(and (= :validation type) (or (= :validation type)
(= :invalid-token code) (= :invalid-token code)
(= :token-expired (:reason error))) (= :token-expired (:reason error)))
(let [msg (tr "errors.token-expired")] (reset! bad-token true)
(ts/schedule 100 #(st/emit! (dm/error msg)))
(st/emit! (rt/nav :auth-login)))
(= :email-already-exists code) (= :email-already-exists code)
(let [msg (tr "errors.email-already-exists")] (let [msg (tr "errors.email-already-exists")]
(ts/schedule 100 #(st/emit! (dm/error msg))) (ts/schedule 100 #(st/emit! (dm/error msg)))
@ -91,5 +90,10 @@
(ts/schedule 100 #(st/emit! (dm/error msg))) (ts/schedule 100 #(st/emit! (dm/error msg)))
(st/emit! (rt/nav :auth-login))))))))) (st/emit! (rt/nav :auth-login)))))))))
[:div.verify-token (if @bad-token
i/loader-pencil])) [:> static/static-header {}
[:div.image i/unchain]
[:div.main-message (tr "errors.invite-invalid")]
[:div.desc-message (tr "errors.invite-invalid.info")]]
[:div.verify-token
i/loader-pencil])))

View file

@ -539,9 +539,6 @@ msgstr "التسجيل معطل حاليا."
msgid "errors.terms-privacy-agreement-invalid" msgid "errors.terms-privacy-agreement-invalid"
msgstr "يجب أن تقبل شروط الخدمة وسياسة الخصوصية الخاصة بنا." msgstr "يجب أن تقبل شروط الخدمة وسياسة الخصوصية الخاصة بنا."
#: src/app/main/ui/auth/verify_token.cljs
msgid "errors.token-expired"
msgstr "انتهت صلاحية الرمز"
#: src/app/main/data/media.cljs, src/app/main/ui/workspace/sidebar/options/menus/exports.cljs, src/app/main/ui/handoff/exports.cljs #: src/app/main/data/media.cljs, src/app/main/ui/workspace/sidebar/options/menus/exports.cljs, src/app/main/ui/handoff/exports.cljs
msgid "errors.unexpected-error" msgid "errors.unexpected-error"

View file

@ -701,10 +701,6 @@ msgstr ""
"Heu d'acceptar les nostres condicions del servei i la política de " "Heu d'acceptar les nostres condicions del servei i la política de "
"privacitat." "privacitat."
#: src/app/main/ui/auth/verify_token.cljs
msgid "errors.token-expired"
msgstr "El codi ha caducat"
#: src/app/main/data/media.cljs, src/app/main/ui/workspace/sidebar/options/menus/exports.cljs, src/app/main/ui/handoff/exports.cljs #: src/app/main/data/media.cljs, src/app/main/ui/workspace/sidebar/options/menus/exports.cljs, src/app/main/ui/handoff/exports.cljs
msgid "errors.unexpected-error" msgid "errors.unexpected-error"
msgstr "S'ha produït un error inesperat." msgstr "S'ha produït un error inesperat."

View file

@ -700,10 +700,6 @@ msgstr ""
"Sie müssen unsere Nutzungsbedingungen und Datenschutzrichtlinien " "Sie müssen unsere Nutzungsbedingungen und Datenschutzrichtlinien "
"akzeptieren." "akzeptieren."
#: src/app/main/ui/auth/verify_token.cljs
msgid "errors.token-expired"
msgstr "Token abgelaufen"
#: src/app/main/data/media.cljs, src/app/main/ui/workspace/sidebar/options/menus/exports.cljs, src/app/main/ui/handoff/exports.cljs #: src/app/main/data/media.cljs, src/app/main/ui/workspace/sidebar/options/menus/exports.cljs, src/app/main/ui/handoff/exports.cljs
msgid "errors.unexpected-error" msgid "errors.unexpected-error"
msgstr "Ein unerwarteter Fehler ist aufgetreten." msgstr "Ein unerwarteter Fehler ist aufgetreten."

View file

@ -729,8 +729,12 @@ msgid "errors.terms-privacy-agreement-invalid"
msgstr "You must accept our terms of service and privacy policy." msgstr "You must accept our terms of service and privacy policy."
#: src/app/main/ui/auth/verify_token.cljs #: src/app/main/ui/auth/verify_token.cljs
msgid "errors.token-expired" msgid "errors.invite-invalid"
msgstr "Token expired" msgstr "Invite invalid"
msgid "errors.invite-invalid.info"
msgstr "This invite might be canceled or may be expired."
#: src/app/main/data/media.cljs, src/app/main/ui/workspace/sidebar/options/menus/exports.cljs, src/app/main/ui/handoff/exports.cljs #: src/app/main/data/media.cljs, src/app/main/ui/workspace/sidebar/options/menus/exports.cljs, src/app/main/ui/handoff/exports.cljs
msgid "errors.unexpected-error" msgid "errors.unexpected-error"

View file

@ -730,8 +730,12 @@ msgid "errors.terms-privacy-agreement-invalid"
msgstr "Debes aceptar nuestros términos de servicio y política de privacidad." msgstr "Debes aceptar nuestros términos de servicio y política de privacidad."
#: src/app/main/ui/auth/verify_token.cljs #: src/app/main/ui/auth/verify_token.cljs
msgid "errors.token-expired" msgid "errors.invite-invalid"
msgstr "Token expirado" msgstr "Invitación inválida"
msgid "errors.invite-invalid.info"
msgstr "Esta invitación puede haber sido cancelada o ha expirado."
#: src/app/main/data/media.cljs, src/app/main/ui/workspace/sidebar/options/menus/exports.cljs, src/app/main/ui/handoff/exports.cljs #: src/app/main/data/media.cljs, src/app/main/ui/workspace/sidebar/options/menus/exports.cljs, src/app/main/ui/handoff/exports.cljs
msgid "errors.unexpected-error" msgid "errors.unexpected-error"

View file

@ -596,10 +596,6 @@ msgstr ""
"Vous devez accepter nos conditions générales d'utilisation et notre " "Vous devez accepter nos conditions générales d'utilisation et notre "
"politique de confidentialité." "politique de confidentialité."
#: src/app/main/ui/auth/verify_token.cljs
msgid "errors.token-expired"
msgstr "Jeton expiré"
#: src/app/main/data/media.cljs, src/app/main/ui/workspace/sidebar/options/menus/exports.cljs, src/app/main/ui/handoff/exports.cljs #: src/app/main/data/media.cljs, src/app/main/ui/workspace/sidebar/options/menus/exports.cljs, src/app/main/ui/handoff/exports.cljs
msgid "errors.unexpected-error" msgid "errors.unexpected-error"
msgstr "Une erreur inattendue sest produite" msgstr "Une erreur inattendue sest produite"

View file

@ -673,10 +673,6 @@ msgstr "הבעלים לא יכולים לעזוב את הקבוצה, עליך ל
msgid "errors.terms-privacy-agreement-invalid" msgid "errors.terms-privacy-agreement-invalid"
msgstr "עליך לקבל את תנאי השירות ואת מדיניות הפרטיות." msgstr "עליך לקבל את תנאי השירות ואת מדיניות הפרטיות."
#: src/app/main/ui/auth/verify_token.cljs
msgid "errors.token-expired"
msgstr "תוקף האסימון פג"
#: src/app/main/data/media.cljs, src/app/main/ui/workspace/sidebar/options/menus/exports.cljs, src/app/main/ui/handoff/exports.cljs #: src/app/main/data/media.cljs, src/app/main/ui/workspace/sidebar/options/menus/exports.cljs, src/app/main/ui/handoff/exports.cljs
msgid "errors.unexpected-error" msgid "errors.unexpected-error"
msgstr "אירעה שגיאה בלתי צפויה." msgstr "אירעה שגיאה בלתי צפויה."

View file

@ -518,10 +518,6 @@ msgstr "O registro de contas está desativado no momento."
msgid "errors.terms-privacy-agreement-invalid" msgid "errors.terms-privacy-agreement-invalid"
msgstr "Você deve aceitar nossos termos de serviço e política de privacidade." msgstr "Você deve aceitar nossos termos de serviço e política de privacidade."
#: src/app/main/ui/auth/verify_token.cljs
msgid "errors.token-expired"
msgstr "Token expirado"
#: src/app/main/data/media.cljs, src/app/main/ui/workspace/sidebar/options/menus/exports.cljs, src/app/main/ui/handoff/exports.cljs #: src/app/main/data/media.cljs, src/app/main/ui/workspace/sidebar/options/menus/exports.cljs, src/app/main/ui/handoff/exports.cljs
msgid "errors.unexpected-error" msgid "errors.unexpected-error"
msgstr "Um erro inesperado ocorreu." msgstr "Um erro inesperado ocorreu."

View file

@ -509,10 +509,6 @@ msgstr "Înregistrarea este dezactivată în prezent."
msgid "errors.terms-privacy-agreement-invalid" msgid "errors.terms-privacy-agreement-invalid"
msgstr "Trebuie să acceptați termenii serviciului și politica de confidențialitate." msgstr "Trebuie să acceptați termenii serviciului și politica de confidențialitate."
#: src/app/main/ui/auth/verify_token.cljs
msgid "errors.token-expired"
msgstr "Codul este expirat"
#: src/app/main/data/media.cljs, src/app/main/ui/workspace/sidebar/options/menus/exports.cljs, src/app/main/ui/handoff/exports.cljs #: src/app/main/data/media.cljs, src/app/main/ui/workspace/sidebar/options/menus/exports.cljs, src/app/main/ui/handoff/exports.cljs
msgid "errors.unexpected-error" msgid "errors.unexpected-error"
msgstr "A apărut o eroare neașteptată." msgstr "A apărut o eroare neașteptată."

View file

@ -692,10 +692,6 @@ msgstr "Нужно переназначить роль владельца пер
msgid "errors.terms-privacy-agreement-invalid" msgid "errors.terms-privacy-agreement-invalid"
msgstr "Вы должны принять наши правила использования и политику конфиденциальности." msgstr "Вы должны принять наши правила использования и политику конфиденциальности."
#: src/app/main/ui/auth/verify_token.cljs
msgid "errors.token-expired"
msgstr "Токен истёк"
#: src/app/main/data/media.cljs, src/app/main/ui/workspace/sidebar/options/menus/exports.cljs, src/app/main/ui/handoff/exports.cljs #: src/app/main/data/media.cljs, src/app/main/ui/workspace/sidebar/options/menus/exports.cljs, src/app/main/ui/handoff/exports.cljs
msgid "errors.unexpected-error" msgid "errors.unexpected-error"
msgstr "Произошла ошибка." msgstr "Произошла ошибка."

View file

@ -692,10 +692,6 @@ msgstr "Sahip takımdan ayrılamaz, sahip rolünü yeniden atamanız gerekir."
msgid "errors.terms-privacy-agreement-invalid" msgid "errors.terms-privacy-agreement-invalid"
msgstr "Hizmet şartlarımızı ve gizlilik politikamızı kabul etmelisin." msgstr "Hizmet şartlarımızı ve gizlilik politikamızı kabul etmelisin."
#: src/app/main/ui/auth/verify_token.cljs
msgid "errors.token-expired"
msgstr "Jetonun süresi geçti"
#: src/app/main/data/media.cljs, src/app/main/ui/workspace/sidebar/options/menus/exports.cljs, src/app/main/ui/handoff/exports.cljs #: src/app/main/data/media.cljs, src/app/main/ui/workspace/sidebar/options/menus/exports.cljs, src/app/main/ui/handoff/exports.cljs
msgid "errors.unexpected-error" msgid "errors.unexpected-error"
msgstr "Beklenmedik bir hata oluştu." msgstr "Beklenmedik bir hata oluştu."

View file

@ -644,10 +644,6 @@ msgstr "当前禁止注册。"
msgid "errors.terms-privacy-agreement-invalid" msgid "errors.terms-privacy-agreement-invalid"
msgstr "你必须接受我们的使用条例和隐私政策。" msgstr "你必须接受我们的使用条例和隐私政策。"
#: src/app/main/ui/auth/verify_token.cljs
msgid "errors.token-expired"
msgstr "令牌已过期"
#: src/app/main/data/media.cljs, src/app/main/ui/workspace/sidebar/options/menus/exports.cljs, src/app/main/ui/handoff/exports.cljs #: src/app/main/data/media.cljs, src/app/main/ui/workspace/sidebar/options/menus/exports.cljs, src/app/main/ui/handoff/exports.cljs
msgid "errors.unexpected-error" msgid "errors.unexpected-error"
msgstr "发生了意料之外的错误。" msgstr "发生了意料之外的错误。"

View file

@ -583,10 +583,6 @@ msgstr "目前並不開放註冊。"
msgid "errors.terms-privacy-agreement-invalid" msgid "errors.terms-privacy-agreement-invalid"
msgstr "您必須接受我們的服務條款和隱私權政策。" msgstr "您必須接受我們的服務條款和隱私權政策。"
#: src/app/main/ui/auth/verify_token.cljs
msgid "errors.token-expired"
msgstr "權杖過期"
#: src/app/main/data/media.cljs, src/app/main/ui/workspace/sidebar/options/menus/exports.cljs, src/app/main/ui/handoff/exports.cljs #: src/app/main/data/media.cljs, src/app/main/ui/workspace/sidebar/options/menus/exports.cljs, src/app/main/ui/handoff/exports.cljs
msgid "errors.unexpected-error" msgid "errors.unexpected-error"
msgstr "發生了預料之外的錯誤。" msgstr "發生了預料之外的錯誤。"