Resolve Issue #93

This commit is contained in:
djmaze 2021-05-31 16:19:01 +02:00
parent 5a6c012b60
commit d67cfaa3a4
13 changed files with 169 additions and 6 deletions

View file

@ -145,6 +145,8 @@ function buildViewModel(ViewModelClass, vmScreen) {
if (vm && ViewType.Popup === position) {
vm.registerPopupKeyDown();
}
dispatchEvent(new CustomEvent('rl-view-model', {detail:vm}));
} else {
console.log('Cannot find view model position: ' + position);
}

View file

@ -0,0 +1,33 @@
(rl => {
if (rl) {
const
forgotUrl = rl.settings.get('forgotPasswordLinkUrl'),
registerUrl = rl.settings.get('registrationLinkUrl');
if (forgotUrl || registerUrl) {
addEventListener('rl-view-model', e => {
if (e.detail && 'Login' === e.detail.viewModelTemplateID) {
const container = e.detail.viewModelDom.querySelector('#plugin-Login-BottomControlGroup'),
forgot = 'LOGIN/LABEL_FORGOT_PASSWORD',
register = 'LOGIN/LABEL_REGISTRATION';
if (container) {
let html = '';
if (forgotUrl) {
html = html + '<p class="forgot-link">'
+ '<a href="'+forgotUrl+'" target="_blank" class="g-ui-link" data-i18n="'+forgot+'">'+rl.i18n(forgot)+'</a>'
+ '</p>';
}
if (registerUrl) {
html = html + '<p class="registration-link">'
+ '<a href="'+registerUrl+'" target="_blank" class="g-ui-link" data-i18n="'+register+'">'+rl.i18n(register)+'</a>'
+ '</p>';
}
container.append(Element.fromHTML('<div class="controls clearfix">' + html + '</div>'));
}
}
});
}
}
})(window.rl);

View file

@ -0,0 +1,42 @@
<?php
class LoginRegisterPlugin extends \RainLoop\Plugins\AbstractPlugin
{
const
NAME = 'Register and Forgot',
VERSION = '2.0',
RELEASE = '2021-06-01',
REQUIRED = '2.5.2',
CATEGORY = 'Login',
DESCRIPTION = 'Links on login screen for registration and forgot password';
public function Init() : void
{
$this->UseLangs(true);
$this->addJs('LoginRegister.js');
$this->addHook('filter.app-data', 'FilterAppData');
}
public function configMapping() : array
{
return [
\RainLoop\Plugins\Property::NewInstance("forgot_password_link_url")
// ->SetLabel('TAB_LOGIN/LABEL_FORGOT_PASSWORD_LINK_URL')
->SetLabel('Forgot password url')
->SetType(\RainLoop\Enumerations\PluginPropertyType::URL),
\RainLoop\Plugins\Property::NewInstance("registration_link_url")
// ->SetLabel('TAB_LOGIN/LABEL_REGISTRATION_LINK_URL')
->SetLabel('Register url')
->SetType(\RainLoop\Enumerations\PluginPropertyType::URL),
];
}
public function FilterAppData($bAdmin, &$aResult)
{
if (!$bAdmin && \is_array($aResult) && empty($aResult['Auth'])) {
$aResult['forgotPasswordLinkUrl'] = \trim($this->Config()->Get('plugin', 'forgot_password_link_url', ''));
$aResult['registrationLinkUrl'] = \trim($this->Config()->Get('plugin', 'registration_link_url', ''));
}
}
}

View file

@ -0,0 +1,10 @@
{
"LOGIN": {
"LABEL_FORGOT_PASSWORD": "Passwort vergessen",
"LABEL_REGISTRATION": "Registrieren"
},
"TAB_LOGIN": {
"LABEL_FORGOT_PASSWORD_LINK_URL": "Forgot password url",
"LABEL_REGISTRATION_LINK_URL": "Register url"
}
}

View file

@ -0,0 +1,10 @@
{
"LOGIN": {
"LABEL_FORGOT_PASSWORD": "Forgot password",
"LABEL_REGISTRATION": "Register"
},
"TAB_LOGIN": {
"LABEL_FORGOT_PASSWORD_LINK_URL": "Forgot password url",
"LABEL_REGISTRATION_LINK_URL": "Register url"
}
}

View file

@ -0,0 +1,10 @@
{
"LOGIN": {
"LABEL_FORGOT_PASSWORD": "Olvidé mi contraseña",
"LABEL_REGISTRATION": "Registrarse"
},
"TAB_LOGIN": {
"LABEL_FORGOT_PASSWORD_LINK_URL": "Forgot password url",
"LABEL_REGISTRATION_LINK_URL": "Register url"
}
}

View file

@ -0,0 +1,10 @@
{
"LOGIN": {
"LABEL_FORGOT_PASSWORD": "Mot de passe oublié",
"LABEL_REGISTRATION": "S'enregistrer"
},
"TAB_LOGIN": {
"LABEL_FORGOT_PASSWORD_LINK_URL": "Forgot password url",
"LABEL_REGISTRATION_LINK_URL": "Register url"
}
}

View file

@ -0,0 +1,10 @@
{
"LOGIN": {
"LABEL_FORGOT_PASSWORD": "Elfelejtett jelszó",
"LABEL_REGISTRATION": "Regisztráció"
},
"TAB_LOGIN": {
"LABEL_FORGOT_PASSWORD_LINK_URL": "Forgot password url",
"LABEL_REGISTRATION_LINK_URL": "Register url"
}
}

View file

@ -0,0 +1,10 @@
{
"LOGIN": {
"LABEL_FORGOT_PASSWORD": "Wachtwoord vergeten",
"LABEL_REGISTRATION": "Registreren"
},
"TAB_LOGIN": {
"LABEL_FORGOT_PASSWORD_LINK_URL": "Forgot password url",
"LABEL_REGISTRATION_LINK_URL": "Register url"
}
}

View file

@ -0,0 +1,10 @@
{
"LOGIN": {
"LABEL_FORGOT_PASSWORD": "Glömt lösenord",
"LABEL_REGISTRATION": "Registrera"
},
"TAB_LOGIN": {
"LABEL_FORGOT_PASSWORD_LINK_URL": "Forgot password url",
"LABEL_REGISTRATION_LINK_URL": "Register url"
}
}

View file

@ -0,0 +1,10 @@
{
"LOGIN": {
"LABEL_FORGOT_PASSWORD": "忘记密码",
"LABEL_REGISTRATION": "注册"
},
"TAB_LOGIN": {
"LABEL_FORGOT_PASSWORD_LINK_URL": "Forgot password url",
"LABEL_REGISTRATION_LINK_URL": "Register url"
}
}

View file

@ -4,10 +4,12 @@ namespace RainLoop\Enumerations;
class PluginPropertyType
{
const STRING = 0;
const INT = 1;
const STRING_TEXT = 2;
const PASSWORD = 3;
const SELECTION = 4;
const BOOL = 5;
const
STRING = 0,
INT = 1,
STRING_TEXT = 2,
PASSWORD = 3,
SELECTION = 4,
BOOL = 5,
URL = 6;
}

View file

@ -28,6 +28,10 @@
params: { value: value, label: Label }
}"></div>
<!-- /ko -->
<!-- ko if: 6 === Type -->
<input type="url"
data-bind="value: value, attr: {placeholder: placeholder}" />
<!-- /ko -->
<span class="help-block" data-bind="text: Desc, visible: '' !== Desc"></span>
</div>
<br />