Skip to content

Node.js based forum software built for the modern web

feat: open intent registration modal in login and register pages

Julian Lamc4871938bf51
diff --git a/public/language/en-GB/login.json b/public/language/en-GB/login.json
index c82659ae4c..b1ae05e4ae 100644
--- a/public/language/en-GB/login.json
+++ b/public/language/en-GB/login.json
@@ -8,5 +8,6 @@
"login-successful": "You have successfully logged in!",
"dont-have-account": "Don't have an account?",
"logged-out-due-to-inactivity": "You have been logged out of the Admin Control Panel due to inactivity",
- "caps-lock-enabled": "Caps Lock is enabled"
+ "caps-lock-enabled": "Caps Lock is enabled",
+ "manage-social-web-handles": "Manage Open Social Web Handles"
}
diff --git a/public/openapi/read/login.yaml b/public/openapi/read/login.yaml
index 4e5b3944a9..f0369f451f 100644
--- a/public/openapi/read/login.yaml
+++ b/public/openapi/read/login.yaml
@@ -27,6 +27,8 @@ get:
description: Custom identifier (value is added to `input[id]` and `label[for]`)
alternate_logins:
type: boolean
+ osw_logins:
+ type: boolean
authentication:
type: array
items:
diff --git a/public/openapi/read/register.yaml b/public/openapi/read/register.yaml
index b4ec6d4fbc..505e4dc25d 100644
--- a/public/openapi/read/register.yaml
+++ b/public/openapi/read/register.yaml
@@ -15,6 +15,8 @@ get:
type: string
alternate_logins:
type: boolean
+ osw_logins:
+ type: boolean
authentication:
type: array
items:
diff --git a/public/src/client/login.js b/public/src/client/login.js
index f7508b8ec2..0ec1afaaa2 100644
--- a/public/src/client/login.js
+++ b/public/src/client/login.js
@@ -94,6 +94,12 @@ define('forum/login', ['hooks', 'translator', 'jquery-form'], function (hooks, t
$('#content #username').focus();
}
$('#content #noscript').val('false');
+
+ $('#ap-register-handle-btn').on('click', function () {
+ require(['modules/intents'], (intents) => {
+ intents.register();
+ });
+ });
};
Login.capsLockCheck = (inputEl, warningEl) => {
diff --git a/public/src/client/register.js b/public/src/client/register.js
index 1cd0570ded..ad3878d7d2 100644
--- a/public/src/client/register.js
+++ b/public/src/client/register.js
@@ -112,6 +112,12 @@ define('forum/register', [
// Set initial focus
$('#username').trigger('focus');
+
+ $('#ap-register-handle-btn').on('click', function () {
+ require(['modules/intents'], (intents) => {
+ intents.register();
+ });
+ });
};
function validateUsername(username, callback) {
diff --git a/public/src/modules/intents.js b/public/src/modules/intents.js
index 75a8ed713b..eca46b2439 100644
--- a/public/src/modules/intents.js
+++ b/public/src/modules/intents.js
@@ -100,15 +100,11 @@ export function register() {
description: '[[intents:description]]',
handles,
}, (html) => {
- const modal = bootbox.dialog({
+ const modal = dialog({
title: '[[intents:title]]',
message: html,
});
- // html.on('hidden.bs.modal', function () {
- // html.remove();
- // });
-
const handleInput = modal.find('#intents-handle-input');
const submitBtn = modal.find('#intents-register-btn');
diff --git a/src/controllers/index.js b/src/controllers/index.js
index 2e55cfe646..969f618673 100644
--- a/src/controllers/index.js
+++ b/src/controllers/index.js
@@ -119,6 +119,7 @@ Controllers.login = async function (req, res) {
req.session.returnTo = req.session.returnTo && req.session.returnTo.replace(nconf.get('base_url'), '').replace(nconf.get('relative_path'), '');
data.alternate_logins = loginStrategies.length > 0;
+ data.osw_logins = !!meta.config.activitypubEnabled;
data.authentication = loginStrategies;
data.allowRegistration = registrationType === 'normal';
data.allowLoginWith = `[[login:${allowLoginWith}]]`;
@@ -177,6 +178,7 @@ Controllers.register = async function (req, res, next) {
res.render('register', {
'register_window:spansize': loginStrategies.length ? 'col-md-6' : 'col-md-12',
alternate_logins: !!loginStrategies.length,
+ osw_logins: !!meta.config.activitypubEnabled,
authentication: loginStrategies,
minimumUsernameLength: meta.config.minimumUsernameLength,
diff --git a/src/views/login.tpl b/src/views/login.tpl
index 13ca55b8fa..2510d67aec 100644
--- a/src/views/login.tpl
+++ b/src/views/login.tpl
@@ -55,10 +55,16 @@
<hr/>
+ {{{ if (allowRegistration || osw_logins) }}}<span class="text-sm">[[login:dont-have-account]]</span>{{{ end }}}
{{{ if allowRegistration }}}
- <span class="text-sm">[[login:dont-have-account]]</span>
<a class="btn btn-outline-light text-body" href="{config.relative_path}/register">[[register:register]]</a>
{{{ end }}}
+
+ {{{ if osw_logins }}}
+ <button class="btn btn-outline-light text-body" id="ap-register-handle-btn" type="button">
+ <i class="fa fa-share-alt"></i> [[login:manage-social-web-handles]]
+ </button>
+ {{{ end }}}
</form>
</div>
</div>
diff --git a/src/views/register.tpl b/src/views/register.tpl
index ca7fac3664..c1e08206b7 100644
--- a/src/views/register.tpl
+++ b/src/views/register.tpl
@@ -59,6 +59,12 @@
<span class="text-sm">[[register:already-have-account]]</span>
<a class="btn btn-outline-light text-body" href="{config.relative_path}/login">[[global:login]]</a>
+ {{{ if osw_logins }}}
+ <button class="btn btn-outline-light text-body" id="ap-register-handle-btn" type="button">
+ <i class="fa fa-share-alt"></i> [[login:manage-social-web-handles]]
+ </button>
+ {{{ end }}}
+
<input id="token" type="hidden" name="token" value="" />
<input id="noscript" type="hidden" name="noscript" value="true" />
<input type="hidden" name="_csrf" value="{config.csrf_token}" />