Skip to content

Commit

Permalink
Reset password works when signed in or not signed in
Browse files Browse the repository at this point in the history
The race conditions and hanging tab (which was due to a strange bug if you use a <form> with out a submit in React).
There are still some clean up items to do:

1) Create person when an admin, without requiring a password verification -- but in any case a password verification will still be required on the first login by the new staff person.

2) Escaping out of the creation/verification/reset process without completing all the steps

3) Staying signed in after a password reset

This is still an ongoing development ... only bother merging for now, if you have merges you want to commit.
  • Loading branch information
SailingSteve committed Mar 2, 2025
1 parent 926a692 commit c1a7f5a
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 8 deletions.
1 change: 1 addition & 0 deletions src/js/components/Navigation/HeaderBar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ const HeaderBar = ({ hideTabs }) => {
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [loc]);

console.log('HeaderBar viewerCanSeeOrDo(canViewSystemSettings, viewerAccessRights): ', viewerCanSeeOrDo('canViewSystemSettings', viewerAccessRights));

return (
<HeaderBarWrapper
Expand Down
23 changes: 16 additions & 7 deletions src/js/pages/Login.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ const Login = ({ classes }) => {
const authPerson = useRef(undefined);

const [loginAttempted, setLoginAttempted] = useState(false);
const [isForSomeOneElse, setIsForSomeOneElse] = useState(false);
const [openResetPasswordDialog, setOpenResetPasswordDialog] = useState(false);
const [showCreateStuff, setShowCreateStuff] = useState(false);
const [successLine, setSuccessLine] = useState('');
Expand Down Expand Up @@ -191,11 +192,17 @@ const Login = ({ classes }) => {
setSuccessLine(`user # ${data.personId} created`);
setSuccessLine(`user # ${data.personId} created`);
authPerson.current = data.person;
verifyYourEmail(data.personId).then(() => {
setSuccessLine('A verification email has been sent to your address');
console.log('verifyYourEmail in signupApi then clause , openVerifySecretCodeModalDialog true');
setAppContextValue('openVerifySecretCodeModalDialog', true);
});
if (isForSomeOneElse) {
setShowCreateStuff(false);
setSuccessLine(`A person record was created for ${firstName} ${lastName} (they will have to verify their email on their first login)`);
console.log('verifyYourEmail in signupApi then clause , openVerifySecretCodeModalDialog false');
} else {
verifyYourEmail(data.personId).then(() => {
setSuccessLine('A verification email has been sent to your address');
console.log('verifyYourEmail in signupApi then clause , openVerifySecretCodeModalDialog true');
setAppContextValue('openVerifySecretCodeModalDialog', true);
});
}
}
} catch (e) {
console.log('signup error', e);
Expand Down Expand Up @@ -239,7 +246,7 @@ const Login = ({ classes }) => {
if (!showCreateStuff) {
setShowCreateStuff(true);
setWarningLine('');
setSuccessLine('');
setSuccessLine(isForSomeOneElse ? 'Creating an account for someone else' : '');
} else {
setWarningLine('');
let errStr = '';
Expand Down Expand Up @@ -268,13 +275,15 @@ const Login = ({ classes }) => {
};

const createForSomeoneElsePressed = () => {
console.log('NOT YET IMPLEMENTED');
setIsForSomeOneElse(true);
createPressed();
};

// console.log(getAppContextData());
const isAdmin = getAppContextValue('loggedInPersonIsAdmin') || false;
const isAuthSafe = getAppContextValue('isAuthenticated') || false;
const displayVerify =
!isForSomeOneElse &&
authPerson.current &&
Object.keys(authPerson.current).length > 0 &&
getAppContextValue('secretCodeVerified') !== true &&
Expand Down
9 changes: 8 additions & 1 deletion src/js/pages/SystemSettings/PermissionsAdministration.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,16 @@ const PermissionsAdministration = ({ classes }) => {
setCanEditPermissionsAnyone(viewerCanSeeOrDo('canEditPermissionsAnyone', viewerAccessRights));
}, [viewerAccessRights]);

function alphabetizePeoplesObject (obj) {
const arrayOfObjects = Object.keys(obj).map((key) => ({ ...obj[key], id: key }));
arrayOfObjects.sort((a, b) => (a.lastName + a.firstName).localeCompare(b.lastName + b.firstName));
return arrayOfObjects;
}

useEffect(() => {
const allPeopleCacheCopy2 = JSON.parse(JSON.stringify(allPeopleCache));
setPeopleWorkingArray(Object.values(allPeopleCacheCopy2));
const sorted = alphabetizePeoplesObject(allPeopleCacheCopy2);
setPeopleWorkingArray(sorted);
}, [allPeopleCache]);

const adminFldRef = useRef('');
Expand Down

0 comments on commit c1a7f5a

Please sign in to comment.