Skip to content

Commit

Permalink
feat(auth): added user registration
Browse files Browse the repository at this point in the history
  • Loading branch information
CorentinTh committed Dec 29, 2024
1 parent dbc52a6 commit 705fcbf
Show file tree
Hide file tree
Showing 40 changed files with 2,381 additions and 1,639 deletions.
8 changes: 4 additions & 4 deletions packages/app-client/src/locales/ar.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@
"invalid-credentials": "البريد الإلكتروني أو كلمة المرور غير صحيحة.",
"unknown": "حدث خطأ غير معروف. يرجى المحاولة مرة أخرى لاحقًا."
},
"footer": [
"ليس لديك حساب؟",
"اتصل بمالك النسخة."
]
"footer": {
"no-account": "ليس لديك حساب؟",
"register": "التسجيل"
}
},
"create": {
"errors": {
Expand Down
8 changes: 4 additions & 4 deletions packages/app-client/src/locales/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@
"invalid-credentials": "Ungültige E-Mail oder ungültiges Passwort.",
"unknown": "Ein unbekannter Fehler ist aufgetreten. Bitte versuchen Sie es später noch einmal."
},
"footer": [
"Sie haben keinen Account?",
"Kontaktieren Sie den Besitzer der Instanz."
]
"footer": {
"no-account": "Sie haben keinen Account?",
"register": "Registrieren"
}
},
"create": {
"errors": {
Expand Down
27 changes: 23 additions & 4 deletions packages/app-client/src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,31 @@
"submit": "Login",
"errors": {
"invalid-credentials": "Invalid email or password.",
"invalid-request": "Invalid credentials format. Please check your email and password.",
"unknown": "An unknown error occurred. Please try again later."
},
"footer": [
"Don't have an account?",
"Contact the owner of the instance."
]
"footer": {
"no-account": "Don't have an account?",
"register": "Register"
}
},
"register": {
"title": "Register to Enclosed",
"description": "This is a private instance of Enclosed. Create an account to be able to create notes.",
"registration-disabled": "Registration is disabled on this instance. Please contact the administrator for more information.",
"email": "Email",
"password": "Password",
"submit": "Register",
"errors": {
"password-too-short": "The password is too short. It must be at least 8 characters long.",
"email-taken": "The email address is already in use.",
"invalid-request": "Invalid credentials format. Please check your email and password.",
"unknown": "An unknown error occurred. Please try again later."
},
"footer": {
"have-account": "Already have an account?",
"login": "Login"
}
},
"create": {
"errors": {
Expand Down
8 changes: 4 additions & 4 deletions packages/app-client/src/locales/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@
"invalid-credentials": "Correo electrónico o contraseña incorrectos.",
"unknown": "Ocurrió un error desconocido. Por favor, inténtelo de nuevo más tarde."
},
"footer": [
"¿No tienes una cuenta?",
"Contacta al propietario de la instancia."
]
"footer": {
"no-account": "¿No tienes una cuenta?",
"register": "Registrarse"
}
},
"create": {
"errors": {
Expand Down
26 changes: 22 additions & 4 deletions packages/app-client/src/locales/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,28 @@
"invalid-credentials": "Email ou mot de passe invalide.",
"unknown": "Une erreur inconnue est survenue. Veuillez réessayer plus tard."
},
"footer": [
"Vous n'avez pas de compte ?",
"Contactez le propriétaire de l'instance."
]
"footer": {
"no-account": "Vous n'avez pas de compte?",
"register": "S'inscrire"
}
},
"register": {
"title": "Inscription à Enclosed",
"description": "Ceci est une instance privée de Enclosed. Créez un compte pour pouvoir créer des notes.",
"registration-disabled": "La création de compte est désactivée sur cette instance. Veuillez contacter l'administrateur pour plus d'informations.",
"email": "Email",
"password": "Mot de passe",
"submit": "S'inscrire",
"errors": {
"password-too-short": "Le mot de passe est trop court. Il doit comporter au moins 8 caractères.",
"email-taken": "L'adresse email est déjà utilisée.",
"invalid-request": "Format de l'adresse email ou du mot de passe invalide. Veuillez vérifier vos identifiants.",
"unknown": "Une erreur inconnue est survenue. Veuillez réessayer plus tard."
},
"footer": {
"have-account": "Vous avez déjà un compte?",
"login": "Se connecter"
}
},
"create": {
"errors": {
Expand Down
8 changes: 4 additions & 4 deletions packages/app-client/src/locales/hu.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@
"invalid-credentials": "Érvénytelen e-mail vagy jelszó.",
"unknown": "Ismeretlen hiba történt. Kérjük, próbálkozz később újra."
},
"footer": [
"Nincs fiókod?",
"Vedd fel a kapcsolatot az Enclosed privát példányának tulajdonosával."
]
"footer": {
"no-account": "Nincs fiókod?",
"register": "Regisztráció"
}
},
"create": {
"errors": {
Expand Down
8 changes: 4 additions & 4 deletions packages/app-client/src/locales/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@
"invalid-credentials": "Email o password non validi.",
"unknown": "Errore sconosciuto. Riprova più tardi."
},
"footer": [
"Non hai un account?",
"Contatta il proprietario dell'istanza."
]
"footer": {
"no-account": "Non hai un account?",
"register": "Registrati"
}
},
"create": {
"errors": {
Expand Down
8 changes: 4 additions & 4 deletions packages/app-client/src/locales/nl.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@
"invalid-credentials": "Ongeldig e-mailadres of wachtwoord.",
"unknown": "Er is een onbekende fout opgetreden. Probeer het later nog eens."
},
"footer": [
"Heb je geen account?",
"Neem contact op met de eigenaar van de instantie."
]
"footer": {
"no-account": "Heb je geen account?",
"register": "Registreren"
}
},
"create": {
"errors": {
Expand Down
8 changes: 4 additions & 4 deletions packages/app-client/src/locales/pl.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@
"invalid-credentials": "Nieprawidłowy e-mail lub hasło.",
"unknown": "Wystąpił nieznany błąd. Spróbuj ponownie później."
},
"footer": [
"Nie masz konta?",
"Skontaktuj się z właścicielem instancji."
]
"footer": {
"no-account": "Nie masz konta?",
"register": "Zarejestruj się"
}
},
"create": {
"errors": {
Expand Down
8 changes: 4 additions & 4 deletions packages/app-client/src/locales/pt-BR.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@
"invalid-credentials": "E-mail ou senha inválidos.",
"unknown": "Ocorreu um erro. Tente novamente mais tarde."
},
"footer": [
"Não tem uma conta?",
"Entre em contato com o dono da instância."
]
"footer": {
"no-account": "Não tem uma conta?",
"register": "Registrar"
}
},
"create": {
"errors": {
Expand Down
5 changes: 4 additions & 1 deletion packages/app-client/src/locales/pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,10 @@
"invalid-credentials": "Email ou palavra-passe inválidos.",
"unknown": "Ocorreu um erro. Tenta outra vez mais tarde."
},
"footer": ["Não tens conta?", "Contacta o criador da instância."]
"footer": {
"no-account": "Não tens conta?",
"register": "Registar"
}
},
"create": {
"errors": {
Expand Down
8 changes: 4 additions & 4 deletions packages/app-client/src/locales/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@
"invalid-credentials": "Неверный адрес электронной почты или пароль.",
"unknown": "Неизвестная ошибка. Пожалуйста, повторите попытку позже."
},
"footer": [
"Нет учётной записи?",
"Связаться с владельцем"
]
"footer": {
"no-account": "Нет учётной записи?",
"register": "Зарегистрироваться"
}
},
"create": {
"errors": {
Expand Down
5 changes: 4 additions & 1 deletion packages/app-client/src/locales/tr.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@
"invalid-credentials": "Geçersiz e-posta veya şifre.",
"unknown": "Bilinmeyen bir hata oluştu. Lütfen daha sonra tekrar deneyin."
},
"footer": ["Hesabınız yok mu?", "Bu sistemin sahibine ulaşın."]
"footer": {
"no-account": "Hesabınız yok mu?",
"register": "Kayıt ol"
}
},
"create": {
"errors": {
Expand Down
8 changes: 4 additions & 4 deletions packages/app-client/src/locales/vi.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@
"invalid-credentials": "Email hoặc mật khẩu không hợp lệ.",
"unknown": "Đã xảy ra lỗi không xác định. Vui lòng thử lại sau."
},
"footer": [
"Bạn chưa có tài khoản?",
"Liên hệ với chủ sở hữu của phiên bản."
]
"footer": {
"no-account": "Bạn chưa có tài khoản?",
"register": "Đăng ký"
}
},
"create": {
"errors": {
Expand Down
5 changes: 4 additions & 1 deletion packages/app-client/src/locales/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,10 @@
"invalid-credentials": "无效的电子邮箱或密码。",
"unknown": "发生未知错误,稍后再试。"
},
"footer": ["没有账户?", "联系实例的拥有者。"]
"footer": {
"no-account": "没有账户?",
"register": "注册"
}
},
"create": {
"errors": {
Expand Down
8 changes: 4 additions & 4 deletions packages/app-client/src/locales/zh-TW.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@
"invalid-credentials": "無效的電子郵件或密碼。",
"unknown": "發生未知錯誤。請稍後再試。"
},
"footer": [
"沒有帳戶嗎?",
"聯繫網站擁有者。"
]
"footer": {
"no-account": "沒有帳戶嗎?",
"register": "註冊"
}
},
"create": {
"errors": {
Expand Down
15 changes: 14 additions & 1 deletion packages/app-client/src/modules/auth/auth.services.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { apiClient } from '../shared/http/http-client';

export { login };
export { login, register };

async function login({ email, password }: { email: string; password: string }) {
const { accessToken } = await apiClient<{ accessToken: string }>({
Expand All @@ -14,3 +14,16 @@ async function login({ email, password }: { email: string; password: string }) {

return { accessToken };
}

async function register({ email, password }: { email: string; password: string }) {
const { accessToken } = await apiClient<{ accessToken: string }>({
path: 'api/auth/register',
method: 'POST',
body: {
email,
password,
},
});

return { accessToken };
}
Loading

0 comments on commit 705fcbf

Please sign in to comment.