Skip to content

Commit

Permalink
throttle signinSilent
Browse files Browse the repository at this point in the history
  • Loading branch information
FZambia committed Jan 10, 2024
1 parent 1d7aebe commit b787ba3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
13 changes: 10 additions & 3 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -244,11 +244,18 @@ function ShellWrapper({
handlePasswordLogout()
}

const [lastSignIn, setLastSignIn] = useState(0)

const signinSilent = () => {
if (auth) {
auth.signinSilent()
} else {
if (!auth) {
handleLogout()
return
}
const now = Date.now()
if (now - lastSignIn >= 10000) {
// throttle to once in 10 seconds.
auth.signinSilent()
setLastSignIn(now)
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/pages/Login/Login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ export function Login({ handleLogin }: LoginProps) {
sx={{ mt: 3, mb: 2 }}
onClick={() => void auth.signinRedirect()}
>
Log in over {adminSettings.oidc?.display_name}
Log in using {adminSettings.oidc?.display_name}
</Button>
) : (
<Button
Expand Down

0 comments on commit b787ba3

Please sign in to comment.