Remove type from auth UI
This commit is contained in:
parent
697946f415
commit
1ce90839fe
|
@ -187,28 +187,21 @@ const CodeDisplay: React.FC<CodeDisplay> = ({ code }) => {
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// Generate to set the initial otp and nextOTP on component mount.
|
// Generate to set the initial otp and nextOTP on component mount.
|
||||||
regen();
|
regen();
|
||||||
const codeType = code.type;
|
|
||||||
const codePeriodInMs = code.period * 1000;
|
const periodMs = code.period * 1000;
|
||||||
const timeToNextCode =
|
const timeToNextCode = periodMs - (Date.now() % periodMs);
|
||||||
codePeriodInMs - (new Date().getTime() % codePeriodInMs);
|
|
||||||
const interval = null;
|
let interval: ReturnType<typeof setInterval> | undefined;
|
||||||
// Wait until we are at the start of the next code period, and then
|
// Wait until we are at the start of the next code period, and then
|
||||||
// start the interval loop.
|
// start the interval loop.
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
// We need to call regen() once before the interval loop to set the
|
// We need to call regen() once before the interval loop to set the
|
||||||
// initial otp and nextOTP.
|
// initial otp and nextOTP.
|
||||||
regen();
|
regen();
|
||||||
codeType.toLowerCase() === "totp" ||
|
interval = setInterval(() => regen, periodMs);
|
||||||
codeType.toLowerCase() === "hotp"
|
|
||||||
? setInterval(() => {
|
|
||||||
regen();
|
|
||||||
}, codePeriodInMs)
|
|
||||||
: null;
|
|
||||||
}, timeToNextCode);
|
}, timeToNextCode);
|
||||||
|
|
||||||
return () => {
|
return () => interval && clearInterval(interval);
|
||||||
if (interval) clearInterval(interval);
|
|
||||||
};
|
|
||||||
}, [code]);
|
}, [code]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -346,7 +339,7 @@ const TimerProgress: React.FC<TimerProgressProps> = ({ period }) => {
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const advance = () => {
|
const advance = () => {
|
||||||
const timeRemaining = us - ((new Date().getTime() * 1000) % us);
|
const timeRemaining = us - ((Date.now() * 1000) % us);
|
||||||
setProgress(timeRemaining / us);
|
setProgress(timeRemaining / us);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue