@churchapps/apphelper-login 0.6.14 → 0.6.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/dist/LoginPage.d.ts +1 -0
  2. package/dist/LoginPage.d.ts.map +1 -1
  3. package/dist/LoginPage.js +14 -3
  4. package/dist/LoginPage.js.map +1 -1
  5. package/dist/LogoutPage.d.ts.map +1 -1
  6. package/dist/LogoutPage.js +1 -1
  7. package/dist/LogoutPage.js.map +1 -1
  8. package/dist/components/Forgot.d.ts.map +1 -1
  9. package/dist/components/Forgot.js +71 -83
  10. package/dist/components/Forgot.js.map +1 -1
  11. package/dist/components/Login.d.ts.map +1 -1
  12. package/dist/components/Login.js +86 -106
  13. package/dist/components/Login.js.map +1 -1
  14. package/dist/components/LoginSetPassword.d.ts.map +1 -1
  15. package/dist/components/LoginSetPassword.js +70 -94
  16. package/dist/components/LoginSetPassword.js.map +1 -1
  17. package/dist/components/Register.d.ts.map +1 -1
  18. package/dist/components/Register.js +104 -132
  19. package/dist/components/Register.js.map +1 -1
  20. package/dist/components/SelectChurchModal.d.ts.map +1 -1
  21. package/dist/components/SelectChurchModal.js +2 -1
  22. package/dist/components/SelectChurchModal.js.map +1 -1
  23. package/dist/components/SelectChurchRegister.d.ts.map +1 -1
  24. package/dist/components/SelectChurchRegister.js +11 -5
  25. package/dist/components/SelectChurchRegister.js.map +1 -1
  26. package/dist/components/SelectChurchSearch.d.ts.map +1 -1
  27. package/dist/components/SelectChurchSearch.js +3 -2
  28. package/dist/components/SelectChurchSearch.js.map +1 -1
  29. package/dist/components/SelectableChurch.js +1 -1
  30. package/dist/components/SelectableChurch.js.map +1 -1
  31. package/dist/helpers/AnalyticsHelper.d.ts.map +1 -1
  32. package/dist/helpers/AnalyticsHelper.js +3 -3
  33. package/dist/helpers/AnalyticsHelper.js.map +1 -1
  34. package/dist/helpers/Locale.d.ts.map +1 -1
  35. package/dist/helpers/Locale.js +9 -11
  36. package/dist/helpers/Locale.js.map +1 -1
  37. package/package.json +98 -57
  38. package/src/LoginPage.tsx +0 -314
  39. package/src/LogoutPage.tsx +0 -43
  40. package/src/components/Forgot.tsx +0 -247
  41. package/src/components/Login.tsx +0 -304
  42. package/src/components/LoginSetPassword.tsx +0 -296
  43. package/src/components/Register.tsx +0 -371
  44. package/src/components/SelectChurchModal.tsx +0 -88
  45. package/src/components/SelectChurchRegister.tsx +0 -88
  46. package/src/components/SelectChurchSearch.tsx +0 -85
  47. package/src/components/SelectableChurch.tsx +0 -114
  48. package/src/helpers/AnalyticsHelper.ts +0 -44
  49. package/src/helpers/Locale.ts +0 -248
  50. package/src/helpers/index.ts +0 -2
  51. package/src/index.ts +0 -11
  52. package/tsconfig.json +0 -30
@@ -21,7 +21,7 @@ export class Locale {
21
21
  }
22
22
  // Helper method to get value from nested object using dot notation
