Skip to content

Commit 9e79b00

Browse files
apphelper: keep login cookies 32 days so expired jwts can refresh (ChurchAppsSupport#1133) (#61)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
1 parent a926065 commit 9e79b00

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@churchapps/apphelper": patch
3+
---
4+
5+
Keep the login cookies for 32 days so an expired jwt can be refreshed and users stay signed in (ChurchAppsSupport#1133).

‎apphelper/src/login/LoginPage.tsx‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ interface Props {
3535
handleRedirect?: (url: string, user?: UserInterface, person?: PersonInterface, userChurch?: LoginUserChurchInterface, userChurches?: LoginUserChurchInterface[]) => void; // Function to handle redirects from parent component
3636
}
3737

38-
const COOKIE_MAX_AGE = 2 * 24 * 60 * 60;
38+
// Outlive the 2-day user jwt plus the Api's 30-day refresh window, so an expired jwt can still be traded for a new one.
39+
const COOKIE_MAX_AGE = 32 * 24 * 60 * 60;
3940
const isLocalPath = (url: string) => /^\/(?![/\\])/.test(url.replace(/[\t\n\r]/g, ""));
4041

4142
const LoginPageContent: React.FC<Props> = ({ showLogo = true, loginContainerCssProps, ...props }) => {
@@ -188,7 +189,7 @@ const LoginPageContent: React.FC<Props> = ({ showLogo = true, loginContainerCssP
188189

189190
async function continueLoginProcess() {
190191
if (UserHelper.currentUserChurch) {
191-
// Store the user JWT (180-day) for session persistence, not the API JWT (2-day)
192+
// Store the user JWT (refreshable for 30 days after it expires) for session persistence, not the API JWT
192193
setCookie("jwt", userJwt || userJwtBackup, { path: "/", maxAge: COOKIE_MAX_AGE, secure: window.location.protocol === "https:", sameSite: "lax" });
193194
try {
194195
if (UserHelper.currentUserChurch.church.id) ApiHelper.patch(`/userChurch/${UserHelper.user.id}`, { churchId: UserHelper.currentUserChurch.church.id, appName: props.appName, lastAccessed: new Date() }, "MembershipApi");

0 commit comments

Comments
 (0)