@klauswuestefeld/jux-web 2024.12.3 → 2024.12.7
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.
- package/dist/jux-web.js +48 -25
- package/dist/login/login-page.d.ts +1 -1
- package/dist/login/session.d.ts +2 -2
- package/dist/main.esm.js +48 -25
- package/dist/main.js +48 -25
- package/package.json +1 -1
package/dist/jux-web.js
CHANGED
|
@@ -14556,7 +14556,7 @@ var juxWeb = (function (exports) {
|
|
|
14556
14556
|
const onError = () => onAuthenticationFailure('login-failed');
|
|
14557
14557
|
getSSOAuthorizationEndpoint(onSuccess, onError);
|
|
14558
14558
|
};
|
|
14559
|
-
const initSession = (clientApp, supportedLoginTypes, onUserLogin, backgroundImage, fetchUserBackendUrl, magicLinkRequestEndpoint, magicLinkAuthEndpoint) => {
|
|
14559
|
+
const initSession = (clientApp, supportedLoginTypes, onUserLogin, onLoginError, backgroundImage, fetchUserBackendUrl, magicLinkRequestEndpoint, magicLinkAuthEndpoint) => {
|
|
14560
14560
|
// if (startNewDemo()) {
|
|
14561
14561
|
// initDemo(setBackendToken, onAuthentication);
|
|
14562
14562
|
// return;
|
|
@@ -14610,7 +14610,7 @@ var juxWeb = (function (exports) {
|
|
|
14610
14610
|
handleSSOLogin();
|
|
14611
14611
|
return;
|
|
14612
14612
|
}
|
|
14613
|
-
displayPage(clientApp, loginPage(clientApp, backgroundImage, onUserLogin, supportedLoginTypes));
|
|
14613
|
+
displayPage(clientApp, loginPage(clientApp, backgroundImage, onUserLogin, onLoginError, supportedLoginTypes));
|
|
14614
14614
|
// validateThirdPartyCookies(initGapi, () => displayPage(Page.LOGIN));
|
|
14615
14615
|
// checkMixpanel(() => mixpanel.track('View Login Page'));
|
|
14616
14616
|
};
|
|
@@ -14652,7 +14652,7 @@ var juxWeb = (function (exports) {
|
|
|
14652
14652
|
authSignIn(onUserLogin);
|
|
14653
14653
|
}, onCookieError);
|
|
14654
14654
|
};
|
|
14655
|
-
const onAuthPasswordLogin = (credentials, onUserLogin, onReturn, clientApp, backgroundImg) => {
|
|
14655
|
+
const onAuthPasswordLogin = (credentials, onUserLogin, onLoginError, onReturn, clientApp, backgroundImg) => {
|
|
14656
14656
|
const { email } = credentials;
|
|
14657
14657
|
enableSignInLayout();
|
|
14658
14658
|
const onSuccess = (res) => {
|
|
@@ -14663,9 +14663,8 @@ var juxWeb = (function (exports) {
|
|
|
14663
14663
|
disableSignInLayout();
|
|
14664
14664
|
};
|
|
14665
14665
|
const onError = (err) => {
|
|
14666
|
-
console.error(err);
|
|
14667
|
-
reportError(err);
|
|
14668
14666
|
disableSignInLayout();
|
|
14667
|
+
onLoginError(err);
|
|
14669
14668
|
};
|
|
14670
14669
|
const onUnauthorized = () => {
|
|
14671
14670
|
disableSignInLayout();
|
|
@@ -14852,11 +14851,51 @@ var juxWeb = (function (exports) {
|
|
|
14852
14851
|
return result;
|
|
14853
14852
|
};
|
|
14854
14853
|
|
|
14854
|
+
const authPasswordRow = (type, autoCompleteValue) => {
|
|
14855
|
+
const result = document.createElement(`${type}-row`);
|
|
14856
|
+
result.style.display = 'flex';
|
|
14857
|
+
const label = document.createElement('label');
|
|
14858
|
+
label.textContent = type.charAt(0).toUpperCase() + type.slice(1);
|
|
14859
|
+
label.htmlFor = `input-${type}`;
|
|
14860
|
+
const input = document.createElement('input');
|
|
14861
|
+
input.id = `input-${type}`;
|
|
14862
|
+
input.type = type;
|
|
14863
|
+
input.autocomplete = autoCompleteValue;
|
|
14864
|
+
result.append(label, input);
|
|
14865
|
+
return result;
|
|
14866
|
+
};
|
|
14867
|
+
const authPasswordForm = (clientApp, loginPage, onUserLogin, onLoginError, backgroundImg) => {
|
|
14868
|
+
const result = document.createElement('form');
|
|
14869
|
+
const emailRow = authPasswordRow('email', 'username');
|
|
14870
|
+
const emailInput = emailRow.querySelector('input');
|
|
14871
|
+
const passwordRow = authPasswordRow('password', 'current-password');
|
|
14872
|
+
const passwordInput = passwordRow.querySelector('input');
|
|
14873
|
+
const togglePasswordDisplayBtn = document.createElement('button');
|
|
14874
|
+
togglePasswordDisplayBtn.type = 'button';
|
|
14875
|
+
togglePasswordDisplayBtn.addEventListener('click', (_ev) => {
|
|
14876
|
+
const passwordType = passwordInput.type === 'password' ? 'text' : 'password';
|
|
14877
|
+
passwordInput.type = passwordType;
|
|
14878
|
+
});
|
|
14879
|
+
passwordRow.appendChild(togglePasswordDisplayBtn);
|
|
14880
|
+
const handlePasswordLogin = () => onAuthPasswordLogin({ email: emailInput.value, password: passwordInput.value || null }, onUserLogin, onLoginError, onReturn, clientApp, backgroundImg);
|
|
14881
|
+
const onReturn = () => clientApp.appendChild(loginPage);
|
|
14882
|
+
const button = loginButton('Login', handlePasswordLogin);
|
|
14883
|
+
button.classList.add('auth-password');
|
|
14884
|
+
button.setAttribute('type', 'submit');
|
|
14885
|
+
const submitButton = document.createElement('button');
|
|
14886
|
+
submitButton.style.display = 'none';
|
|
14887
|
+
result.append(emailRow, passwordRow, button, submitButton);
|
|
14888
|
+
result.addEventListener('submit', (ev) => {
|
|
14889
|
+
ev.preventDefault();
|
|
14890
|
+
handlePasswordLogin();
|
|
14891
|
+
});
|
|
14892
|
+
return result;
|
|
14893
|
+
};
|
|
14855
14894
|
const onEmailLoginRequest = (clientApp, loginPage, onUserLogin, backgroundImage, loginTypes) => {
|
|
14856
14895
|
const onReturn = () => clientApp.appendChild(loginPage);
|
|
14857
14896
|
loginPage.appendChild(magicLinkModal(onUserLogin, onReturn, backgroundImage, loginPage, clientApp, loginTypes));
|
|
14858
14897
|
};
|
|
14859
|
-
const appendLoginTypes = (loginPage, section, clientApp, onUserLogin, loginTypes, backgroundImg) => {
|
|
14898
|
+
const appendLoginTypes = (loginPage, section, clientApp, onUserLogin, onLoginError, loginTypes, backgroundImg) => {
|
|
14860
14899
|
if (loginTypes.includes('Google')) {
|
|
14861
14900
|
section.appendChild(loginButton('Google', () => onGoogleSignIn(onUserLogin)));
|
|
14862
14901
|
}
|
|
@@ -14870,26 +14909,10 @@ var juxWeb = (function (exports) {
|
|
|
14870
14909
|
section.appendChild(loginButton('Email', () => onEmailLoginRequest(clientApp, loginPage, onUserLogin, backgroundImg, loginTypes)));
|
|
14871
14910
|
}
|
|
14872
14911
|
if (loginTypes.includes('auth-password')) {
|
|
14873
|
-
|
|
14874
|
-
emailField.id = 'input-email';
|
|
14875
|
-
emailField.type = 'email';
|
|
14876
|
-
const passwordRow = document.createElement('password-row');
|
|
14877
|
-
passwordRow.style.display = 'flex';
|
|
14878
|
-
const passwordField = document.createElement('input');
|
|
14879
|
-
passwordField.id = 'input-password';
|
|
14880
|
-
passwordField.type = 'password';
|
|
14881
|
-
const togglePasswordDisplayBtn = document.createElement('button');
|
|
14882
|
-
togglePasswordDisplayBtn.addEventListener('click', (_ev) => {
|
|
14883
|
-
const passwordType = passwordField.type === 'password' ? 'text' : 'password';
|
|
14884
|
-
passwordField.type = passwordType;
|
|
14885
|
-
});
|
|
14886
|
-
passwordRow.append(passwordField, togglePasswordDisplayBtn);
|
|
14887
|
-
const onReturn = () => clientApp.appendChild(loginPage);
|
|
14888
|
-
const button = loginButton('Login', () => onAuthPasswordLogin({ email: emailField.value, password: passwordField.value || null }, onUserLogin, onReturn, clientApp, backgroundImg));
|
|
14889
|
-
section.append(emailField, passwordRow, button);
|
|
14912
|
+
section.appendChild(authPasswordForm(clientApp, loginPage, onUserLogin, onLoginError, backgroundImg));
|
|
14890
14913
|
}
|
|
14891
14914
|
};
|
|
14892
|
-
const loginPage = (clientApp, backgroundImg, onUserLogin, loginTypes) => {
|
|
14915
|
+
const loginPage = (clientApp, backgroundImg, onUserLogin, onLoginError, loginTypes) => {
|
|
14893
14916
|
const content = [];
|
|
14894
14917
|
const salutation = document.createElement('sign-in-salutation');
|
|
14895
14918
|
salutation.textContent = getTranslation('sign-in-salutation');
|
|
@@ -14900,7 +14923,7 @@ var juxWeb = (function (exports) {
|
|
|
14900
14923
|
content.push(salutation, explanation, msg);
|
|
14901
14924
|
const result = basePage('login-page', backgroundImg, content);
|
|
14902
14925
|
const section = result.querySelector('section');
|
|
14903
|
-
appendLoginTypes(result, section, clientApp, onUserLogin, loginTypes, backgroundImg);
|
|
14926
|
+
appendLoginTypes(result, section, clientApp, onUserLogin, onLoginError, loginTypes, backgroundImg);
|
|
14904
14927
|
return result;
|
|
14905
14928
|
};
|
|
14906
14929
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const loginPage: (clientApp: HTMLElement, backgroundImg: string, onUserLogin: any, loginTypes: string[]) => HTMLElement;
|
|
1
|
+
export declare const loginPage: (clientApp: HTMLElement, backgroundImg: string, onUserLogin: any, onLoginError: any, loginTypes: string[]) => HTMLElement;
|
package/dist/login/session.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export declare const setBackendToken: (token: string) => void;
|
|
2
2
|
export declare const onTokenAcquired: (token: string, onUserLogin: any) => void;
|
|
3
|
-
export declare const initSession: (clientApp: HTMLElement, supportedLoginTypes: string[], onUserLogin: any, backgroundImage: string, fetchUserBackendUrl: any, magicLinkRequestEndpoint: string | null, magicLinkAuthEndpoint: string | null) => void;
|
|
3
|
+
export declare const initSession: (clientApp: HTMLElement, supportedLoginTypes: string[], onUserLogin: any, onLoginError: any, backgroundImage: string, fetchUserBackendUrl: any, magicLinkRequestEndpoint: string | null, magicLinkAuthEndpoint: string | null) => void;
|
|
4
4
|
export declare const onMicrosoftSignIn: (onUserLogin: any) => Promise<void>;
|
|
5
5
|
export declare const onGoogleSignIn: (onUserLogin: any) => void;
|
|
6
|
-
export declare const onAuthPasswordLogin: (credentials: any, onUserLogin: any, onReturn: any, clientApp: HTMLElement, backgroundImg: string) => void;
|
|
6
|
+
export declare const onAuthPasswordLogin: (credentials: any, onUserLogin: any, onLoginError: any, onReturn: any, clientApp: HTMLElement, backgroundImg: string) => void;
|
|
7
7
|
export declare const handleMagicLinkRequest: (token: string | null, onReturn: any, backgroundImage: string, currentPage: HTMLElement, clientBody: HTMLElement, email?: string) => void;
|
package/dist/main.esm.js
CHANGED
|
@@ -1041,7 +1041,7 @@ const handleSSOLogin = () => {
|
|
|
1041
1041
|
const onError = () => onAuthenticationFailure('login-failed');
|
|
1042
1042
|
getSSOAuthorizationEndpoint(onSuccess, onError);
|
|
1043
1043
|
};
|
|
1044
|
-
const initSession = (clientApp, supportedLoginTypes, onUserLogin, backgroundImage, fetchUserBackendUrl, magicLinkRequestEndpoint, magicLinkAuthEndpoint) => {
|
|
1044
|
+
const initSession = (clientApp, supportedLoginTypes, onUserLogin, onLoginError, backgroundImage, fetchUserBackendUrl, magicLinkRequestEndpoint, magicLinkAuthEndpoint) => {
|
|
1045
1045
|
// if (startNewDemo()) {
|
|
1046
1046
|
// initDemo(setBackendToken, onAuthentication);
|
|
1047
1047
|
// return;
|
|
@@ -1095,7 +1095,7 @@ const initSession = (clientApp, supportedLoginTypes, onUserLogin, backgroundImag
|
|
|
1095
1095
|
handleSSOLogin();
|
|
1096
1096
|
return;
|
|
1097
1097
|
}
|
|
1098
|
-
displayPage(clientApp, loginPage(clientApp, backgroundImage, onUserLogin, supportedLoginTypes));
|
|
1098
|
+
displayPage(clientApp, loginPage(clientApp, backgroundImage, onUserLogin, onLoginError, supportedLoginTypes));
|
|
1099
1099
|
// validateThirdPartyCookies(initGapi, () => displayPage(Page.LOGIN));
|
|
1100
1100
|
// checkMixpanel(() => mixpanel.track('View Login Page'));
|
|
1101
1101
|
};
|
|
@@ -1137,7 +1137,7 @@ const onGoogleSignIn = (onUserLogin) => {
|
|
|
1137
1137
|
authSignIn(onUserLogin);
|
|
1138
1138
|
}, onCookieError);
|
|
1139
1139
|
};
|
|
1140
|
-
const onAuthPasswordLogin = (credentials, onUserLogin, onReturn, clientApp, backgroundImg) => {
|
|
1140
|
+
const onAuthPasswordLogin = (credentials, onUserLogin, onLoginError, onReturn, clientApp, backgroundImg) => {
|
|
1141
1141
|
const { email } = credentials;
|
|
1142
1142
|
enableSignInLayout();
|
|
1143
1143
|
const onSuccess = (res) => {
|
|
@@ -1148,9 +1148,8 @@ const onAuthPasswordLogin = (credentials, onUserLogin, onReturn, clientApp, back
|
|
|
1148
1148
|
disableSignInLayout();
|
|
1149
1149
|
};
|
|
1150
1150
|
const onError = (err) => {
|
|
1151
|
-
console.error(err);
|
|
1152
|
-
reportError(err);
|
|
1153
1151
|
disableSignInLayout();
|
|
1152
|
+
onLoginError(err);
|
|
1154
1153
|
};
|
|
1155
1154
|
const onUnauthorized = () => {
|
|
1156
1155
|
disableSignInLayout();
|
|
@@ -1337,11 +1336,51 @@ const magicLinkModal = (onUserLogin, onReturn, backgroundImage, currentPage, cli
|
|
|
1337
1336
|
return result;
|
|
1338
1337
|
};
|
|
1339
1338
|
|
|
1339
|
+
const authPasswordRow = (type, autoCompleteValue) => {
|
|
1340
|
+
const result = document.createElement(`${type}-row`);
|
|
1341
|
+
result.style.display = 'flex';
|
|
1342
|
+
const label = document.createElement('label');
|
|
1343
|
+
label.textContent = type.charAt(0).toUpperCase() + type.slice(1);
|
|
1344
|
+
label.htmlFor = `input-${type}`;
|
|
1345
|
+
const input = document.createElement('input');
|
|
1346
|
+
input.id = `input-${type}`;
|
|
1347
|
+
input.type = type;
|
|
1348
|
+
input.autocomplete = autoCompleteValue;
|
|
1349
|
+
result.append(label, input);
|
|
1350
|
+
return result;
|
|
1351
|
+
};
|
|
1352
|
+
const authPasswordForm = (clientApp, loginPage, onUserLogin, onLoginError, backgroundImg) => {
|
|
1353
|
+
const result = document.createElement('form');
|
|
1354
|
+
const emailRow = authPasswordRow('email', 'username');
|
|
1355
|
+
const emailInput = emailRow.querySelector('input');
|
|
1356
|
+
const passwordRow = authPasswordRow('password', 'current-password');
|
|
1357
|
+
const passwordInput = passwordRow.querySelector('input');
|
|
1358
|
+
const togglePasswordDisplayBtn = document.createElement('button');
|
|
1359
|
+
togglePasswordDisplayBtn.type = 'button';
|
|
1360
|
+
togglePasswordDisplayBtn.addEventListener('click', (_ev) => {
|
|
1361
|
+
const passwordType = passwordInput.type === 'password' ? 'text' : 'password';
|
|
1362
|
+
passwordInput.type = passwordType;
|
|
1363
|
+
});
|
|
1364
|
+
passwordRow.appendChild(togglePasswordDisplayBtn);
|
|
1365
|
+
const handlePasswordLogin = () => onAuthPasswordLogin({ email: emailInput.value, password: passwordInput.value || null }, onUserLogin, onLoginError, onReturn, clientApp, backgroundImg);
|
|
1366
|
+
const onReturn = () => clientApp.appendChild(loginPage);
|
|
1367
|
+
const button = loginButton('Login', handlePasswordLogin);
|
|
1368
|
+
button.classList.add('auth-password');
|
|
1369
|
+
button.setAttribute('type', 'submit');
|
|
1370
|
+
const submitButton = document.createElement('button');
|
|
1371
|
+
submitButton.style.display = 'none';
|
|
1372
|
+
result.append(emailRow, passwordRow, button, submitButton);
|
|
1373
|
+
result.addEventListener('submit', (ev) => {
|
|
1374
|
+
ev.preventDefault();
|
|
1375
|
+
handlePasswordLogin();
|
|
1376
|
+
});
|
|
1377
|
+
return result;
|
|
1378
|
+
};
|
|
1340
1379
|
const onEmailLoginRequest = (clientApp, loginPage, onUserLogin, backgroundImage, loginTypes) => {
|
|
1341
1380
|
const onReturn = () => clientApp.appendChild(loginPage);
|
|
1342
1381
|
loginPage.appendChild(magicLinkModal(onUserLogin, onReturn, backgroundImage, loginPage, clientApp, loginTypes));
|
|
1343
1382
|
};
|
|
1344
|
-
const appendLoginTypes = (loginPage, section, clientApp, onUserLogin, loginTypes, backgroundImg) => {
|
|
1383
|
+
const appendLoginTypes = (loginPage, section, clientApp, onUserLogin, onLoginError, loginTypes, backgroundImg) => {
|
|
1345
1384
|
if (loginTypes.includes('Google')) {
|
|
1346
1385
|
section.appendChild(loginButton('Google', () => onGoogleSignIn(onUserLogin)));
|
|
1347
1386
|
}
|
|
@@ -1355,26 +1394,10 @@ const appendLoginTypes = (loginPage, section, clientApp, onUserLogin, loginTypes
|
|
|
1355
1394
|
section.appendChild(loginButton('Email', () => onEmailLoginRequest(clientApp, loginPage, onUserLogin, backgroundImg, loginTypes)));
|
|
1356
1395
|
}
|
|
1357
1396
|
if (loginTypes.includes('auth-password')) {
|
|
1358
|
-
|
|
1359
|
-
emailField.id = 'input-email';
|
|
1360
|
-
emailField.type = 'email';
|
|
1361
|
-
const passwordRow = document.createElement('password-row');
|
|
1362
|
-
passwordRow.style.display = 'flex';
|
|
1363
|
-
const passwordField = document.createElement('input');
|
|
1364
|
-
passwordField.id = 'input-password';
|
|
1365
|
-
passwordField.type = 'password';
|
|
1366
|
-
const togglePasswordDisplayBtn = document.createElement('button');
|
|
1367
|
-
togglePasswordDisplayBtn.addEventListener('click', (_ev) => {
|
|
1368
|
-
const passwordType = passwordField.type === 'password' ? 'text' : 'password';
|
|
1369
|
-
passwordField.type = passwordType;
|
|
1370
|
-
});
|
|
1371
|
-
passwordRow.append(passwordField, togglePasswordDisplayBtn);
|
|
1372
|
-
const onReturn = () => clientApp.appendChild(loginPage);
|
|
1373
|
-
const button = loginButton('Login', () => onAuthPasswordLogin({ email: emailField.value, password: passwordField.value || null }, onUserLogin, onReturn, clientApp, backgroundImg));
|
|
1374
|
-
section.append(emailField, passwordRow, button);
|
|
1397
|
+
section.appendChild(authPasswordForm(clientApp, loginPage, onUserLogin, onLoginError, backgroundImg));
|
|
1375
1398
|
}
|
|
1376
1399
|
};
|
|
1377
|
-
const loginPage = (clientApp, backgroundImg, onUserLogin, loginTypes) => {
|
|
1400
|
+
const loginPage = (clientApp, backgroundImg, onUserLogin, onLoginError, loginTypes) => {
|
|
1378
1401
|
const content = [];
|
|
1379
1402
|
const salutation = document.createElement('sign-in-salutation');
|
|
1380
1403
|
salutation.textContent = getTranslation('sign-in-salutation');
|
|
@@ -1385,7 +1408,7 @@ const loginPage = (clientApp, backgroundImg, onUserLogin, loginTypes) => {
|
|
|
1385
1408
|
content.push(salutation, explanation, msg);
|
|
1386
1409
|
const result = basePage('login-page', backgroundImg, content);
|
|
1387
1410
|
const section = result.querySelector('section');
|
|
1388
|
-
appendLoginTypes(result, section, clientApp, onUserLogin, loginTypes, backgroundImg);
|
|
1411
|
+
appendLoginTypes(result, section, clientApp, onUserLogin, onLoginError, loginTypes, backgroundImg);
|
|
1389
1412
|
return result;
|
|
1390
1413
|
};
|
|
1391
1414
|
|
package/dist/main.js
CHANGED
|
@@ -1065,7 +1065,7 @@ const handleSSOLogin = () => {
|
|
|
1065
1065
|
const onError = () => onAuthenticationFailure('login-failed');
|
|
1066
1066
|
getSSOAuthorizationEndpoint(onSuccess, onError);
|
|
1067
1067
|
};
|
|
1068
|
-
const initSession = (clientApp, supportedLoginTypes, onUserLogin, backgroundImage, fetchUserBackendUrl, magicLinkRequestEndpoint, magicLinkAuthEndpoint) => {
|
|
1068
|
+
const initSession = (clientApp, supportedLoginTypes, onUserLogin, onLoginError, backgroundImage, fetchUserBackendUrl, magicLinkRequestEndpoint, magicLinkAuthEndpoint) => {
|
|
1069
1069
|
// if (startNewDemo()) {
|
|
1070
1070
|
// initDemo(setBackendToken, onAuthentication);
|
|
1071
1071
|
// return;
|
|
@@ -1119,7 +1119,7 @@ const initSession = (clientApp, supportedLoginTypes, onUserLogin, backgroundImag
|
|
|
1119
1119
|
handleSSOLogin();
|
|
1120
1120
|
return;
|
|
1121
1121
|
}
|
|
1122
|
-
displayPage(clientApp, loginPage(clientApp, backgroundImage, onUserLogin, supportedLoginTypes));
|
|
1122
|
+
displayPage(clientApp, loginPage(clientApp, backgroundImage, onUserLogin, onLoginError, supportedLoginTypes));
|
|
1123
1123
|
// validateThirdPartyCookies(initGapi, () => displayPage(Page.LOGIN));
|
|
1124
1124
|
// checkMixpanel(() => mixpanel.track('View Login Page'));
|
|
1125
1125
|
};
|
|
@@ -1161,7 +1161,7 @@ const onGoogleSignIn = (onUserLogin) => {
|
|
|
1161
1161
|
authSignIn(onUserLogin);
|
|
1162
1162
|
}, onCookieError);
|
|
1163
1163
|
};
|
|
1164
|
-
const onAuthPasswordLogin = (credentials, onUserLogin, onReturn, clientApp, backgroundImg) => {
|
|
1164
|
+
const onAuthPasswordLogin = (credentials, onUserLogin, onLoginError, onReturn, clientApp, backgroundImg) => {
|
|
1165
1165
|
const { email } = credentials;
|
|
1166
1166
|
enableSignInLayout();
|
|
1167
1167
|
const onSuccess = (res) => {
|
|
@@ -1172,9 +1172,8 @@ const onAuthPasswordLogin = (credentials, onUserLogin, onReturn, clientApp, back
|
|
|
1172
1172
|
disableSignInLayout();
|
|
1173
1173
|
};
|
|
1174
1174
|
const onError = (err) => {
|
|
1175
|
-
console.error(err);
|
|
1176
|
-
reportError(err);
|
|
1177
1175
|
disableSignInLayout();
|
|
1176
|
+
onLoginError(err);
|
|
1178
1177
|
};
|
|
1179
1178
|
const onUnauthorized = () => {
|
|
1180
1179
|
disableSignInLayout();
|
|
@@ -1361,11 +1360,51 @@ const magicLinkModal = (onUserLogin, onReturn, backgroundImage, currentPage, cli
|
|
|
1361
1360
|
return result;
|
|
1362
1361
|
};
|
|
1363
1362
|
|
|
1363
|
+
const authPasswordRow = (type, autoCompleteValue) => {
|
|
1364
|
+
const result = document.createElement(`${type}-row`);
|
|
1365
|
+
result.style.display = 'flex';
|
|
1366
|
+
const label = document.createElement('label');
|
|
1367
|
+
label.textContent = type.charAt(0).toUpperCase() + type.slice(1);
|
|
1368
|
+
label.htmlFor = `input-${type}`;
|
|
1369
|
+
const input = document.createElement('input');
|
|
1370
|
+
input.id = `input-${type}`;
|
|
1371
|
+
input.type = type;
|
|
1372
|
+
input.autocomplete = autoCompleteValue;
|
|
1373
|
+
result.append(label, input);
|
|
1374
|
+
return result;
|
|
1375
|
+
};
|
|
1376
|
+
const authPasswordForm = (clientApp, loginPage, onUserLogin, onLoginError, backgroundImg) => {
|
|
1377
|
+
const result = document.createElement('form');
|
|
1378
|
+
const emailRow = authPasswordRow('email', 'username');
|
|
1379
|
+
const emailInput = emailRow.querySelector('input');
|
|
1380
|
+
const passwordRow = authPasswordRow('password', 'current-password');
|
|
1381
|
+
const passwordInput = passwordRow.querySelector('input');
|
|
1382
|
+
const togglePasswordDisplayBtn = document.createElement('button');
|
|
1383
|
+
togglePasswordDisplayBtn.type = 'button';
|
|
1384
|
+
togglePasswordDisplayBtn.addEventListener('click', (_ev) => {
|
|
1385
|
+
const passwordType = passwordInput.type === 'password' ? 'text' : 'password';
|
|
1386
|
+
passwordInput.type = passwordType;
|
|
1387
|
+
});
|
|
1388
|
+
passwordRow.appendChild(togglePasswordDisplayBtn);
|
|
1389
|
+
const handlePasswordLogin = () => onAuthPasswordLogin({ email: emailInput.value, password: passwordInput.value || null }, onUserLogin, onLoginError, onReturn, clientApp, backgroundImg);
|
|
1390
|
+
const onReturn = () => clientApp.appendChild(loginPage);
|
|
1391
|
+
const button = loginButton('Login', handlePasswordLogin);
|
|
1392
|
+
button.classList.add('auth-password');
|
|
1393
|
+
button.setAttribute('type', 'submit');
|
|
1394
|
+
const submitButton = document.createElement('button');
|
|
1395
|
+
submitButton.style.display = 'none';
|
|
1396
|
+
result.append(emailRow, passwordRow, button, submitButton);
|
|
1397
|
+
result.addEventListener('submit', (ev) => {
|
|
1398
|
+
ev.preventDefault();
|
|
1399
|
+
handlePasswordLogin();
|
|
1400
|
+
});
|
|
1401
|
+
return result;
|
|
1402
|
+
};
|
|
1364
1403
|
const onEmailLoginRequest = (clientApp, loginPage, onUserLogin, backgroundImage, loginTypes) => {
|
|
1365
1404
|
const onReturn = () => clientApp.appendChild(loginPage);
|
|
1366
1405
|
loginPage.appendChild(magicLinkModal(onUserLogin, onReturn, backgroundImage, loginPage, clientApp, loginTypes));
|
|
1367
1406
|
};
|
|
1368
|
-
const appendLoginTypes = (loginPage, section, clientApp, onUserLogin, loginTypes, backgroundImg) => {
|
|
1407
|
+
const appendLoginTypes = (loginPage, section, clientApp, onUserLogin, onLoginError, loginTypes, backgroundImg) => {
|
|
1369
1408
|
if (loginTypes.includes('Google')) {
|
|
1370
1409
|
section.appendChild(loginButton('Google', () => onGoogleSignIn(onUserLogin)));
|
|
1371
1410
|
}
|
|
@@ -1379,26 +1418,10 @@ const appendLoginTypes = (loginPage, section, clientApp, onUserLogin, loginTypes
|
|
|
1379
1418
|
section.appendChild(loginButton('Email', () => onEmailLoginRequest(clientApp, loginPage, onUserLogin, backgroundImg, loginTypes)));
|
|
1380
1419
|
}
|
|
1381
1420
|
if (loginTypes.includes('auth-password')) {
|
|
1382
|
-
|
|
1383
|
-
emailField.id = 'input-email';
|
|
1384
|
-
emailField.type = 'email';
|
|
1385
|
-
const passwordRow = document.createElement('password-row');
|
|
1386
|
-
passwordRow.style.display = 'flex';
|
|
1387
|
-
const passwordField = document.createElement('input');
|
|
1388
|
-
passwordField.id = 'input-password';
|
|
1389
|
-
passwordField.type = 'password';
|
|
1390
|
-
const togglePasswordDisplayBtn = document.createElement('button');
|
|
1391
|
-
togglePasswordDisplayBtn.addEventListener('click', (_ev) => {
|
|
1392
|
-
const passwordType = passwordField.type === 'password' ? 'text' : 'password';
|
|
1393
|
-
passwordField.type = passwordType;
|
|
1394
|
-
});
|
|
1395
|
-
passwordRow.append(passwordField, togglePasswordDisplayBtn);
|
|
1396
|
-
const onReturn = () => clientApp.appendChild(loginPage);
|
|
1397
|
-
const button = loginButton('Login', () => onAuthPasswordLogin({ email: emailField.value, password: passwordField.value || null }, onUserLogin, onReturn, clientApp, backgroundImg));
|
|
1398
|
-
section.append(emailField, passwordRow, button);
|
|
1421
|
+
section.appendChild(authPasswordForm(clientApp, loginPage, onUserLogin, onLoginError, backgroundImg));
|
|
1399
1422
|
}
|
|
1400
1423
|
};
|
|
1401
|
-
const loginPage = (clientApp, backgroundImg, onUserLogin, loginTypes) => {
|
|
1424
|
+
const loginPage = (clientApp, backgroundImg, onUserLogin, onLoginError, loginTypes) => {
|
|
1402
1425
|
const content = [];
|
|
1403
1426
|
const salutation = document.createElement('sign-in-salutation');
|
|
1404
1427
|
salutation.textContent = getTranslation('sign-in-salutation');
|
|
@@ -1409,7 +1432,7 @@ const loginPage = (clientApp, backgroundImg, onUserLogin, loginTypes) => {
|
|
|
1409
1432
|
content.push(salutation, explanation, msg);
|
|
1410
1433
|
const result = basePage('login-page', backgroundImg, content);
|
|
1411
1434
|
const section = result.querySelector('section');
|
|
1412
|
-
appendLoginTypes(result, section, clientApp, onUserLogin, loginTypes, backgroundImg);
|
|
1435
|
+
appendLoginTypes(result, section, clientApp, onUserLogin, onLoginError, loginTypes, backgroundImg);
|
|
1413
1436
|
return result;
|
|
1414
1437
|
};
|
|
1415
1438
|
|