23
23
  static getNestedValue(obj, path) {
24
- return path.split('.').reduce((current, key) => {
24
+ return path.split(".").reduce((current, key) => {
25
25
  return current && current[key] !== undefined ? current[key] : undefined;
26
26
  }, obj);
27
27
  }
@@ -45,16 +45,16 @@ export class Locale {
45
45
  const fallbackValue = this.getNestedValue(this.englishFallbacks, key);
46
46
  if (fallbackValue !== undefined) {
47
47
  // Handle simple string interpolation for options
48
- if (typeof fallbackValue === 'string' && options) {
48
+ if (typeof fallbackValue === "string" && options) {
49
49
  let result = fallbackValue;
50
50
  Object.keys(options).forEach(optionKey => {
51
51
  const placeholder = `{{${optionKey}}}`;
52
52
  if (result.includes(placeholder)) {
53
- result = result.replace(new RegExp(placeholder, 'g'), String(options[optionKey]));
53
+ result = result.replace(new RegExp(placeholder, "g"), String(options[optionKey]));
54
54
  }
55
55
  // Also handle {} placeholder for backward compatibility
56
- if (result.includes('{}')) {
57
- result = result.replace('{}', String(options[optionKey]));
56
+ if (result.includes("{}")) {
57
+ result = result.replace("{}", String(options[optionKey]));
58
58
  }
59
59
  });
60
60
  return result;
@@ -90,7 +90,7 @@ Locale.supportedLanguages = [
90
90
  "pt",
91
91
  "ru",
92
92
  "tl",
93
- "zh",
93
+ "zh"
94
94
  ];
95
95
  Locale.extraCodes = { no: ["nb", "nn"] };
96
96
  // Hard-coded English fallbacks for when locale files are not available
@@ -205,13 +205,11 @@ Locale.init = async (backends) => {
205
205
  resources,
206
206
  fallbackLng: "en",
207
207
  debug: false,
208
- interpolation: {
209
- escapeValue: false,
210
- },
208
+ interpolation: { escapeValue: false },
211
209
  detection: {
212
210
  order: ["navigator"],
213
- caches: ["localStorage"],
214
- },
211
+ caches: ["localStorage"]
212
+ }
215
213
  });
216
214
  }
217
215
  catch (error) {
@@ -1 +1 @@
1
- {"version":3,"file":"Locale.js","sourceRoot":"","sources":["../../src/helpers/Locale.ts"],"names":[],"mappings":";AAAA,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAClE,OAAO,gBAAgB,MAAM,kCAAkC,CAAC;AAChE,OAAO,OAAO,MAAM,yBAAyB,CAAC;AAY9C,MAAM,OAAO,MAAM;IAsJV,MAAM,CAAC,SAAS,CACvB,MAA+B,EAC/B,MAA+B;QAE/B,KAAK,MAAM,GAAG,IAAI,MAAM,EAAE,CAAC;YAC1B,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;gBAChC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC;oBAAE,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,EAAE,CAAC,GAAG,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;gBACvD,IAAI,CAAC,SAAS,CACb,MAAM,CAAC,GAAG,CAA4B,EACtC,MAAM,CAAC,GAAG,CAA4B,CACtC,CAAC;YACH,CAAC;;gBAAM,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,EAAE,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QACtD,CAAC;QACD,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Aa,EAAE,EAAE,WAAW,EAAE,KAAK,EAAE;YACrC,SAAS,EAAE;gBACT,KAAK,EAAE,CAAC,WAAW,CAAC;gBACpB,MAAM,EAAE,CAAC,cAAc,CAAC;aACzB;SACF,CAAC,CAAC;IACP,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,IAAI,CAAC,4BAA4B,EAAE,KAAK,CAAC,CAAC;IACpD,CAAC;AACH,CAAC,AAxDU,CAwDT"}
package/package.json CHANGED
@@ -1,57 +1,98 @@
1
- {
2
- "name": "@churchapps/apphelper-login",
3
- "version": "0.6.14",
4
- "description": "Login components for ChurchApps AppHelper",
5
- "type": "module",
6
- "main": "dist/index.js",
7
- "types": "dist/index.d.ts",
8
- "scripts": {
9
- "test": "echo \"Error: no test specified\" && exit 1",
10
- "clean": "rimraf dist",
11
- "tsc": "tsc",
12
- "build": "npm-run-all clean tsc"
13
- },
14
- "repository": {
15
- "type": "git",
16
- "url": "git+https://github.com/LiveChurchSolutions/AppHelper.git"
17
- },
18
- "keywords": [
19
- "ChurchApps",
20
- "login",
21
- "authentication"
22
- ],
23
- "author": "ChurchApps.org",
24
- "license": "MIT",
25
- "bugs": {
26
- "url": "https://github.com/LiveChurchSolutions/AppHelper/issues"
27
- },
28
- "homepage": "https://github.com/LiveChurchSolutions/AppHelper#readme",
29
- "peerDependencies": {
30
- "@churchapps/helpers": "^1.2.4",
31
- "@churchapps/apphelper": "^0.6.0",
32
- "react": "^18.0.0 || ^19.0.0",
33
- "react-dom": "^18.0.0 || ^19.0.0",
34
- "react-router-dom": "^7.6.3"
35
- },
36
- "dependencies": {
37
- "@emotion/react": "^11.14.0",
38
- "@emotion/styled": "^11.14.1",
39
- "@mui/material": "^7.3.1",
40
- "axios": "^1.11.0",
41
- "i18next": "^25.3.2",
42
- "jwt-decode": "^4.0.0",
43
- "react-cookie": "^8.0.1",
44
- "react-google-recaptcha": "^3.1.0",
45
- "react-i18next": "^15.6.1",
46
- "react-ga4": "^2.1.0"
47
- },
48
- "devDependencies": {
49
- "@types/node": "^24.2.0",
50
- "@types/react": "^19.1.9",
51
- "@types/react-dom": "^19.1.7",
52
- "@types/react-google-recaptcha": "^2.1.9",
53
- "npm-run-all2": "^8.0.4",
54
- "rimraf": "^6.0.1",
55
- "typescript": "^5.9.2"
56
- }
57
- }
1
+ {
2
+ "name": "@churchapps/apphelper-login",
3
+ "version": "0.6.16",
4
+ "description": "Login components for ChurchApps AppHelper",
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js"
12
+ }
13
+ },
14
+ "files": [
15
+ "dist"
16
+ ],
17
+ "scripts": {
18
+ "test": "echo \"Error: no test specified\" && exit 1",
19
+ "clean": "rimraf dist",
20
+ "tsc": "tsc",
21
+ "build": "npm-run-all clean tsc",
22
+ "lint": "eslint --fix src/",
23
+ "dev": "vite"
24
+ },
25
+ "repository": {
26
+ "type": "git",
27
+ "url": "git+https://github.com/ChurchApps/Packages.git",
28
+ "directory": "apphelper-login"
29
+ },
30
+ "keywords": [
31
+ "ChurchApps",
32
+ "login",
33
+ "authentication"
34
+ ],
35
+ "author": "ChurchApps.org",
36
+ "license": "MIT",
37
+ "bugs": {
38
+ "url": "https://github.com/ChurchApps/Packages/issues"
39
+ },
40
+ "homepage": "https://github.com/ChurchApps/Packages#readme",
41
+ "peerDependencies": {
42
+ "@churchapps/apphelper": "^0.6.0",
43
+ "@churchapps/helpers": "^1.2.19",
44
+ "@emotion/react": "^11.14.0",
45
+ "@emotion/styled": "^11.14.1",
46
+ "axios": "^1.11.0",
47
+ "i18next": "^25.3.2",
48
+ "i18next-browser-languagedetector": "^8.0.0",
49
+ "i18next-chained-backend": "^4.6.0",
50
+ "jwt-decode": "^4.0.0",
51
+ "react": "^18.0.0 || ^19.0.0",
52
+ "react-cookie": "^8.0.1",
53
+ "react-dom": "^18.0.0 || ^19.0.0",
54
+ "react-ga4": "^2.1.0",
55
+ "react-google-recaptcha": "^3.1.0",
56
+ "react-i18next": "^15.6.1",
57
+ "react-router-dom": "^7.6.3"
58
+ },
59
+ "peerDependenciesMeta": {
60
+ "react-google-recaptcha": { "optional": true }
61
+ },
62
+ "dependencies": {
63
+ "@mui/icons-material": "^7.3.1",
64
+ "@mui/material": "^7.3.1"
65
+ },
66
+ "devDependencies": {
67
+ "@churchapps/apphelper": "^0.6.0",
68
+ "@churchapps/helpers": "^1.2.19",
69
+ "@emotion/react": "^11.14.0",
70
+ "@emotion/styled": "^11.14.1",
71
+ "@eslint/js": "^9.28.0",
72
+ "@types/node": "^24.2.0",
73
+ "@types/react": "^19.1.9",
74
+ "@types/react-dom": "^19.1.7",
75
+ "@types/react-google-recaptcha": "^2.1.9",
76
+ "@vitejs/plugin-react": "^4.7.0",
77
+ "axios": "^1.11.0",
78
+ "eslint": "^9.28.0",
79
+ "eslint-plugin-unused-imports": "^4.4.1",
80
+ "globals": "^16.2.0",
81
+ "i18next": "^25.3.2",
82
+ "i18next-browser-languagedetector": "^8.2.0",
83
+ "i18next-chained-backend": "^4.6.2",
84
+ "jwt-decode": "^4.0.0",
85
+ "npm-run-all2": "^8.0.4",
86
+ "react": "^19.1.0",
87
+ "react-cookie": "^8.0.1",
88
+ "react-dom": "^19.1.0",
89
+ "react-ga4": "^2.1.0",
90
+ "react-google-recaptcha": "^3.1.0",
91
+ "react-i18next": "^15.6.1",
92
+ "react-router-dom": "^7.6.3",
93
+ "rimraf": "^6.0.1",
94
+ "typescript": "^5.9.2",
95
+ "typescript-eslint": "^8.35.0",
96
+ "vite": "^7.0.6"
97
+ }
98
+ }
package/src/LoginPage.tsx DELETED
@@ -1,314 +0,0 @@
1
- "use client";
2
-
3
- import * as React from "react";
4
- import { ErrorMessages, FloatingSupport, Loading } from "@churchapps/apphelper";
5
- import { LoginResponseInterface, UserContextInterface, ChurchInterface, UserInterface, LoginUserChurchInterface, PersonInterface } from "@churchapps/helpers";
6
- import { ApiHelper, ArrayHelper, UserHelper, CommonEnvironmentHelper } from "@churchapps/helpers";
7
- import { AnalyticsHelper, Locale } from "./helpers";
8
- import { useCookies, CookiesProvider } from "react-cookie"
9
- import { Register } from "./components/Register"
10
- import { SelectChurchModal } from "./components/SelectChurchModal"
11
- import { Forgot } from "./components/Forgot";
12
- import { Alert, PaperProps, Typography } from "@mui/material";
13
- import { Login } from "./components/Login";
14
- import { LoginSetPassword } from "./components/LoginSetPassword";
15
- import ga4 from "react-ga4";
16
-
17
- interface Props {
18
- context: UserContextInterface,
19
- jwt: string,
20
- auth: string,
21
- keyName?: string,
22
- logo?: string,
23
- appName?: string,
24
- appUrl?: string,
25
- returnUrl?: string,
26
- userRegisteredCallback?: (user: UserInterface) => Promise<void>;
27
- churchRegisteredCallback?: (church: ChurchInterface) => Promise<void>;
28
- callbackErrors?: string[];
29
- showLogo?: boolean;
30
- showFooter?: boolean;
31
- loginContainerCssProps?: PaperProps;
32
- defaultEmail?: string;
33
- defaultPassword?: string;
34
- handleRedirect?: (url: string, user?: UserInterface, person?: PersonInterface, userChurch?: LoginUserChurchInterface, userChurches?: LoginUserChurchInterface[]) => void; // Function to handle redirects from parent component
35
- }
36
-
37
- const LoginPageContent: React.FC<Props> = ({ showLogo = true, loginContainerCssProps, ...props }) => {
38
- const [welcomeBackName, setWelcomeBackName] = React.useState("");
39
- const [pendingAutoLogin, setPendingAutoLogin] = React.useState(false);
40
- const [errors, setErrors] = React.useState([]);
41
- const [cookies, setCookie] = useCookies(["jwt", "name", "email", "lastChurchId"]);
42
- const [showForgot, setShowForgot] = React.useState(false);
43
- const [showRegister, setShowRegister] = React.useState(false);
44
- const [showSelectModal, setShowSelectModal] = React.useState(false);
45
- const [loginResponse, setLoginResponse] = React.useState<LoginResponseInterface>(null)
46
- const [userJwt, setUserJwt] = React.useState("");
47
- const [isSubmitting, setIsSubmitting] = React.useState(false);
48
-
49
- const loginFormRef = React.useRef(null);
50
- const location = typeof window !== "undefined" && window.location;
51
- let selectedChurchId = "";
52
- let registeredChurch: ChurchInterface = null;
53
- let userJwtBackup = ""; //use state copy for storing between page updates. This copy for instant availability.
54
-
55
- const cleanAppUrl = () => {
56
- if (!props.appUrl) return null;
57
- else {
58
- const index = props.appUrl.indexOf("/", 9);
59
- if (index === -1) return props.appUrl;
60
- else return props.appUrl.substring(0, index);
61
- }
62
- }
63
-
64
- React.useEffect(() => {
65
- if (props.callbackErrors?.length > 0) {
66
- setErrors(props.callbackErrors)
67
- }
68
- }, [props.callbackErrors])
69
-
70
- const performLogout = () => {
71
- // Clear all authentication cookies
72
- setCookie("jwt", "", { path: "/", maxAge: 0 });
73
- setCookie("name", "", { path: "/", maxAge: 0 });
74
- setCookie("email", "", { path: "/", maxAge: 0 });
75
- setCookie("lastChurchId", "", { path: "/", maxAge: 0 });
76
- // Clear any JWT in the ApiHelper
77
- ApiHelper.clearPermissions();
78
- // Clear user context
79
- props.context.setUser(null);
80
- props.context.setUserChurches([]);
81
- props.context.setUserChurch(null);
82
- props.context.setPerson(null);
83
- // Show a logout success message
84
- setErrors(["You have been successfully logged out."]);
85
-
86
- // Handle redirect after logout
87
- const search = new URLSearchParams(location?.search);
88
- const returnUrl = search.get("returnUrl") || props.returnUrl || "/";
89
-
90
- // Use handleRedirect if available, otherwise use window.location
91
- if (props.handleRedirect) {
92
- props.handleRedirect(returnUrl);
93
- } else if (typeof window !== "undefined") {
94
- window.location.href = returnUrl;
95
- }
96
- };
97
-
98
- const init = () => {
99
- const search = new URLSearchParams(location?.search);
100
- const action = search.get("action");
101
- if (action === "logout") performLogout();
102
- else if (action === "forgot") setShowForgot(true);
103
- else if (action === "register") setShowRegister(true);
104
- else {
105
- if (!props.auth && props.jwt) {
106
- setWelcomeBackName(cookies.name);
107
- login({ jwt: props.jwt });
108
- setPendingAutoLogin(true);
109
- } else {
110
- setPendingAutoLogin(false);
111
- }
112
- }
113
- };
114
-
115
- const handleLoginSuccess = async (resp: LoginResponseInterface) => {
116
- userJwtBackup = resp.user.jwt;
117
- setUserJwt(userJwtBackup);
118
- ApiHelper.setDefaultPermissions(resp.user.jwt);
119
- setLoginResponse(resp)
120
- resp.userChurches.forEach(uc => { if (!uc.apis) uc.apis = []; });
121
- UserHelper.userChurches = resp.userChurches;
122
-
123
- setCookie("name", `${resp.user.firstName} ${resp.user.lastName}`, { path: "/" });
124
- setCookie("email", resp.user.email, { path: "/" });
125
- UserHelper.user = resp.user;
126
-
127
- // JWT church selection is handled by the server response, no client-side decoding needed
128
-
129
- const search = new URLSearchParams(location?.search);
130
- const churchIdInParams = search.get("churchId");
131
-
132
- if (props.keyName) selectChurchByKeyName();
133
- else if (churchIdInParams) selectChurch(churchIdInParams);
134
- else if (cookies.lastChurchId && ArrayHelper.getOne(resp.userChurches, "church.id", cookies.lastChurchId)) {
135
- selectedChurchId = cookies.lastChurchId;
136
- selectChurchById();
137
- }
138
- else setShowSelectModal(true);
139
- }
140
-
141
- const selectChurchById = async () => {
142
- await UserHelper.selectChurch(props.context, selectedChurchId, undefined);
143
-
144
- setCookie("lastChurchId", selectedChurchId, { path: "/" });
145
-
146
- if (registeredChurch) {
147
- AnalyticsHelper.logEvent("Church", "Register", UserHelper.currentUserChurch.church.name);
148
- try {
149
- if (CommonEnvironmentHelper.GoogleAnalyticsTag && typeof (window) !== "undefined") {
150
- ga4.gtag("event", "conversion", { send_to: "AW-427967381/Ba2qCLrXgJoYEJWHicwB" });
151
- }
152
- } catch { }
153
- }
154
- else AnalyticsHelper.logEvent("Church", "Select", UserHelper.currentUserChurch.church.name);
155
-
156
- if (props.churchRegisteredCallback && registeredChurch) {
157
- await props.churchRegisteredCallback(registeredChurch)
158
- registeredChurch = null;
159
- login({ jwt: userJwt || userJwtBackup });
160
- } else await continueLoginProcess();
161
- }
162
-
163
- const selectChurchByKeyName = async () => {
164
- if (!ArrayHelper.getOne(UserHelper.userChurches, "church.subDomain", props.keyName)) {
165
- const userChurch: LoginUserChurchInterface = await ApiHelper.post("/churches/select", { subDomain: props.keyName }, "MembershipApi");
166
- UserHelper.setupApiHelper(userChurch);
167
- setCookie("lastChurchId", userChurch.church.id, { path: "/" });
168
- //create/claim the person record and relogin
169
- await ApiHelper.get("/people/claim/" + userChurch.church.id, "MembershipApi");
170
- login({ jwt: userJwt || userJwtBackup });
171
- return;
172
- }
173
- await UserHelper.selectChurch(props.context, undefined, props.keyName);
174
- const selectedChurch = ArrayHelper.getOne(UserHelper.userChurches, "church.subDomain", props.keyName);
175
- if (selectedChurch) setCookie("lastChurchId", selectedChurch.church.id, { path: "/" });
176
- await continueLoginProcess()
177
- return;
178
- }
179
-
180
- async function continueLoginProcess() {
181
- if (UserHelper.currentUserChurch) {
182
- UserHelper.currentUserChurch.apis.forEach(api => {
183
- if (api.keyName === "MembershipApi") setCookie("jwt", api.jwt, { path: "/" });
184
- })
185
- try {
186
- if (UserHelper.currentUserChurch.church.id) ApiHelper.patch(`/userChurch/${UserHelper.user.id}`, { churchId: UserHelper.currentUserChurch.church.id, appName: props.appName, lastAccessed: new Date() }, "MembershipApi")
187
- } catch (e) {
188
- console.log("Could not update user church accessed date")
189
- }
190
- }
191
-
192
- props.context.setUser(UserHelper.user);
193
- props.context.setUserChurches(UserHelper.userChurches)
194
- props.context.setUserChurch(UserHelper.currentUserChurch)
195
-
196
- // Get or claim person before proceeding
197
- let person;
198
- try {
199
- person = await ApiHelper.get(`/people/${UserHelper.currentUserChurch.person?.id}`, "MembershipApi");
200
- if (person) props.context.setPerson(person);
201
- } catch {
202
- person = await ApiHelper.get("/people/claim/" + UserHelper.currentUserChurch.church.id, "MembershipApi");
203
- props.context.setPerson(person);
204
- }
205
-
206
- // Handle redirect with actual data
207
- const search = new URLSearchParams(location?.search);
208
- const returnUrl = search.get("returnUrl") || props.returnUrl || "/";
209
- if (returnUrl && typeof window !== "undefined") {
210
- // Use handleRedirect function if available, otherwise fallback to window.location
211
- if (props.handleRedirect) {
212
- props.handleRedirect(returnUrl, UserHelper.user, person, UserHelper.currentUserChurch, UserHelper.userChurches);
213
- } else {
214
- window.location.href = returnUrl;
215
- }
216
- }
217
- }
218
-
219
- async function selectChurch(churchId: string) {
220
- try {
221
- setErrors([])
222
- selectedChurchId = churchId;
223
- setCookie("lastChurchId", churchId, { path: "/" });
224
- if (!ArrayHelper.getOne(UserHelper.userChurches, "church.id", churchId)) {
225
- const userChurch: LoginUserChurchInterface = await ApiHelper.post("/churches/select", { churchId: churchId }, "MembershipApi");
226
- UserHelper.setupApiHelper(userChurch);
227
-
228
- //create/claim the person record and relogin
229
- await ApiHelper.get("/people/claim/" + churchId, "MembershipApi");
230
- login({ jwt: userJwt || userJwtBackup });
231
- return;
232
- }
233
- UserHelper.selectChurch(props.context, churchId, null).then(() => { continueLoginProcess() });
234
- } catch (err) {
235
- console.log("Error in selecting church: ", err)
236
- setErrors([Locale.label("login.validate.selectingChurch")])
237
- loginFormRef?.current?.setSubmitting(false);
238
- }
239
-
240
- }
241
-
242
- const handleLoginErrors = (errors: string[]) => {
243
- setWelcomeBackName("");
244
- setErrors([Locale.label("login.validate.invalid")]);
245
- }
246
-
247
- const login = async (data: any) => {
248
- setErrors([])
249
- setIsSubmitting(true);
250
- try {
251
- const resp: LoginResponseInterface = await ApiHelper.postAnonymous("/users/login", data, "MembershipApi");
252
- setIsSubmitting(false);
253
- handleLoginSuccess(resp);
254
- } catch (e: any) {
255
- setPendingAutoLogin(false);
256
- setWelcomeBackName("");
257
- if (!data.jwt) handleLoginErrors([e.toString()]);
258
- setIsSubmitting(false);
259
- }
260
- };;
261
-
262
- const getWelcomeBack = () => {
263
- if (welcomeBackName !== "") {
264
- const label = Locale.label("login.welcomeName") || "Welcome back, {}!";
265
- const parts = label.split("{}");
266
- return (
267
- <>
268
- <Alert severity="info">
269
- {parts[0]}{welcomeBackName}{parts[1] || ""}
270
- </Alert>
271
- <Loading />
272
- </>
273
- );
274
- }
275
- }
276
- const getCheckEmail = () => { if (new URLSearchParams(location?.search).get("checkEmail") === "1") return <Alert severity="info">{Locale.label("login.registerThankYou")}</Alert> }
277
- const handleRegisterCallback = () => { setShowForgot(false); setShowRegister(true); }
278
- const handleLoginCallback = () => { setShowForgot(false); setShowRegister(false); }
279
- const handleChurchRegistered = (church: ChurchInterface) => { registeredChurch = church; setShowRegister(false); }
280
-
281
- const getInputBox = () => {
282
- if (showRegister) return (
283
-
284
- <Register updateErrors={setErrors} appName={props.appName} appUrl={cleanAppUrl()} loginCallback={handleLoginCallback} userRegisteredCallback={props.userRegisteredCallback} />
285
-
286
- );
287
- else if (showForgot) return (<Forgot registerCallback={handleRegisterCallback} loginCallback={handleLoginCallback} />);
288
- else if (props.auth) return (<LoginSetPassword setErrors={setErrors} setShowForgot={setShowForgot} isSubmitting={isSubmitting} auth={props.auth} login={login} appName={props.appName} appUrl={cleanAppUrl()} />)
289
- else return <Login setShowRegister={setShowRegister} setShowForgot={setShowForgot} setErrors={setErrors} isSubmitting={isSubmitting} login={login} mainContainerCssProps={loginContainerCssProps} defaultEmail={props.defaultEmail} defaultPassword={props.defaultPassword} showFooter={props.showFooter} />;
290
- }
291
-
292
- React.useEffect(init, []); //eslint-disable-line
293
-
294
- return (
295
- <>
296
- <ErrorMessages errors={errors} />
297
- {getWelcomeBack()}
298
- {getCheckEmail()}
299
- {!pendingAutoLogin && getInputBox()}
300
- <SelectChurchModal show={showSelectModal} userChurches={loginResponse?.userChurches} selectChurch={selectChurch} registeredChurchCallback={handleChurchRegistered} errors={errors} appName={props.appName} handleRedirect={props.handleRedirect} />
301
- <FloatingSupport appName={props.appName} />
302
- </>
303
- );
304
-
305
- };
306
-
307
- export const LoginPage: React.FC<Props> = (props) => {
308
- // Always wrap with CookiesProvider to ensure context is available
309
- return (
310
- <CookiesProvider defaultSetOptions={{ path: '/' }}>
311
- <LoginPageContent {...props} />
312
- </CookiesProvider>
313
- );
314
- };
@@ -1,43 +0,0 @@
1
- "use client";
2
-
3
- import React from "react";
4
- import { useCookies, CookiesProvider } from "react-cookie"
5
- import { ApiHelper, UserContextInterface } from "@churchapps/helpers";
6
-
7
- interface Props { context?: UserContextInterface, handleRedirect?: (url: string) => void }
8
-
9
- const LogoutPageContent: React.FC<Props> = (props) => {
10
- const [, , removeCookie] = useCookies(["jwt", "email", "name", "lastChurchId"]);
11
-
12
- removeCookie("jwt");
13
- removeCookie("email");
14
- removeCookie("name");
15
- removeCookie("lastChurchId");
16
-
17
- ApiHelper.clearPermissions();
18
- props.context?.setUser(null);
19
- props.context?.setPerson(null);
20
- props.context?.setUserChurches(null);
21
- props.context?.setUserChurch(null);
22
-
23
- setTimeout(() => {
24
- // a must check for Nextjs
25
- if (typeof window !== "undefined") {
26
- // Use handleRedirect function if available, otherwise fallback to window.location
27
- if (props.handleRedirect) {
28
- props.handleRedirect("/");
29
- } else {
30
- window.location.href = "/";
31
- }
32
- }
33
- }, 300);
34
- return null;
35
- }
36
-
37
- export const LogoutPage: React.FC<Props> = (props) => {
38
- return (
39
- <CookiesProvider defaultSetOptions={{ path: '/' }}>
40
- <LogoutPageContent {...props} />
41
- </CookiesProvider>
42
- );
43
- }