refactor(server): auth (#5895)

Remove `next-auth` and implement our own Authorization/Authentication system from scratch.

## Server

- [x] tokens
  - [x] function
  - [x] encryption

- [x] AuthController
  - [x] /api/auth/sign-in
  - [x] /api/auth/sign-out
  - [x] /api/auth/session
  - [x] /api/auth/session (WE SUPPORT MULTI-ACCOUNT!)

- [x] OAuthPlugin
  - [x] OAuthController
  - [x] /oauth/login
  - [x] /oauth/callback
  - [x] Providers
    - [x] Google
    - [x] GitHub

## Client

- [x] useSession
- [x] cloudSignIn
- [x] cloudSignOut

## NOTE:

Tests will be adding in the future
This commit is contained in:
liuyi
2024-03-12 10:00:09 +00:00
parent af49e8cc41
commit fb3a0e7b8f
148 changed files with 3407 additions and 2851 deletions

View File

@@ -406,10 +406,12 @@
"com.affine.appearanceSettings.windowFrame.description": "Customise appearance of Windows Client.",
"com.affine.appearanceSettings.windowFrame.frameless": "Frameless",
"com.affine.appearanceSettings.windowFrame.title": "Window frame style",
"com.affine.auth.change.email.message": "Your current email is {{email}}. Well send a temporary verification link to this email.",
"com.affine.auth.verify.email.message": "Your current email is {{email}}. Well send a temporary verification link to this email.",
"com.affine.auth.change.email.page.subtitle": "Please enter your new email address below. We will send a verification link to this email address to complete the process.",
"com.affine.auth.change.email.page.success.subtitle": "Congratulations! You have successfully updated the email address associated with your AFFiNE Cloud account.",
"com.affine.auth.change.email.page.success.title": "Email address updated!",
"com.affine.auth.verify.email.page.success.title": "Email address verified!",
"com.affine.auth.verify.email.page.success.subtitle": "Congratulations! You have successfully verified the email address associated with your AFFiNE Cloud account.",
"com.affine.auth.change.email.page.title": "Change email address",
"com.affine.auth.create.count": "Create Account",
"com.affine.auth.desktop.signing.in": "Signing in...",
@@ -430,11 +432,11 @@
"com.affine.auth.reset.password.message": "You will receive an email with a link to reset your password. Please check your inbox.",
"com.affine.auth.reset.password.page.success": "Password reset successful",
"com.affine.auth.reset.password.page.title": "Reset your AFFiNE Cloud password",
"com.affine.auth.send.change.email.link": "Send verification link",
"com.affine.auth.send.verify.email.hint": "Send verification link",
"com.affine.auth.send.reset.password.link": "Send reset link",
"com.affine.auth.send.set.password.link": "Send set link",
"com.affine.auth.sent": "Sent",
"com.affine.auth.sent.change.email.hint": "Verification link has been sent.",
"com.affine.auth.sent.verify.email.hint": "Verification link has been sent.",
"com.affine.auth.sent.change.email.fail": "The verification link failed to be sent, please try again later.",
"com.affine.auth.sent.change.password.hint": "Reset password link has been sent.",
"com.affine.auth.sent.reset.password.success.message": "Your password has upgraded! You can sign in AFFiNE Cloud with new password!",
@@ -951,7 +953,8 @@
"com.affine.settings.auto-check-description": "If enabled, it will automatically check for new versions at regular intervals.",
"com.affine.settings.auto-download-description": " If enabled, new versions will be automatically downloaded to the current device.",
"com.affine.settings.email": "Email",
"com.affine.settings.email.action": "Change Email",
"com.affine.settings.email.action.change": "Change Email",
"com.affine.settings.email.action.verify": "Verify Email",
"com.affine.settings.member-tooltip": "Enable AFFiNE Cloud to collaborate with others",
"com.affine.settings.noise-style": "Noise background on the sidebar",
"com.affine.settings.noise-style-description": "Use background noise effect on the sidebar.",

View File

@@ -406,7 +406,7 @@
"com.affine.appearanceSettings.windowFrame.description": "Personnalisez l'apparence de l'application Windows",
"com.affine.appearanceSettings.windowFrame.frameless": "Sans Bords",
"com.affine.appearanceSettings.windowFrame.title": "Style de fenêtre",
"com.affine.auth.change.email.message": "Votre email actuel est {{email}}. Nous enverrons un lien de vérification temporaire à cette addresse.",
"com.affine.auth.verify.email.message": "Votre email actuel est {{email}}. Nous enverrons un lien de vérification temporaire à cette addresse.",
"com.affine.auth.change.email.page.subtitle": "Rentrez votre nouvelle adresse mail en dessous. Nous enverrons un lien de vérification à cette adresse mail pour compléter le processus",
"com.affine.auth.change.email.page.success.subtitle": "Félicitation! Vous avez réussi à mettre à jour votre adresse mail associé avec votre compte AFFiNE cloud ",
"com.affine.auth.change.email.page.success.title": "Adresse mail mise à jour !",
@@ -430,11 +430,11 @@
"com.affine.auth.reset.password.message": "Vous allez recevoir un mail avec un lien pour réinitialiser votre mot de passe. Merci de vérifier votre boite de réception",
"com.affine.auth.reset.password.page.success": "Mot de passe réinitialisé avec succès",
"com.affine.auth.reset.password.page.title": "Réinitialiser votre mot de passe AFFiNE Cloud",
"com.affine.auth.send.change.email.link": "Envoyer un lien de vérification",
"com.affine.auth.send.verify.email.hint": "Envoyer un lien de vérification",
"com.affine.auth.send.reset.password.link": "Envoyer un lien de réinitialisation",
"com.affine.auth.send.set.password.link": "Envoyer un lien pour définir votre mot de passe",
"com.affine.auth.sent": "Envoyé",
"com.affine.auth.sent.change.email.hint": "Le lien de vérification a été envoyé",
"com.affine.auth.sent.verify.email.hint": "Le lien de vérification a été envoyé",
"com.affine.auth.sent.change.password.hint": "Le lien de réinitialisation de mot de passe a été envoyé",
"com.affine.auth.sent.reset.password.success.message": "Votre mot de passe a été changé! Vous pouvez à nouveau vous connecter à AFFiNE Cloud avec votre nouveau mot de passe ! ",
"com.affine.auth.sent.set.password.hint": "Le lien pour définir votre mot de passe à été envoyé",
@@ -788,7 +788,7 @@
"com.affine.settings.auto-check-description": "Si activé, l'option cherchera automatiquement pour les nouvelles versions à intervalles réguliers",
"com.affine.settings.auto-download-description": "Si activé, les nouvelles versions seront automatiquement téléchargées sur l'appareil actuel",
"com.affine.settings.email": "Email",
"com.affine.settings.email.action": "Changer l'Email",
"com.affine.settings.email.action.change": "Changer l'Email",
"com.affine.settings.member-tooltip": "Activer AFFiNE Cloud pour collaborer avec d'autres personnes",
"com.affine.settings.noise-style": "Bruit d'arrière-plan de la barre latérale",
"com.affine.settings.noise-style-description": "Utiliser l'effet de bruit d'arrière-plan sur la barre latérale",

View File

@@ -406,7 +406,7 @@
"com.affine.appearanceSettings.windowFrame.description": "Windows 클라이언트의 모양을 사용자 정의합니다.",
"com.affine.appearanceSettings.windowFrame.frameless": "프레임 없이",
"com.affine.appearanceSettings.windowFrame.title": "윈도우 프레임 스타일",
"com.affine.auth.change.email.message": "현재 이메일은 {{email}}입니다. 이 이메일 주소로 임시 인증 링크를 보내 드리겠습니다.",
"com.affine.auth.verify.email.message": "현재 이메일은 {{email}}입니다. 이 이메일 주소로 임시 인증 링크를 보내 드리겠습니다.",
"com.affine.auth.change.email.page.subtitle": "아래에 새 이메일 주소를 입력하세요. 절차를 완료하기 위해 이 이메일 주소로 인증 링크를 보내드립니다.",
"com.affine.auth.change.email.page.success.subtitle": "축하합니다! AFFiNE Cloud 계정과 연결된 이메일 주소를 성공적으로 업데이트했습니다.",
"com.affine.auth.change.email.page.success.title": "이메일 주소를 업데이트했습니다!",
@@ -430,11 +430,11 @@
"com.affine.auth.reset.password.message": "비밀번호를 재설정할 수 있는 링크가 포함된 이메일을 받게 됩니다. 받은 편지함을 확인해 주세요.",
"com.affine.auth.reset.password.page.success": "비밀번호 재설정 성공",
"com.affine.auth.reset.password.page.title": "AFFiNE Cloud 비밀번호 재설정",
"com.affine.auth.send.change.email.link": "인증 링크 전송",
"com.affine.auth.send.verify.email.hint": "인증 링크 전송",
"com.affine.auth.send.reset.password.link": "재설정 링크 전송",
"com.affine.auth.send.set.password.link": "설정 링크 전송",
"com.affine.auth.sent": "보냄",
"com.affine.auth.sent.change.email.hint": "인증 링크를 보냈습니다.",
"com.affine.auth.sent.verify.email.hint": "인증 링크를 보냈습니다.",
"com.affine.auth.sent.change.password.hint": "비밀번호 재설정 링크를 보냈습니다.",
"com.affine.auth.sent.reset.password.success.message": "비밀번호가 업그레이드했습니다! 새 비밀번호로 AFFiNE Cloud에 로그인할 수 있습니다!",
"com.affine.auth.sent.set.password.hint": "비밀번호 설정 링크를 보냈습니다.",
@@ -908,7 +908,7 @@
"com.affine.settings.auto-check-description": "이 기능을 활성화하면, 정기적으로 새 버전을 자동으로 확인합니다.",
"com.affine.settings.auto-download-description": "이 기능을 활성화하면, 새 버전이 현재 디바이스에 자동으로 다운로드됩니다.",
"com.affine.settings.email": "이메일",
"com.affine.settings.email.action": "이메일 변경",
"com.affine.settings.email.action.change": "이메일 변경",
"com.affine.settings.member-tooltip": "다른 사람들과 협업할 수 있는 AFFiNE Cloud 활성화",
"com.affine.settings.noise-style": "Noise background on the sidebar",
"com.affine.settings.noise-style-description": "Use background noise effect on the sidebar.",

View File

@@ -337,11 +337,11 @@
"com.affine.auth.reset.password": "Redefinir Senha",
"com.affine.auth.reset.password.message": "Você receberá um email com um link para redefinir sua senha. Por favor verifique sua caixa de entrada.",
"com.affine.auth.reset.password.page.title": "Redefina sua senha da AFFiNE Cloud",
"com.affine.auth.send.change.email.link": "Envie um link de verificação",
"com.affine.auth.send.verify.email.hint": "Envie um link de verificação",
"com.affine.auth.send.reset.password.link": "Enviar link de redefinição",
"com.affine.auth.send.set.password.link": "Enviar link de definição",
"com.affine.auth.sent": "Enviado",
"com.affine.auth.sent.change.email.hint": "Link de verificação foi enviado.",
"com.affine.auth.sent.verify.email.hint": "Link de verificação foi enviado.",
"com.affine.auth.sent.change.password.hint": "Link de redefinição de senha foi enviado.",
"com.affine.auth.set.email.save": "Salvar Email",
"com.affine.auth.set.password.page.title": "Defina sua senha para AFFiNE Cloud",
@@ -422,7 +422,7 @@
"com.affine.settings.auto-check-description": "Se ativado, ele verificará automaticamente novas versões em intervalos regulares.",
"com.affine.settings.auto-download-description": "Se ativado, novas versões serão baixadas automaticamente para o dispositivo atual.",
"com.affine.settings.email": "Email",
"com.affine.settings.email.action": "Mudar Email",
"com.affine.settings.email.action.change": "Mudar Email",
"com.affine.settings.password": "Senha",
"com.affine.settings.password.action.change": "Mudar senha",
"com.affine.settings.profile": "Meu Perfil",

View File

@@ -318,10 +318,10 @@
"com.affine.auth.reset.password": "Восстановить пароль",
"com.affine.auth.reset.password.message": "Вы получите письмо со ссылкой для восстановления пароля. Пожалуйста, проверьте свой почтовый ящик.",
"com.affine.auth.reset.password.page.title": "Восстановить пароль AFFiNE Cloud",
"com.affine.auth.send.change.email.link": "Отправить ссылку для подтверждения",
"com.affine.auth.send.verify.email.hint": "Отправить ссылку для подтверждения",
"com.affine.auth.send.reset.password.link": "Отправить ссылку для восстановления",
"com.affine.auth.sent": "Отправлено",
"com.affine.auth.sent.change.email.hint": "Ссылка для подтверждения отправлена.",
"com.affine.auth.sent.verify.email.hint": "Ссылка для подтверждения отправлена.",
"com.affine.auth.sent.change.password.hint": "Ссылка для восстановления пароля отправлена.",
"com.affine.auth.sent.set.password.hint": "Ссылка для установки пароля отправлена.",
"com.affine.auth.set.email.save": "Сохранить электронную почту",

View File

@@ -394,7 +394,7 @@
"com.affine.appearanceSettings.windowFrame.description": "自定义 Windows 客户端外观。",
"com.affine.appearanceSettings.windowFrame.frameless": "无边框",
"com.affine.appearanceSettings.windowFrame.title": "视窗样式",
"com.affine.auth.change.email.message": "您当前的邮箱是 {{email}}。我们将向此邮箱发送一个临时的验证链接。",
"com.affine.auth.verify.email.message": "您当前的邮箱是 {{email}}。我们将向此邮箱发送一个临时的验证链接。",
"com.affine.auth.change.email.page.subtitle": "请在下方输入您的新电子邮件地址。我们将把验证链接发送至该电子邮件地址以完成此过程。",
"com.affine.auth.change.email.page.success.subtitle": "恭喜!您已更新了与 AFFiNE Cloud 账户关联的电子邮件地址。",
"com.affine.auth.change.email.page.success.title": "邮箱地址已更新!",
@@ -418,11 +418,11 @@
"com.affine.auth.reset.password.message": "您将收到一封电子邮件,以便重置密码。请在收件箱中查收。",
"com.affine.auth.reset.password.page.success": "密码重置成功",
"com.affine.auth.reset.password.page.title": "重置您的 AFFiNE Cloud 密码",
"com.affine.auth.send.change.email.link": "发送验证链接",
"com.affine.auth.send.verify.email.hint": "发送验证链接",
"com.affine.auth.send.reset.password.link": "发送重置链接",
"com.affine.auth.send.set.password.link": "发送设置链接",
"com.affine.auth.sent": "已发送",
"com.affine.auth.sent.change.email.hint": "验证链接已发送",
"com.affine.auth.sent.verify.email.hint": "验证链接已发送",
"com.affine.auth.sent.change.password.hint": "重置密码链接已发送。",
"com.affine.auth.sent.reset.password.success.message": "您的密码已更新!您可以使用新密码登录 AFFiNE Cloud",
"com.affine.auth.sent.set.password.hint": "设置密码链接已发送。",
@@ -821,7 +821,8 @@
"com.affine.settings.auto-check-description": "如果启用,它将定期自动检查新版本。",
"com.affine.settings.auto-download-description": "如果启用,新版本将自动下载到当前设备。",
"com.affine.settings.email": "电子邮件",
"com.affine.settings.email.action": "更改邮箱",
"com.affine.settings.email.action.change": "更改邮箱",
"com.affine.settings.email.action.verify": "验证邮箱",
"com.affine.settings.member-tooltip": "启用 AFFiNE Cloud 以与他人协作",
"com.affine.settings.noise-style": "侧边栏的噪点背景",
"com.affine.settings.noise-style-description": "在侧边栏使用噪点背景效果。",

View File

@@ -336,11 +336,11 @@
"com.affine.auth.reset.password": "重設密碼",
"com.affine.auth.reset.password.message": "您將收到一封電子郵件,其中包含重設密碼的連結。請檢查您的收件箱。",
"com.affine.auth.reset.password.page.title": "重設您的 AFFiNE Cloud 密碼",
"com.affine.auth.send.change.email.link": "發送驗證連結",
"com.affine.auth.send.verify.email.hint": "發送驗證連結",
"com.affine.auth.send.reset.password.link": "發送重設連結",
"com.affine.auth.send.set.password.link": "發送設定連結",
"com.affine.auth.sent": "已發送",
"com.affine.auth.sent.change.email.hint": "驗證連結已發送。",
"com.affine.auth.sent.verify.email.hint": "驗證連結已發送。",
"com.affine.auth.sent.change.password.hint": "重設密碼連結已發送。",
"com.affine.auth.sent.set.password.hint": "設定密碼連結已發送。",
"com.affine.auth.set.email.save": "保存電子郵件地址",
@@ -438,7 +438,8 @@
"com.affine.settings.auto-check-description": "若啟用,將定期自動檢測新版本。",
"com.affine.settings.auto-download-description": "若啟用,將自動下載新版本。",
"com.affine.settings.email": "電子郵件地址",
"com.affine.settings.email.action": "更改電子郵件地址",
"com.affine.settings.email.action.change": "更改電子郵件地址",
"com.affine.settings.email.action.verify": "验证電子郵件地址",
"com.affine.settings.member-tooltip": "啟用 AFFiNE Cloud 以與他人協作",
"com.affine.settings.noise-style": "側欄背景雜訊效果",
"com.affine.settings.noise-style-description": "在側欄背景使用雜訊效果。",