The whole frontend needs refactoring, but a good place to start is by extracting the functional logic into custom hooks. The throwaway nature of the initial project meant that I didn't do this from the beginning as I should. A good component to start that on is frontend/src/components/AuthWrapper.js
.
Currently, the functionality for logging in is in the component itself. We want the component to contain only UI concerns, so we want a custom hook that looks like this:
export function AuthWrapper(props) {
const [isLoading, isAuthorized, hasFailedLoginAttempts] = useLogin();
return (
<div>
...
</div>
);
}