feat : middleware and refresh token

This commit is contained in:
Yusron alamsyah
2026-04-06 13:55:31 +07:00
parent d438fb0f5f
commit 4325bae76f
16 changed files with 1127 additions and 476 deletions
-2
View File
@@ -12,8 +12,6 @@ const clearLocalAuthStorage = () => {
localStorage.removeItem('accessToken');
localStorage.removeItem('refreshToken');
localStorage.removeItem('user-preferences');
localStorage.removeItem('app-state');
sessionStorage.clear();
};
+6
View File
@@ -8,6 +8,11 @@ export const useValidation = () => {
return (value !== null && value !== undefined && String(value).trim() !== '') || message;
};
const emailRules = (value, message = 'Email tidak valid.') => {
if (!value) return true;
return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(value) || message;
};
const minNameLength = (value, minLength = 3) => {
if (!value) return true; // Lewati jika kosong (handle oleh 'required')
const length = value.trim().length; // Hitung panjang setelah menghapus spasi di awal/akhir
@@ -51,6 +56,7 @@ export const useValidation = () => {
return {
required,
emailRules,
isNumber,
phoneLength,
indonesianPhoneFormat,