fix: bad message in case of account disabled #1027
Massimo Melina committed
Jul 2, 2025 at 00:20 UTC
2f5c6214fd8e319f2ec5c8af71dab2936c1a7f07
28 files changed
+60
-32
src/api.auth.ts
+4
-2
@@ -1,6 +1,8 @@
1
// This file is part of HFS - Copyright 2021-2023, Massimo Melina <a@rejetto.com> - License https://www.gnu.org/licenses/gpl-3.0.txt
2
3
-import { Account, accountCanLogin, changeSrpHelper, expandUsername, getAccount, getFromAccount } from './perm'
3
+import {
4
+ Account, accountCanLogin, accountIsDisabled, changeSrpHelper, expandUsername, getAccount, getFromAccount
5
+} from './perm'
6
import { ApiError, ApiHandler } from './apiMiddleware'
7
import { SRPServerSessionStep1 } from 'tssrp6a'
8
import {
@@ -47,7 +49,7 @@ export const loginSrp1: ApiHandler = async ({ username }, ctx) => {
49
if (!account || !accountCanLogin(account)) { // TODO simulate fake account to prevent knowing valid usernames
50
ctx.logExtra({ u: username })
51
ctx.state.dontLog = false // log even if log_api is false
50
- return new ApiError(HTTP_UNAUTHORIZED)
52
+ return new ApiError(HTTP_UNAUTHORIZED, account && accountIsDisabled(account) ? 'Account disabled' : undefined)
53
}
54
if (failAllowNet(ctx, account))
55
return new ApiError(HTTP_UNAUTHORIZED)
src/langs/hfs-lang-ar.json
+2
-1
@@ -189,6 +189,7 @@
189
"Yes": "نعم",
190
"No": "لا",
191
"esc_again": "انقر على ESC ثانية لاغلاق",
192
- "insufficient storage": "مساحة تخزين غير كافية"
192
+ "insufficient storage": "مساحة تخزين غير كافية",
193
+ "Account disabled": "تم تعطيل الحساب"
194
}
195
}
src/langs/hfs-lang-bg.json
+3
-2
@@ -182,11 +182,12 @@
182
"creation": "създаване",
183
"required_change_password": "Трябва да смените паролата си",
184
"Wildcards": "Заместващи символи",
185
- "Considering resume": "Разглеждане на възобновяване",
185
+ "Considering resume": "Проверка за възобновяване на качването",
186
187
"Yes": "Да",
188
"No": "Не",
189
"esc_again": "Натиснете ESC два пъти за затваряне",
190
- "insufficient storage": "недостатъчно пространство"
190
+ "insufficient storage": "недостатъчно пространство",
191
+ "Account disabled": "Акаунтът е деактивиран"
192
}
193
}
src/langs/hfs-lang-de.json
+2
-1
@@ -179,6 +179,7 @@
179
"Yes": "Ja",
180
"No": "Nein",
181
"esc_again": "Drucken Sie ESC zwei Mal, um das Fenster zu schließen.",
182
- "insufficient storage": "nicht genügend Speicherplatz"
182
+ "insufficient storage": "nicht genügend Speicherplatz",
183
+ "Account disabled": "Konto deaktiviert"
184
}
185
}
\ No newline at end of file
src/langs/hfs-lang-el.json
+2
-1
@@ -190,6 +190,7 @@
190
"Yes": "Ναι",
191
"No": "Οχι",
192
"esc_again": "Πατήστε ESC δυο φορές για να κλειστειτε",
193
- "insufficient storage": "ανεπαρκής χώρος αποθήκευσης"
193
+ "insufficient storage": "ανεπαρκής χώρος αποθήκευσης",
194
+ "Account disabled": "Ο λογαριασμός έχει απενεργοποιηθεί"
195
}
196
}
src/langs/hfs-lang-en.json
+2
-1
@@ -188,6 +188,7 @@
188
"Yes": "Yes",
189
"No": "No",
190
"esc_again": "Press ESC twice to close",
191
- "insufficient storage": "insufficient storage"
191
+ "insufficient storage": "insufficient storage",
192
+ "Account disabled": "Account disabled"
193
}
194
}
\ No newline at end of file
src/langs/hfs-lang-es.json
+2
-1
@@ -193,6 +193,7 @@
193
"Yes": "Si",
194
"No": "No",
195
"esc_again": "Presione ESC dos veces para cerrar",
196
- "insufficient storage": "almacenamiento insuficiente"
196
+ "insufficient storage": "almacenamiento insuficiente",
197
+ "Account disabled": "Cuenta deshabilitada"
198
}
199
}
src/langs/hfs-lang-fi.json
+2
-1
@@ -193,6 +193,7 @@
193
"Yes": "Kyllä",
194
"No": "Ei",
195
"esc_again": "Paina ESC kahdesti sulkeaksesi",
196
- "insufficient storage": "riittämätön tallennustila"
196
+ "insufficient storage": "riittämätön tallennustila",
197
+ "Account disabled": "Tili on poistettu käytöstä"
198
}
199
}
src/langs/hfs-lang-fr.json
+2
-1
@@ -193,6 +193,7 @@
193
"Yes": "Oui",
194
"No": "Non",
195
"esc_again": "Appuyez ESC deux fois pour fermer",
196
- "insufficient storage": "espace insuffisant"
196
+ "insufficient storage": "espace insuffisant",
197
+ "Account disabled": "Compte désactivé"
198
}
199
}
\ No newline at end of file
src/langs/hfs-lang-hu.json
+2
-1
@@ -194,6 +194,7 @@
194
"Yes": "Igen",
195
"No": "Nem",
196
"esc_again": "ESC megadva 2 alkalommal",
197
- "insufficient storage": "elégtelen tárhely"
197
+ "insufficient storage": "elégtelen tárhely",
198
+ "Account disabled": "A fiók deaktiválva"
199
}
200
}
src/langs/hfs-lang-it.json
+2
-1
@@ -180,6 +180,7 @@
180
"Yes": "Sì",
181
"No": "No",
182
"esc_again": "Premi ESC due volte per chiudere",
183
- "insufficient storage": "spazio insufficiente"
183
+ "insufficient storage": "spazio insufficiente",
184
+ "Account disabled": "Account disattivato"
185
}
186
}
src/langs/hfs-lang-ja.json
+2
-1
@@ -189,6 +189,7 @@
189
"Yes": "はい",
190
"No": "いいえ",
191
"esc_again": "ESCを2回押して閉じます",
192
- "insufficient storage": "ストレージ容量不足"
192
+ "insufficient storage": "ストレージ容量不足",
193
+ "Account disabled": "アカウントは無効です"
194
}
195
}
\ No newline at end of file
src/langs/hfs-lang-ko.json
+2
-1
@@ -189,6 +189,7 @@
189
"Yes": "영",
190
"No": "안",
191
"esc_again": "ESC 두번 페스하기",
192
- "insufficient storage": "저장 공간 부족"
192
+ "insufficient storage": "저장 공간 부족",
193
+ "Account disabled": "계정이 비활성화되었습니다"
194
}
195
}
src/langs/hfs-lang-lt.json
+2
-1
@@ -188,6 +188,7 @@
188
"Yes": "Taip",
189
"No": "Ne",
190
"esc_again": "Paspauskite ESC du kartus, kad uždarytumėte",
191
- "insufficient storage": "nepakanka vietos"
191
+ "insufficient storage": "nepakanka vietos",
192
+ "Account disabled": "Paskyra išjungta"
193
}
194
}
\ No newline at end of file
src/langs/hfs-lang-ms.json
+2
-1
@@ -150,6 +150,7 @@
150
"Yes": "Ya",
151
"No": "Tidak",
152
"esc_again": "Tekan ESC dua kali untuk menutup",
153
- "insufficient storage": "ruang storan tidak mencukupi"
153
+ "insufficient storage": "ruang storan tidak mencukupi",
154
+ "Account disabled": "Akaun dinyahdayakan"
155
}
156
}
\ No newline at end of file
src/langs/hfs-lang-nl.json
+2
-1
@@ -188,6 +188,7 @@
188
"Yes": "Ja",
189
"No": "Nee",
190
"esc_again": "Druk ESC twee keer om te sluiten",
191
- "insufficient storage": "onvoldoende opslagruimte"
191
+ "insufficient storage": "onvoldoende opslagruimte",
192
+ "Account disabled": "Account uitgeschakeld"
193
}
194
}
\ No newline at end of file
src/langs/hfs-lang-pl.json
+2
-1
@@ -188,6 +188,7 @@
188
"Yes": "Tak",
189
"No": "Nie",
190
"esc_again": "Naciśnij ESC dwukrotnie do zamkniecia",
191
- "insufficient storage": "za mało miejsca"
191
+ "insufficient storage": "za mało miejsca",
192
+ "Account disabled": "Konto wyłączone"
193
}
194
}
\ No newline at end of file
src/langs/hfs-lang-pt-br.json
+2
-1
@@ -188,6 +188,7 @@
188
"Yes": "Sim",
189
"No": "Nao",
190
"esc_again": "Pressione ESC duas vezes para fechar",
191
- "insufficient storage": "armazenamento insuficiente"
191
+ "insufficient storage": "armazenamento insuficiente",
192
+ "Account disabled": "Conta foi desativada"
193
}
194
}
\ No newline at end of file
src/langs/hfs-lang-ro.json
+2
-1
@@ -189,6 +189,7 @@
189
"Yes": "Da",
190
"No": "Nu",
191
"esc_again": "Apasa ESC de doua ori pentru a inchide",
192
- "insufficient storage": "spațiu de stocare insuficient"
192
+ "insufficient storage": "spațiu de stocare insuficient",
193
+ "Account disabled": "Cont dezactivat"
194
}
195
}
\ No newline at end of file
src/langs/hfs-lang-ru.json
+2
-1
@@ -192,6 +192,7 @@
192
"Yes": "Да",
193
"No": "Нет",
194
"esc_again": "Нажмите ESC дважды для закрытия",
195
- "insufficient storage": "недостаточно места"
195
+ "insufficient storage": "недостаточно места",
196
+ "Account disabled": "Учетная запись отключена"
197
}
198
}
src/langs/hfs-lang-sr.json
+2
-1
@@ -189,6 +189,7 @@
189
"Yes": "Да",
190
"No": "Не",
191
"esc_again": "Пritisnite ESC два пута за затварање",
192
- "insufficient storage": "недовољно простора"
192
+ "insufficient storage": "недовољно простора",
193
+ "Account disabled": "Налог је деактивиран"
194
}
195
}
\ No newline at end of file
src/langs/hfs-lang-th.json
+2
-1
@@ -189,6 +189,7 @@
189
"Yes": "ใช่",
190
"No": "ไม่",
191
"esc_again": "กด ESC สองครั้งเพื่อปิด",
192
- "insufficient storage": "พื้นที่จัดเก็บไม่เพียงพอ"
192
+ "insufficient storage": "พื้นที่จัดเก็บไม่เพียงพอ",
193
+ "Account disabled": "บัญชีถูกปิดใช้งานแล้ว"
194
}
195
}
src/langs/hfs-lang-tr.json
+2
-1
@@ -189,6 +189,7 @@
189
"Yes": "Evet",
190
"No": "Hayır",
191
"esc_again": "ESC'i iki kere basarak kapat",
192
- "insufficient storage": "yetersiz depolama alanı"
192
+ "insufficient storage": "yetersiz depolama alanı",
193
+ "Account disabled": "Hesap devre dışı bırakıldı"
194
}
195
}
src/langs/hfs-lang-uk.json
+2
-1
@@ -183,6 +183,7 @@
183
"Yes": "Так",
184
"No": "Ні",
185
"esc_again": "Натисніть ESC два рази для закриття",
186
- "insufficient storage": "недостатньо місця"
186
+ "insufficient storage": "недостатньо місця",
187
+ "Account disabled": "Обліковий запис вимкнено"
188
}
189
}
\ No newline at end of file
src/langs/hfs-lang-vi.json
+2
-1
@@ -194,6 +194,7 @@
194
"Yes": "Có",
195
"No": "Không",
196
"esc_again": "Nhấn ESC hai lần để đóng",
197
- "insufficient storage": "không đủ dung lượng"
197
+ "insufficient storage": "không đủ dung lượng",
198
+ "Account disabled": "Tài khoản đã bị vô hiệu hóa"
199
}
200
}
src/langs/hfs-lang-zh-tw.json
+2
-1
@@ -189,6 +189,7 @@
189
"Yes": "是",
190
"No": "否",
191
"esc_again": "按 ESC 兩次關閉",
192
- "insufficient storage": "儲存空間不足"
192
+ "insufficient storage": "儲存空間不足",
193
+ "Account disabled": "帳戶已停用"
194
}
195
}
\ No newline at end of file
src/langs/hfs-lang-zh.json
+2
-1
@@ -193,6 +193,7 @@
193
"Yes": "是",
194
"No": "否",
195
"esc_again": "按 ESC 两次关闭",
196
- "insufficient storage": "存储空间不足"
196
+ "insufficient storage": "存储空间不足",
197
+ "Account disabled": "账户已禁用"
198
}
199
}
\ No newline at end of file
src/perm.ts
+3
-3
@@ -195,14 +195,14 @@ export function accountHasPassword(account: Account) {
195
}
196
197
export function accountCanLogin(account: Account) {
198
- return (accountHasPassword(account) || account.plugin?.auth) && !allDisabled(account)
198
+ return (accountHasPassword(account) || account.plugin?.auth) && !accountIsDisabled(account)
199
}
200
201
-function allDisabled(account: Account): boolean {
201
+export function accountIsDisabled(account: Account): boolean {
202
return Boolean(account.disabled
203
|| account.expire as any < Date.now()
204
|| account.belongs?.length // don't every() on empty array, as it returns true
205
- && account.belongs.map(u => getAccount(u, false)).every(a => a && allDisabled(a)) )
205
+ && account.belongs.map(u => getAccount(u, false)).every(a => a && accountIsDisabled(a)) )
206
}
207
208
export function accountCanLoginAdmin(account: Account) {