fixup: disable access control when CODE is empty

This commit is contained in:
Yifei Zhang 2023-03-26 07:06:06 +00:00
parent 3136d6d3fd
commit d0d1673ccc
2 changed files with 18 additions and 14 deletions

View File

@ -239,19 +239,23 @@ export function Settings(props: { closeSettings: () => void }) {
</div>
</List>
<List>
<SettingItem
title={Locale.Settings.AccessCode.Title}
subTitle={Locale.Settings.AccessCode.SubTitle}
>
<input
value={accessStore.accessCode}
type="text"
placeholder={Locale.Settings.AccessCode.Placeholder}
onChange={(e) => {
accessStore.updateCode(e.currentTarget.value);
}}
></input>
</SettingItem>
{enabledAccessControl ? (
<SettingItem
title={Locale.Settings.AccessCode.Title}
subTitle={Locale.Settings.AccessCode.SubTitle}
>
<input
value={accessStore.accessCode}
type="text"
placeholder={Locale.Settings.AccessCode.Placeholder}
onChange={(e) => {
accessStore.updateCode(e.currentTarget.value);
}}
></input>
</SettingItem>
) : (
<></>
)}
<SettingItem
title={Locale.Settings.HistoryCount.Title}

View File

@ -14,7 +14,7 @@ export function middleware(req: NextRequest, res: NextResponse) {
console.log("[Auth] got access code:", accessCode);
console.log("[Auth] hashed access code:", hashedCode);
if (!ACCESS_CODES.has(hashedCode)) {
if (ACCESS_CODES.size > 0 && !ACCESS_CODES.has(hashedCode)) {
return NextResponse.json(
{
needAccessCode: true,