θΏ™ζ˜―indexlocζδΎ›ηš„ζœεŠ‘οΌŒδΈθ¦θΎ“ε…₯任何密码
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
af79c0a
WIP new login screen UI
shatfield4 Apr 9, 2024
1e76657
update prisma schema/create new models for pw recovery
shatfield4 Apr 9, 2024
50da1e5
WIP password recovery backend
shatfield4 Apr 10, 2024
7d5db62
WIP reset password flow
shatfield4 Apr 11, 2024
c0f6e8f
WIP pw reset flow
shatfield4 Apr 11, 2024
22dff49
password reset logic complete & functional UI
shatfield4 Apr 12, 2024
0e5a714
WIP login screen redesign for single and multi user
shatfield4 Apr 16, 2024
6407949
create placeholder modal to display recovery codes
shatfield4 Apr 17, 2024
35a457a
Merge branch 'master' into 1072-feat-implement-reset-password-recover…
shatfield4 Apr 17, 2024
17e44e0
implement UI for recovery code modals/download recovery codes
shatfield4 Apr 17, 2024
9575447
Merge branch '1072-feat-implement-reset-password-recovery-flows' into…
shatfield4 Apr 17, 2024
cfb10de
multiuser desktop password reset UI/functionality complete
shatfield4 Apr 18, 2024
0ca0d33
support single user mode for pw reset
shatfield4 Apr 18, 2024
54ab05a
mobile styles for all password reset/login flows complete
shatfield4 Apr 18, 2024
a14bbba
Merge branch 'master' into 1031-feat-implement-login-screen-redesign
shatfield4 Apr 18, 2024
870dd5b
lint
shatfield4 Apr 19, 2024
a953882
remove single user password recovery
shatfield4 Apr 19, 2024
121502f
create PasswordRecovery util file to make more readable
shatfield4 Apr 19, 2024
1090160
Merge branch 'master' of github.com:Mintplex-Labs/anything-llm into 1…
timothycarambat Apr 25, 2024
bb790e8
do not drop-replace users table in migration
timothycarambat Apr 25, 2024
11d8312
review pr
timothycarambat Apr 25, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 86 additions & 0 deletions frontend/src/components/Modals/DisplayRecoveryCodeModal/index.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
import showToast from "@/utils/toast";
import { DownloadSimple, Key } from "@phosphor-icons/react";
import { saveAs } from "file-saver";
import { useState } from "react";

export default function RecoveryCodeModal({
recoveryCodes,
onDownloadComplete,
onClose,
}) {
const [downloadClicked, setDownloadClicked] = useState(false);

const downloadRecoveryCodes = () => {
const blob = new Blob([recoveryCodes.join("\n")], { type: "text/plain" });
saveAs(blob, "recovery_codes.txt");
setDownloadClicked(true);
};

const handleClose = () => {
if (downloadClicked) {
onDownloadComplete();
onClose();
}
};

const handleCopyToClipboard = () => {
navigator.clipboard.writeText(recoveryCodes.join(",\n")).then(() => {
showToast("Recovery codes copied to clipboard", "success", {
clear: true,
});
});
};

return (
<div className="inline-block bg-[#2C2F36] rounded-lg text-left overflow-hidden shadow-xl transform transition-all border-2 border-[#BCC9DB]/10 w-[600px] mx-4">
<div className="md:py-[35px] md:px-[50px] py-[28px] px-[20px]">
<div className="flex gap-x-2">
<Key size={24} className="text-white" weight="bold" />
<h3
className="text-lg leading-6 font-medium text-white"
id="modal-headline"
>
Recovery Codes
</h3>
</div>
<div className="mt-4">
<p className="text-sm text-white flex flex-col">
In order to reset your password in the future, you will need these
recovery codes. Download or copy your recovery codes to save them.{" "}
<br />
<b className="mt-4">These recovery codes are only shown once!</b>
</p>
<div
className="bg-[#1C1E21] text-white hover:text-[#46C8FF]
flex items-center justify-center rounded-md mt-6 cursor-pointer"
onClick={handleCopyToClipboard}
>
<ul className="space-y-2 md:p-6 p-4">
{recoveryCodes.map((code, index) => (
<li key={index} className="md:text-sm text-xs">
{code}
</li>
))}
</ul>
</div>
</div>
</div>
<div className="flex w-full justify-center items-center p-3 space-x-2 rounded-b border-gray-500/50 -mt-4 mb-4">
<button
type="button"
className="transition-all duration-300 text-xs md:w-[500px] md:h-[34px] h-[48px] w-full m-2 font-semibold rounded-lg bg-[#46C8FF] hover:bg-[#2C2F36] border-2 border-transparent hover:border-[#46C8FF] hover:text-white whitespace-nowrap shadow-[0_4px_14px_rgba(0,0,0,0.25)] flex justify-center items-center gap-x-2"
onClick={downloadClicked ? handleClose : downloadRecoveryCodes}
>
{downloadClicked ? (
"Close"
) : (
<>
<DownloadSimple weight="bold" size={18} />
<p>Download</p>
</>
)}
</button>
</div>
</div>
);
}
Loading