Skip to content

Commit

Permalink
Add error for when user enters wrong room password (#2534)
Browse files Browse the repository at this point in the history
add error for when user enters wrong room password

Co-authored-by: graham <[email protected]>
  • Loading branch information
Cosmin-Mare and grymmy authored Nov 5, 2024
1 parent 5bae3ab commit 13db9a4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
10 changes: 7 additions & 3 deletions src/components/popups-etc/room-password.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ export interface RoomPasswordPopupProps {

export default function RoomPasswordPopup(props: RoomPasswordPopupProps) {
let password = useSignal("");
function checkPassword() {
let isWrong = useSignal(false);
function checkPassword(noPassCheck = false) {
if(props.persistenceState.value.kind !== PersistenceStateKind.COLLAB) return
fetch("/api/rooms/check-password", {
method: "POST",
Expand All @@ -29,10 +30,12 @@ export default function RoomPasswordPopup(props: RoomPasswordPopupProps) {
}
}
)
} else {
isWrong.value = !noPassCheck;
}
});
}
useEffect(checkPassword, [])
useEffect(() => checkPassword(true), [])
return (
<div class={styles.overlay}>
<div class={styles.modal}>
Expand All @@ -54,7 +57,8 @@ export default function RoomPasswordPopup(props: RoomPasswordPopupProps) {
Enter room
</Button>
</div>
</form>
</form>
{isWrong.value && <p className={styles.error}>Incorrect password!</p>}
</div>
</div>
)
Expand Down
2 changes: 1 addition & 1 deletion src/components/popups-etc/share-room.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -130,4 +130,4 @@ p.muted {
.warning a {
color: #000000;
text-decoration: underline;
}
}

0 comments on commit 13db9a4

Please sign in to comment.