Skip to content

Commit

Permalink
fix: Login Terms custom content (#28999)
Browse files Browse the repository at this point in the history
  • Loading branch information
hugocostadev authored May 31, 2023
1 parent 9959bc6 commit ebbb608
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 17 deletions.
7 changes: 7 additions & 0 deletions .changeset/login-terms.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@rocket.chat/meteor": patch
"@rocket.chat/web-ui-registration": patch
---

fix: Login Terms custom content
The custom layout Login Terms did not had any effect on the login screen, so it was changed to get the proper setting effect
1 change: 1 addition & 0 deletions apps/meteor/packages/rocketchat-i18n/i18n/en.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -2815,6 +2815,7 @@
"Layout_Home_Title": "Home Title",
"Layout_Legal_Notice": "Legal Notice",
"Layout_Login_Terms": "Login Terms",
"Layout_Login_Terms_Content": "By proceeding you are agreeing to our <a href='terms-of-service'>Terms of Service</a>, <a href='privacy-policy'>Privacy Policy</a> and <a href='legal-notice'>Legal Notice</a>.",
"Layout_Privacy_Policy": "Privacy Policy",
"Layout_Show_Home_Button": "Show home page button on sidebar header",
"Layout_Custom_Content_Description": "Here goes your custom content. It may be placed inside a white block or may take the all space available in the homepage, if you’re on Enterprise.",
Expand Down
3 changes: 2 additions & 1 deletion apps/meteor/packages/rocketchat-i18n/i18n/pt-BR.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -2478,6 +2478,7 @@
"Layout_Home_Title": "Título da página inicial",
"Layout_Legal_Notice": "Aviso legal",
"Layout_Login_Terms": "Termos de login",
"Layout_Login_Terms_Content": "Ao continuar você está concordando com nossos <a href='terms-of-service'>Termos de Serviço</a>, <a href='privacy-policy'>Política de Privacidade</a> e <a href='legal-notice'>Aviso Legal</a>.",
"Layout_Privacy_Policy": "Política de privacidade",
"Layout_Show_Home_Button": "Exibir \"Botão da página inicial\"",
"Layout_Sidenav_Footer": "Rodapé da navegação lateral",
Expand Down Expand Up @@ -4985,4 +4986,4 @@
"RegisterWorkspace_Features_Omnichannel_Title": "Omnichannel",
"RegisterWorkspace_Setup_Label": "E-mail da conta da nuvem",
"cloud.RegisterWorkspace_Setup_Terms_Privacy": "Eu concordo com os <1>Termos e condições</1> e a <3>Política de privacidade</3>"
}
}
15 changes: 6 additions & 9 deletions apps/meteor/server/settings/layout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,15 +108,12 @@ export const createLayoutSettings = () =>
multiline: true,
public: true,
});
await this.add(
'Layout_Login_Terms',
'By proceeding you are agreeing to our <a href="terms-of-service">Terms of Service</a>, <a href="privacy-policy">Privacy Policy</a> and <a href="legal-notice">Legal Notice</a>.',
{
type: 'string',
multiline: true,
public: true,
},
);
await this.add('Layout_Login_Terms', '', {
type: 'code',
code: 'text/html',
multiline: true,
public: true,
});
await this.add('Layout_Privacy_Policy', 'Privacy Policy <br> Go to APP SETTINGS &rarr; Layout to customize this page.', {
type: 'code',
code: 'text/html',
Expand Down
1 change: 1 addition & 0 deletions apps/meteor/server/startup/migrations/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,5 @@ import './v292';
import './v293';
import './v294';
import './v295';
import './v296';
import './xrun';
21 changes: 21 additions & 0 deletions apps/meteor/server/startup/migrations/v296.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { Settings } from '@rocket.chat/models';

import { addMigration } from '../../lib/migrations';
import { SystemLogger } from '../../lib/logger/system';
import { settings } from '../../../app/settings/server';

addMigration({
version: 296,
name: 'Reset the default value of Login Terms setting and replace by empty string',
async up() {
const oldLoginTermsValue =
'By proceeding you are agreeing to our <a href="terms-of-service">Terms of Service</a>, <a href="privacy-policy">Privacy Policy</a> and <a href="legal-notice">Legal Notice</a>.';

const loginTermsValue = settings.get('Layout_Login_Terms');

if (loginTermsValue === oldLoginTermsValue) {
await Settings.updateOne({ _id: 'Layout_Login_Terms' }, { $set: { value: '', packageValue: '' } });
SystemLogger.warn(`The default value of the setting 'Login Terms' has changed to an empty string. Please review your settings.`);
}
},
});
15 changes: 8 additions & 7 deletions packages/web-ui-registration/src/components/LoginTerms.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import { Trans } from 'react-i18next';
import type { ReactElement } from 'react';
import { Link, HorizontalWizardLayoutCaption } from '@rocket.chat/layout';
import { HorizontalWizardLayoutCaption } from '@rocket.chat/layout';
import { useSetting } from '@rocket.chat/ui-contexts';
import { Box } from '@rocket.chat/fuselage';
import { useTranslation } from 'react-i18next';

export const LoginTerms = (): ReactElement => {
const { t } = useTranslation();
const loginTerms = useSetting('Layout_Login_Terms') as string;

return (
<HorizontalWizardLayoutCaption>
<Trans
defaults='By proceeding you are agreeing to our <0>{{terms}}</0>, <1>{{privacyPolicy}}</1> and <2>{{legalNotice}}</2>.'
values={{ terms: 'Terms of Service', privacyPolicy: 'Privacy Policy', legalNotice: 'Legal Notice' }}
components={[<Link href='/terms-of-service' />, <Link href='/privacy-policy' />, <Link href='/legal-notice' />]}
/>
<Box withRichContent dangerouslySetInnerHTML={{ __html: loginTerms !== '' ? loginTerms : t('Layout_Login_Terms_Content') }} />
</HorizontalWizardLayoutCaption>
);
};
Expand Down

0 comments on commit ebbb608

Please sign in to comment.