Skip to content

Commit

Permalink
fixup: disable access control when CODE is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
Yidadaa committed Mar 26, 2023
1 parent 3136d6d commit d0d1673
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 14 deletions.
30 changes: 17 additions & 13 deletions app/components/settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
2 changes: 1 addition & 1 deletion middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit d0d1673

Please sign in to comment.