Add extension point after user account creation

This commit is contained in:
yflory 2025-05-28 17:33:03 +02:00
parent 17cc6b43df
commit a5ea001ef1
4 changed files with 40 additions and 20 deletions

View File

@ -104,9 +104,9 @@ define([
var proceed = function (result) {
hashing = false;
if (cb && typeof cb === "function" && cb(result)) { return; }
LocalStore.clearLoginToken();
Realtime.whenRealtimeSyncs(result.realtime, function () {
if (cb && typeof cb === "function" && cb(result)) { return; }
LocalStore.clearLoginToken();
Exports.redirect();
});
};

View File

@ -9,8 +9,7 @@ define([
'/common/common-interface.js',
'/customize/messages.js',
'/customize/pages.js',
'/common/extensions.js'
], function (Config, $, h, UI, Msg, Pages, Extensions) {
], function (Config, $, h, UI, Msg, Pages) {
return function () {
document.title = Msg.register_header;
var tos = $(UI.createCheckbox('accept-terms')).find('.cp-checkmark-label').append(Msg.register_acceptTerms).parent()[0];
@ -47,16 +46,6 @@ define([
$('body').addClass('cp-register-closed');
}
let extensions = [];
let utils = { h };
Extensions.getExtensionsSync('REGISTER_FORM').forEach(ext => {
try {
extensions.push(ext.getContent(utils));
} catch (error) {
console.error(error);
}
});
return frame([
h('div.cp-restricted-registration', [
h('p', Msg.register_registrationIsClosed),
@ -110,7 +99,6 @@ define([
UI.createCheckbox('import-recent', Msg.register_importRecent, true)
]),
termsCheck,
extensions,
h('button#register', Msg.login_register),
]),
h('div#ssoForm.form-group.col-md-6'+ssoEnabled, [
@ -118,7 +106,7 @@ define([
]),
]),
h('div.col-md-3.cp-closed-filler'+ssoEnabled),
])
]),
]);
};
});

View File

@ -1124,6 +1124,13 @@ define([
$('head > link[href^="/customize/src/pre-loading.css"]').remove();
$('html').toggleClass('cp-loading-noscroll', false);
};
UI.emptyLoadingScreen = function (content) {
UI.addLoadingScreen();
var $loading = $('#' + LOADING);
$loading.find('.cp-loading-container').hide();
$loading.find('.cp-loading-logo').hide();
$loading.append(content);
};
UI.errorLoadingScreen = function (error, transparent, exitable) {
if (error === 'Error: XDR encoding failure') {
console.warn(error);

View File

@ -15,10 +15,11 @@ define([
'/common/common-feedback.js',
'/common/outer/local-store.js',
'/common/hyperscript.js',
'/common/extensions.js',
'/customize/pages.js',
'css!/components/components-font-awesome/css/font-awesome.min.css',
], function (Config, $, Login, Cryptpad, Cred, UI, Util, Realtime, Constants, Feedback, LocalStore, h, Pages) {
], function (Config, $, Login, Cryptpad, Cred, UI, Util, Realtime, Constants, Feedback, LocalStore, h, Extensions, Pages) {
if (window.top !== window) { return; }
var Messages = Cryptpad.Messages;
$(function () {
@ -146,6 +147,30 @@ define([
return void UI.alert(Messages.register_mustAcceptTerms);
}
const extensions = [];
Extensions.getExtensionsSync('POST_REGISTER').forEach(ext => {
try {
extensions.push(ext);
} catch (error) {
console.error(error);
}
});
const cb = (data) => {
console.error(data);
const next = Util.mkAsync(() => {
Login.redirect();
});
if (!extensions.length) {
next();
} else {
extensions.forEach(ext => {
const content = ext.getContent();
UI.emptyLoadingScreen(content);
});
}
return true;
};
setTimeout(function () {
var span = h('span', [
h('h2', [
@ -156,8 +181,7 @@ define([
Messages.register_warning_note
]);
UI.confirm(span,
function (yes) {
UI.confirm(span, function (yes) {
if (!yes) { return; }
Login.loginOrRegisterUI({
@ -166,7 +190,8 @@ define([
token,
isRegister: true,
shouldImport,
onOTP: UI.getOTPScreen
onOTP: UI.getOTPScreen,
cb
});
}, {
ok: Messages.register_writtenPassword,