@davoodmehraban89 / Factor-easy-2 Mirror · read-only / commits / d712c34
Fork 0

سامانه صدور فاکتور و حسابداری

Mirrored from https://github.com/davoodmehraban89/Factor-easy.git

Synced Dec 3, 17:00 UTC

Keep complete login visible on short screens

davoodmehraban89 committed Oct 28, 2026 at 16:51 UTC d712c347a0576e103f7c63cbfd633b6665a4ba43
5 files changed +80 -5
PROJECT_STATE.md
+9
@@ -152,3 +152,12 @@
152 - Plan: first add a meaningful held-recovery-request browser regression, observe it fail against unchanged main, then package the exact recovery IIFE before core in the existing preloaded core request in the generated Pages artifact. Preserve static-handler-before-core order, recovery URL sanitization before SDK/session initialization and all recovery validation/tenant guards. Hash combined bytes for both preload and script so old core cannot pair with new HTML. Keep canonical source files, source execution order, account transport, stored data and production backend unchanged. Run targeted generated login/recovery suites, all existing checks/Golden/full browser suite, independent review and exact-head protected release checks. Actual affected-device login remains NOT VERIFIED and Issue106 stays open.
153 - **Implemented and verified locally2026-10-28:** both new regressions failed against unchanged main for the intended reasons (disabled login while recovery download is held; stale core content version). Generated Pages now prepends the processed recovery IIFE to the existing preloaded core request, removes only its separate script tag and uses the complete-content SHA for both core references. No canonical runtime JavaScript or backend configuration changed. Full existing Quality browser command **184/184 PASS(3.8m)**, targeted startup plus full generated strict-CSP recovery **28/28 PASS(13.2s)**, all **51** existing static/behavioral/server/release-safety commands PASS including **45/45** server cases and Golden; diff check PASS. The initial input-driven attempt encountered the previously known local WOFF2/fontconfig issue, independently reproduced even on a standalone blank input; the final runs use only a process-local fontconfig exclusion, with no repository/CI/font/test-assertion change. Previous interrupted full-suite output was not counted; the complete rerun is persisted outside git.
154 - **Independent application/security review:** no critical/important/minor findings; generated artifact order/hash verified and three additional synthetic SDK-boundary probes PASS (ordinary entry; valid recovery with another cached identity; invalid recovery Cancel preserving that identity). Concatenation's hoisted showAuthPanel is DOM-only and safe; URL sanitization and active guard still precede SDK initialization. Owner-network DNS/TLS/login acceptance, real password/email operations, physical printing and production two-user use remain NOT VERIFIED. Publish this scoped repair through its own protected PR; later exact PR/main SHA, CI/gate/Pages and public readback evidence belongs in the PR description, because those identifiers are created after this commit. No new real mail/account/password/financial write or Supabase production schema/Auth/DNS change occurred; rollback is reverting this build/test-only repair.
155 +
156 +### 2026-10-28 — Forgot Password placement below both login actions
157 +- Owner requests that the existing Forgot Password control appear below both password and email-code login actions. Fresh protected main b02a7a7716da07fb0b8bb75d3e393396152908a1 is the released PR185 repair. Scope: relocate only the existing button in index.html after auth-actions and use its existing10px spacing above it; preserve all IDs, handlers, text, Auth/recovery/accounting behavior and the verified combined auth build. Isolated branch fix/login-forgot-position-20261028; no new dependency, SQL, backend or real account/mail/password operation. Verify existing login/recovery checks and actual generated desktop/mobile visual order, then publish through the protected PR/release pipeline under existing owner release authorization.
158 +
159 +### 2026-10-28 — Owner login acceptance and short-screen login layout
160 +- Owner now reports that the site opened and they successfully signed in on their computer. This is owner-reported login acceptance after PR185, not proof that all prior intermittent DNS/TLS failures are resolved. Preserve the independent network evidence and Issue106 history.
161 +- Owner screenshots show the login heading cropped above the viewport on a laptop. Extend the current login-presentation fix with responsive vertical spacing and safe overflow from the beginning of the form, including short desktops, mobile and reduced CSS viewports under zoom. Preserve all buttons, readable fields, existing brand, normal/recovery authentication and financial behavior. Reproduce with bounding-box/scroll tests before CSS changes, verify source and generated strict-CSP Pages. Moving static buttons also requires verifying generated-handler cache identity so old cached handlers cannot bind to a new DOM order.
162 +- Separate new requests remain active: investigate company Edit being unavailable with a real rendered-button test; prepare owner-requested direct password assignment in central users/licenses, restricted to the existing global software-admin role. Organization managers retain recovery-link scope. These are separate scoped fixes, with no production account/password mutation authorized by testing the feature. Production Auth-function activation requires the existing separate explicit approval boundary after a concrete reviewed result.
163 +- **Local verification complete2026-10-28:** the new height/scroll browser cases reproduced clipped top at `920×600`, `1024×600`, `1366×650` and lost scroll start at a short desktop before CSS repair. Compact desktop login layout and scroll-from-top now pass source and generated Pages at desktop `920×600`, `1024×600`, `1366×650`, overflow desktop `1024×450`, `680×400` and mobile `390×568`. Full existing browser workflow **191/191 PASS**, generated focused startup/recovery/branding **37/37 PASS**, all **51** static/behavioral/server/release-safety checks PASS including **45/45** server cases and Golden, and diff check PASS. The separate handler-version regression failed on unmodified main because its URL had no content version; generated Pages now use SHA-256 of the generated handler source, and the test confirms the exact downloaded script matches that URL hash and normal synthetic login executes once. The owner has reported a successful site login before this presentation update; post-publication physical-device viewport and intermittent owner-network behavior remain NOT VERIFIED. No account/password, Auth, configuration, SQL, RLS, financial data or dependency change occurred in this presentation PR.
index.html
+10 -3
@@ -23,8 +23,8 @@
23 html,body{width:100%;max-width:100%;overflow-x:hidden!important;position:relative}
24 *{box-sizing:border-box;margin:0;padding:0;font-family:'Vazirmatn FD',-apple-system,BlinkMacSystemFont,Tahoma,sans-serif;-webkit-tap-highlight-color:transparent}
25 body{background-color:var(--bg);color:var(--text);font-size:14px}
26 -#auth-screen{position:fixed;inset:0;background:radial-gradient(circle at 14% 12%,rgba(71,153,255,.18),transparent 32%),linear-gradient(135deg,#f8fbff 0%,#eef4ff 48%,#e8f1ff 100%);z-index:9999;display:flex;align-items:center;justify-content:center;padding:clamp(14px,3vw,42px);overflow:auto}
27 -.auth-shell{width:min(1180px,100%);min-height:min(760px,calc(100vh - 56px));display:grid;grid-template-columns:minmax(420px,.94fr) minmax(480px,1.06fr);background:#fff;border:1px solid rgba(148,163,184,.22);border-radius:32px;overflow:hidden;box-shadow:0 34px 90px rgba(15,42,91,.18),0 8px 28px rgba(37,99,235,.08)}
26 +#auth-screen{position:fixed;inset:0;background:radial-gradient(circle at 14% 12%,rgba(71,153,255,.18),transparent 32%),linear-gradient(135deg,#f8fbff 0%,#eef4ff 48%,#e8f1ff 100%);z-index:9999;display:flex;align-items:flex-start;justify-content:center;padding:clamp(14px,3vw,42px);overflow:auto}
27 +.auth-shell{width:min(1180px,100%);flex-shrink:0;margin-block:auto;min-height:min(760px,calc(100vh - 56px));display:grid;grid-template-columns:minmax(0,.94fr) minmax(0,1.06fr);background:#fff;border:1px solid rgba(148,163,184,.22);border-radius:32px;overflow:hidden;box-shadow:0 34px 90px rgba(15,42,91,.18),0 8px 28px rgba(37,99,235,.08)}
28 .auth-card{background:linear-gradient(180deg,#fff,#fbfdff);width:100%;padding:clamp(32px,5vw,68px);text-align:right;display:flex;flex-direction:column;justify-content:center}
29 .auth-brand{display:flex;align-items:center;gap:14px;margin-bottom:28px}.auth-brand-logo{width:58px;height:58px;border-radius:16px;box-shadow:0 12px 28px rgba(24,94,214,.22);flex:none}.auth-brand h1{font-size:24px;color:#0b1739;letter-spacing:-.5px}.auth-brand p{font-size:12px;color:#64748b;margin-top:3px}
30 .auth-card .form-group label{color:#334155}.auth-card .form-control{min-height:50px;border-radius:12px;border-color:#dbe4f0;background:#fff;padding:10px 14px}.auth-card .form-control:focus{border-color:#2b75ff;box-shadow:0 0 0 4px rgba(43,117,255,.10)}
@@ -35,6 +35,13 @@ body{background-color:var(--bg);color:var(--text);font-size:14px}
35 .auth-hero{width:min(470px,100%);text-align:center;display:flex;flex-direction:column;align-items:center}.auth-hero-logo{width:96px;height:96px;border-radius:25px;box-shadow:0 22px 48px rgba(0,0,0,.28);margin-bottom:18px}.auth-hero h2{font-family:Arial,sans-serif;font-size:52px;letter-spacing:-1.5px;line-height:1}.auth-hero .erp{font-family:Arial,sans-serif;font-size:13px;letter-spacing:6px;color:#c9dcff;margin-top:8px}.auth-hero .tagline{font-size:14px;color:#d9e7ff;margin-top:22px}
36 .auth-dashboard-art{width:100%;height:260px;margin-top:34px;position:relative;perspective:900px}.auth-glass{position:absolute;border:1px solid rgba(118,210,255,.58);background:linear-gradient(145deg,rgba(65,152,255,.18),rgba(4,36,105,.28));box-shadow:inset 0 0 30px rgba(65,192,255,.08),0 25px 50px rgba(0,0,0,.18);backdrop-filter:blur(7px)}.auth-glass-main{right:9%;left:12%;top:18px;bottom:0;border-radius:22px;transform:rotateY(-8deg)}.auth-glass-side{right:0;width:76px;top:0;bottom:18px;border-radius:18px;display:flex;flex-direction:column;gap:14px;align-items:center;justify-content:center}.auth-glass-side span{width:34px;height:34px;border-radius:10px;background:rgba(88,185,255,.24);display:grid;place-items:center;color:#8be8ff}.auth-chart{position:absolute;left:21%;right:22%;top:80px;height:95px;border-left:1px solid rgba(139,232,255,.24);border-bottom:1px solid rgba(139,232,255,.24)}.auth-chart:after{content:"";position:absolute;inset:12px 6px 8px;background:linear-gradient(135deg,transparent 0 18%,#39c8ff 19% 21%,transparent 22% 37%,#39c8ff 38% 40%,transparent 41% 58%,#39c8ff 59% 61%,transparent 62% 76%,#39c8ff 77% 79%,transparent 80%);filter:drop-shadow(0 0 6px #27bfff)}
37 @media(max-width:900px){.auth-shell{grid-template-columns:1fr;min-height:0;max-width:560px}.auth-visual{display:none}.auth-card{padding:32px 24px}.auth-brand{justify-content:center;text-align:center}.auth-actions{grid-template-columns:1fr}#auth-screen{align-items:flex-start}.auth-card{min-height:calc(100vh - 28px)}}
38 +@media(min-width:901px) and (max-height:800px){
39 +#auth-screen{padding:8px 20px}.auth-shell{min-height:0}.auth-card{padding:12px 24px;line-height:1.5}
40 +.auth-brand{gap:10px;margin-bottom:8px}.auth-brand-logo{width:44px;height:44px;border-radius:12px}.auth-brand h1{font-size:20px;line-height:1.3}
41 +.auth-card .form-group{margin-bottom:8px}.auth-card .form-group label{margin-bottom:4px}.auth-card .form-control{min-height:44px;padding:8px 12px}
42 +.auth-google{min-height:44px;margin-bottom:4px}.auth-divider{margin:4px 0 6px}.auth-actions{margin-top:6px}.auth-actions .btn{min-height:44px}.auth-note{margin-top:8px;line-height:1.5}#auth-connectivity-result:empty{display:none}
43 +.auth-visual{padding:28px}.auth-hero-logo{width:72px;height:72px;margin-bottom:12px}.auth-hero h2{font-size:42px}.auth-hero .tagline{margin-top:16px}.auth-dashboard-art{height:180px;margin-top:20px}
44 +}
45 .app-root{display:flex;min-height:100vh;width:100%;max-width:100%;overflow-x:hidden}
46 .sidebar{width:var(--sidebar-w);background:var(--card-bg);border-left:1px solid var(--border);display:flex;flex-direction:column;position:fixed;top:0;bottom:0;right:0;z-index:100}
47 .brand-box{padding:20px;display:flex;align-items:center;gap:12px;border-bottom:1px solid var(--border)}
@@ -234,11 +241,11 @@ body{background:#f6f9fc}
241 <div class="auth-divider">یا با ایمیل</div>
242 <div class="form-group"><label>ایمیل</label><input type="email" id="auth-email" class="form-control" placeholder="name@example.com" autocomplete="email" autocapitalize="none" dir="ltr" /></div>
243 <div class="form-group"><label>رمز عبور</label><input type="password" id="auth-password" class="form-control" placeholder="رمز عبور" autocomplete="current-password" dir="ltr" /></div>
237 - <button disabled type="button" id="auth-forgot-password" class="btn btn-secondary" style="width:100%;margin-bottom:10px" onclick="finoraRequestPasswordRecovery()">فراموشی رمز عبور</button>
244 <div class="auth-actions">
245 <button id="auth-login-button" class="btn btn-primary" onclick="handleLogin()" disabled>ورود با رمز</button>
246 <button disabled class="btn btn-secondary" onclick="startEmailOtp(false,false)">ورود با کد ایمیل</button>
247 </div>
248 + <button disabled type="button" id="auth-forgot-password" class="btn btn-secondary" style="width:100%;margin-top:10px" onclick="finoraRequestPasswordRecovery()">فراموشی رمز عبور</button>
249 <p id="auth-login-status" aria-live="polite" data-state="loading" style="font-size:12px;line-height:1.9;margin-top:8px;min-height:24px;color:#475569">در حال آماده‌سازی فرم ورود...</p>
250 <button disabled type="button" id="auth-connectivity-check" class="btn btn-secondary" style="width:100%;margin-top:10px" onclick="checkAuthConnectivity()">بررسی اتصال به سرور ورود</button>
251 <p id="auth-connectivity-result" aria-live="polite" style="font-size:12px;line-height:1.9;margin-top:8px;overflow-wrap:anywhere"></p>
scripts/branding-login.spec.js
+44 -2
@@ -1,7 +1,13 @@
1 const {test,expect}=require('@playwright/test');
2 +const BASE=process.env.FINORA_BRANDING_BASE||'http://127.0.0.1:4173/index.html';
3 +test.beforeEach(async({page})=>{
4 + await page.route('https://*.supabase.co/**',r=>r.abort());
5 + await page.route('https://cdn.jsdelivr.net/**',r=>r.abort());
6 + await page.route('https://cdnjs.cloudflare.com/**',r=>r.abort());
7 +});
8 test('Finora login renders premium ERP branding and real icon assets',async({page})=>{
9 await page.setViewportSize({width:1440,height:900});
4 - await page.goto('http://127.0.0.1:4173/index.html',{waitUntil:'domcontentloaded'});
10 + await page.goto(BASE,{waitUntil:'domcontentloaded'});
11 await expect(page).toHaveTitle('نرم‌افزار ERP سازمانی فینورا');
12 await expect(page.locator('#auth-screen .auth-shell')).toBeVisible();
13 await expect(page.locator('.auth-visual')).toBeVisible();
@@ -11,6 +17,42 @@ test('Finora login renders premium ERP branding and real icon assets',async({pag
17 const href=await page.locator('link[rel="icon"]').getAttribute('href');expect(href).toContain('finora-favicon-32.png');
18 });
19 test('Finora login remains focused and usable on mobile',async({page})=>{
14 - await page.setViewportSize({width:390,height:844});await page.goto('http://127.0.0.1:4173/index.html',{waitUntil:'domcontentloaded'});
20 + await page.setViewportSize({width:390,height:844});await page.goto(BASE,{waitUntil:'domcontentloaded'});
21 await expect(page.locator('.auth-visual')).toBeHidden();await expect(page.locator('.auth-card')).toBeVisible();await expect(page.locator('#auth-email')).toBeVisible();
22 });
23 +for(const viewport of [{width:1366,height:650},{width:1024,height:600},{width:920,height:600}]){
24 + test('complete login fits short desktop '+viewport.width+'x'+viewport.height,async({page})=>{
25 + await page.setViewportSize(viewport);
26 + await page.goto(BASE,{waitUntil:'domcontentloaded'});
27 + await expect(page.locator('#auth-login-button')).toBeEnabled();
28 + for(const selector of ['.auth-brand','.auth-google','#auth-email','#auth-password','.auth-actions','#auth-forgot-password','#auth-connectivity-check','.auth-signup','.auth-note']){
29 + const box=await page.locator('#auth-screen '+selector).first().boundingBox();
30 + expect(box,selector).toBeTruthy();
31 + expect(box.y,selector+' top').toBeGreaterThanOrEqual(0);
32 + expect(box.y+box.height,selector+' bottom').toBeLessThanOrEqual(viewport.height);
33 + expect(box.x,selector+' left').toBeGreaterThanOrEqual(0);
34 + expect(box.x+box.width,selector+' right').toBeLessThanOrEqual(viewport.width);
35 + }
36 + const login=await page.locator('#auth-form-container .auth-actions').boundingBox();
37 + const forgot=await page.locator('#auth-forgot-password').boundingBox();
38 + expect(forgot.y).toBeGreaterThanOrEqual(login.y+login.height);
39 + });
40 +}
41 +for(const viewport of [{width:1024,height:450},{width:680,height:400},{width:390,height:568}]){
42 + test('overflow login remains reachable from top to bottom '+viewport.width+'x'+viewport.height,async({page})=>{
43 + await page.setViewportSize(viewport);
44 + await page.goto(BASE,{waitUntil:'domcontentloaded'});
45 + await expect(page.locator('#auth-login-button')).toBeEnabled();
46 + // A real diagnostic can grow after initial layout; neither end may be lost.
47 + await page.locator('#auth-connectivity-result').evaluate(el=>el.textContent=('پاسخ سرور طولانی شده است. ').repeat(20));
48 + await page.locator('#auth-screen').evaluate(el=>{el.scrollTop=0;});
49 + expect((await page.locator('.auth-brand').boundingBox()).y).toBeGreaterThanOrEqual(0);
50 + await page.locator('#auth-screen').evaluate(el=>{el.scrollTop=el.scrollHeight;});
51 + const note=await page.locator('.auth-note').boundingBox();
52 + expect(note.y).toBeGreaterThanOrEqual(0);
53 + expect(note.y+note.height).toBeLessThanOrEqual(viewport.height);
54 + expect(await page.locator('#auth-screen').evaluate(el=>el.scrollWidth<=el.clientWidth)).toBe(true);
55 + await page.locator('#auth-email').focus();
56 + await expect(page.locator('#auth-email')).toBeInViewport();
57 + });
58 +}
scripts/build-pages.mjs
+4
@@ -76,6 +76,10 @@ html=html.replace('</body>','<script src="js/generated-dynamic-handlers.js"></sc
76
77 const generated=`// Generated at build time from legacy static inline event attributes.\n(function(){\nwindow.FinoraLoginActionsBound=false;\n${handlers.map(({id,event,body})=>` {\n const el=document.querySelector('[data-finora-handler-${id}]');\n if(el)el.addEventListener(${JSON.stringify(event)},function(event){\n const result=(function(event){${body}}).call(this,event);\n if(result===false){event.preventDefault();event.stopPropagation();}\n });\n }`).join('\n')}\nwindow.FinoraLoginActionsBound=true;\n})();\n`;
78
79 +// Static handler IDs follow DOM order, so a new page must not reuse old bindings.
80 +const handlersHash=createHash('sha256').update(generated).digest('hex').slice(0,16);
81 +html=html.replace('src="js/generated-event-handlers.js"','src="js/generated-event-handlers.js?v='+handlersHash+'"');
82 +
83 const dynamic=`// CSP-safe dispatcher for simple handlers emitted by runtime renderers.\n(function(){\n const events=['click','change','input','submit','blur','focus','keydown','keyup'];\n function split(text,separator){\n const out=[];let cur='',quote='',escape=false;\n for(const ch of text){\n if(escape){cur+=ch;escape=false;continue;}\n if(ch==='\\\\'){cur+=ch;escape=true;continue;}\n if(quote){cur+=ch;if(ch===quote)quote='';continue;}\n if(ch==='\\"'||ch==="'"){quote=ch;cur+=ch;continue;}\n if(ch===separator){if(cur.trim())out.push(cur.trim());cur='';continue;}\n cur+=ch;\n }\n if(cur.trim())out.push(cur.trim());\n return out;\n }\n function arg(token,el,event){\n if(token==='')return undefined;\n if((token[0]==="'"&&token.at(-1)==="'")||(token[0]==='\\"'&&token.at(-1)==='\\"'))return token.slice(1,-1).replace(/\\\\(['\\"\\\\])/g,'$1');\n if(token==='this')return el;if(token==='event')return event;if(token==='this.value')return el.value;if(token==='this.checked')return el.checked;if(token==='event.target.value')return event.target?.value;\n if(token==='true')return true;if(token==='false')return false;if(token==='null')return null;if(token==='undefined')return undefined;\n if(/^-?\\d+(?:\\.\\d+)?$/.test(token))return Number(token);\n throw new Error('Unsupported CSP-safe handler argument: '+token);\n }\n function invokeOne(statement,el,event){\n const raw=String(statement||'').trim();if(raw==='return false')return false;if(raw==='return true')return true;\n const text=raw.replace(/^return\\s+/,'');\n const assign=text.match(/^([A-Za-z_$][\\w$]*)\\[(\\d+)\\]\\.([A-Za-z_$][\\w$]*)=(this\\.(?:value|checked))$/);\n if(assign){const target=window[assign[1]]?.[Number(assign[2])];if(!target)throw new Error('Missing CSP-safe assignment target: '+assign[1]+'['+assign[2]+']');target[assign[3]]=assign[4]==='this.checked'?el.checked:el.value;return target[assign[3]];}\n const m=text.match(/^((?:window\\.)?[A-Za-z_$][\\w$]*(?:\\.[A-Za-z_$][\\w$]*)*)\\s*\\((.*)\\)$/);\n if(!m)throw new Error('Unsupported CSP-safe handler: '+text);\n const parts=m[1].replace(/^window\\./,'').split('.');let owner=window;\n for(let i=0;i<parts.length-1;i++)owner=owner?.[parts[i]];\n const fn=owner?.[parts.at(-1)];if(typeof fn!=='function')throw new Error('Missing CSP-safe handler function: '+m[1]);\n return fn.apply(el,split(m[2],',').map(x=>arg(x,el,event)));\n }\n function invoke(expression,el,event){let result;for(const statement of split(String(expression||''),';')){result=invokeOne(statement,el,event);if(result===false)break;}return result;}\n for(const type of events){\n document.addEventListener(type,function(event){\n const el=event.target?.closest?.('[data-finora-dynamic-'+type+']');if(!el)return;\n const result=invoke(el.getAttribute('data-finora-dynamic-'+type),el,event);\n if(result===false){event.preventDefault();event.stopPropagation();}\n },type==='blur'||type==='focus');\n }\n})();\n`;
84
85 if(/<script(?![^>]*\ssrc=)[^>]*>/i.test(html))throw new Error('Built page still contains inline script blocks');
scripts/login-startup-readiness.spec.js
+13
@@ -124,6 +124,19 @@ test('Pages preload and execute one core URL versioned from its complete auth co
124 expect(coreRequests).toEqual([urls.script]);
125 });
126
127 +test('Pages static button handlers have a content version for their DOM order',async({page,request})=>{
128 + await syntheticLogin(page);
129 + await page.goto(BASE,{waitUntil:'domcontentloaded'});
130 + const url=await page.locator('script[src*="generated-event-handlers.js"]').evaluate(el=>el.src);
131 + const response=await request.get(url);
132 + expect(response.ok()).toBe(true);
133 + const hash=require('node:crypto').createHash('sha256').update(await response.body()).digest('hex').slice(0,16);
134 + expect(new URL(url).searchParams.get('v')).toBe(hash);
135 + await submitPassword(page);
136 + await expect(page.locator('#auth-screen')).toBeHidden();
137 + expect(await page.evaluate(()=>window.finoraLoginFixture.passwordCalls)).toBe(1);
138 +});
139 +
140 for(const bundle of ['business','accounting']){
141 test('early successful Pages login survives a slow '+bundle+' bundle before company-read timeout starts',async({page})=>{
142 await syntheticLogin(page);