Commit ac125b9b by Jan Hrabal

terms

parent 756ea1b4
-- default admin user -- default admin user
insert into APP_ROLE (ID, NAME) values (1, 'ADMIN'); insert into APP_ROLE (ID, NAME) values (1, 'ADMIN');
insert into APP_USER (ID, EMAIL, FIRST_NAME, LAST_NAME, PASSWORD, PASSWORD_SALT, LOCALE, TIMEZONE_ID) VAlUES (1, 'janhrabal@seznam.cz', 'Jan', 'Hrabal', 'NKz1rz7kSEBXFGbolvEhdomvcDQYmD0IKGADVpuoxL1ztsE1NAnOMvbiSkvc3vwLQvBdPHw449XzgRderNJc9MMnnMTEgJdl3S6dtBGiEYDRHK19toXdwttfaDrXewjyZBJkzy7CxE/BOad4XkiTreIFAUGRedK9TGZ+RWbrJ2KIRrkSX3H1J2eT7HLF8bblkxz2qhjsF5s0k37e3sFI0xAdyCy6qAYS4/MW4WYQ3o0YyZc4krGE2k3y9kfPxWEh/favQKoFIX92ZkRh6ZIXNF7i4oUBl1pcg6r5ykCT83IAWm9avM768NEitEVOx0V8P0PQ2WxGA3n7nicKmwYjow==', 'GACR2Rea1kIhZAlImqK8HauZwTah5eMyKiTzr9HDriryN92YkE5UkWe3Gn7oRLkKEftaNfEfa2Ujj18Rrsed2a6QN69UZCkpRHnwgoBp5ckOOaC6s4undHSjYZW5rJx8CuKXTJpO1TS1LlsjwCyir8oA2gGm480jgGwOefm+r2s=', 'en', 'UTC'); insert into APP_USER (ID, EMAIL, FIRST_NAME, LAST_NAME, PASSWORD, PASSWORD_SALT, LOCALE, TIMEZONE_ID) VAlUES (1, 'janhrabal@seznam.cz', 'Jan', 'Hrabal', 'NKz1rz7kSEBXFGbolvEhdomvcDQYmD0IKGADVpuoxL1ztsE1NAnOMvbiSkvc3vwLQvBdPHw449XzgRderNJc9MMnnMTEgJdl3S6dtBGiEYDRHK19toXdwttfaDrXewjyZBJkzy7CxE/BOad4XkiTreIFAUGRedK9TGZ+RWbrJ2KIRrkSX3H1J2eT7HLF8bblkxz2qhjsF5s0k37e3sFI0xAdyCy6qAYS4/MW4WYQ3o0YyZc4krGE2k3y9kfPxWEh/favQKoFIX92ZkRh6ZIXNF7i4oUBl1pcg6r5ykCT83IAWm9avM768NEitEVOx0V8P0PQ2WxGA3n7nicKmwYjow==', 'GACR2Rea1kIhZAlImqK8HauZwTah5eMyKiTzr9HDriryN92YkE5UkWe3Gn7oRLkKEftaNfEfa2Ujj18Rrsed2a6QN69UZCkpRHnwgoBp5ckOOaC6s4undHSjYZW5rJx8CuKXTJpO1TS1LlsjwCyir8oA2gGm480jgGwOefm+r2s=', 'en', 'UTC');
insert into APP_USER_ROLE (USER_ID, ROLE_ID) values (1, 1); insert into APP_USER_ROLE (USER_ID, ROLE_ID) values (1, 1);
-- default templates -- default templates
insert into TEMPLATE (ID, CODE, TEMPLATE) values (1, 'email.layout', '{{content}}'); insert into TEMPLATE (ID, CODE, TEMPLATE) values (1, 'email.layout', '{{content}}');
insert into TEMPLATE (ID, CODE, TEMPLATE) values (2, 'email.signup.subject', 'Welcome to ...'); insert into TEMPLATE (ID, CODE, TEMPLATE) values (2, 'email.signup.subject', 'Welcome to ...');
insert into TEMPLATE (ID, CODE, TEMPLATE) values (3, 'email.signup.text', 'Welcome to ...'); insert into TEMPLATE (ID, CODE, TEMPLATE) values (3, 'email.signup.text', 'Welcome to ...');
insert into TEMPLATE (ID, CODE, TEMPLATE) values (4, 'email.signup.html', 'Welcome to ...'); insert into TEMPLATE (ID, CODE, TEMPLATE) values (4, 'email.signup.html', 'Welcome to ...');
insert into TEMPLATE (ID, CODE, TEMPLATE) values (5, 'email.password.subject', 'Password subject'); insert into TEMPLATE (ID, CODE, TEMPLATE) values (5, 'email.password.subject', 'Password subject');
insert into TEMPLATE (ID, CODE, TEMPLATE) values (6, 'email.password.text', 'Password text {{token}}'); insert into TEMPLATE (ID, CODE, TEMPLATE) values (6, 'email.password.text', 'Password text {{token}}');
insert into TEMPLATE (ID, CODE, TEMPLATE) values (7, 'email.password.html', 'Password HTML'); insert into TEMPLATE (ID, CODE, TEMPLATE) values (7, 'email.password.html', 'Password HTML');
-- legal documents
insert into LEGAL_DOCUMENT (ID, CODE, LOCALE, CONTENT) values (1, 'AUTH.TERMS', '<p>By using the Inodio service you are
agreeing to be bound by the following terms and conditions ("Terms of Service"). IF YOU ARE
ENTERING INTO THIS AGREEMENT ON BEHALF OF A COMPANY OR OTHER LEGAL ENTITY, YOU REPRESENT THAT
YOU HAVE THE AUTHORITY TO BIND SUCH ENTITY, ITS AFFILIATES AND ALL USERS WHO ACCESS OUR SERVICES
THROUGH YOUR ACCOUNT TO THESE TERMS AND CONDITIONS, IN WHICH CASE THE TERMS "YOU" OR "YOUR"
SHALL REFER TO SUCH ENTITY, ITS AFFILIATES AND USERS ASSOCIATED WITH IT. IF YOU DO NOT HAVE SUCH
AUTHORITY, OR IF YOU DO NOT AGREE WITH THESE TERMS AND CONDITIONS, YOU MUST NOT ACCEPT THIS
AGREEMENT AND MAY NOT USE THE SERVICES.</p>
<p>Entity "JH" will further represent company "Jan Hrabal, Prostřední 2249, Zlín, Czech Republic. </p>
<p>If "JH" makes material changes to these Terms, we will notify you by email or by posting a
notice on our site before the changes are effective. Any new features that augment or enhance
the current Service, including the release of new tools and resources, shall be subject to the
Terms of Service. Continued use of the Service after any such changes shall constitute your
consent to such changes. You can review the most current version of the Terms of Service at any
time at: <a href="url">url</a></p>
<p>Violation of any of the terms below might result in the termination of your Account. While
"JH"
prohibits such conduct and Content on the Service, you understand and agree that "JH" cannot
be responsible for the Content posted on the Service and you nonetheless may be exposed to such
materials. You agree to use the Service at your own risk.</p>
<ol type="A">
<li><b>Account Terms</b>
<ol>
<li><p>You must be 13 years or older to use this Service.</p></li>
<li><p>You must be a human. Accounts registered by "bots" or other automated methods are not
permitted.</p></li>
<li><p>You must provide your name, a valid email address, and any other information requested in
order to complete the signup process.</p></li>
<li><p>You are responsible for maintaining the security of your account and password. "JH"
cannot and will not be liable for any loss or damage from your failure to comply with this
security obligation.</p></li>
<li><p>You are responsible for all Content posted and activity that occurs under your account
(even when Content is posted by others who have accounts under your account).</p></li>
<li><p>One person or legal entity may not maintain more than one free account.</p></li>
<li><p>You may not use the Service for any illegal or unauthorized purpose. You must not, in the
use of the Service, violate any laws in your jurisdiction (including but not limited to
copyright or trademark laws).</p></li>
</ol>
</li>
<li><b>API Terms</b>
<p>Customers may access their "JH" account data via an API (Application Program Interface). Any
use of the API, including use of the API through a third-party product that accesses "JH",
is
bound by these Terms of Service plus the following specific terms:</p>
<ol>
<li><p>You expressly understand and agree that "JH" shall not be liable for any direct,
indirect, incidental, special, consequential or exemplary damages, including but not limited
to, damages for loss of profits, goodwill, use, data or other intangible losses (even if
"JH" has been advised of the possibility of such damages), resulting from your use of
the
API or third-party products that access data via the API.</p></li>
<li><p>Abuse or excessively frequent requests to "JH" via the API may result in the
temporary
or permanent suspension of your account''s access to the API. "JH", in its sole
discretion,
will determine abuse or excessive usage of the API. "JH" will make a reasonable attempt
via email to warn the account owner prior to suspension.</p></li>
<li><p>"JH" reserves the right at any time to modify or discontinue, temporarily or
permanently, your access to the API (or any part thereof) with or without notice.</p></li>
</ol>
</li>
<!--li><b>Payment, Refunds, Upgrading and Downgrading Terms</b>
<ol>
<li><p>All paid plans must enter a valid payment account. Free accounts are not required to
provide payment account information.</p></li>
<li><p><strong>An upgrade from the free plan to any paying plan will immediately bill
you.</strong></p></li>
<li><p>For monthly payment plans, <strong>the Service is billed in advance on a monthly basis
and is non-refundable. There will be no refunds or credits for partial months of service,
upgrade/downgrade refunds, or refunds for months unused with an open account. In order to
treat everyone equally, no exceptions will be made.</strong></p></li>
<li><p>All fees are exclusive of all taxes excluding EU VAT, levies, or duties imposed by taxing
authorities, and
you shall be responsible for payment of all such taxes, levies, or duties.</p></li>
<li><p>For any upgrade or downgrade in plan level while on a monthly billing cycle, the credit
card that you provided will automatically be charged the new rate on your next billing
cycle.</p></li>
<li><p>Downgrading your Service may cause the loss of Content, features, or capacity of your
Account. "JH" does not accept any liability for such loss.</p></li>
</ol>
</li-->
<li><b>Cancellation and Termination</b>
<ol>
<li><p><strong>You are solely responsible for properly canceling your account</strong>
</p></li>
<li><p>All of your Content will be immediately deleted from the Service upon cancellation. This
information can not be recovered once your account is cancelled.</p></li>
<!--li><p>If you cancel the Service before the end of your current paid up month, your cancellation
will take effect immediately and you will not be charged again.</p></li-->
<li><p>"JH", in its sole discretion, has the right to suspend or terminate your account and
refuse any and all current or future use of the Service, or any other "JH" service, for
any reason at any time. Such termination of the Service will result in the deactivation or
deletion of your Account or your access to your Account, and the forfeiture and
relinquishment of all Content in your Account. "JH" reserves the right to refuse service
to anyone for any reason at any time.</p></li>
</ol>
</li>
<li><b>Modifications to the Service<!-- and Prices--></b>
<ol>
<li><p>"JH" reserves the right at any time and from time to time to modify or discontinue,
temporarily or permanently, the Service (or any part thereof) with or without notice.</p>
</li>
<!--li><p>Prices of all Services, including but not limited to monthly subscription plan fees to
the Service, are subject to change upon 30 days notice from us. Such notice may be provided
at any time by posting the changes to the Inodio Site (<a href="https://www.inodio.com">www.indoio.com</a>)
or the Service itself.</p></li-->
<li><p>"JH" shall not be liable to you or to any third-party for any modification,<!-- price
change,--> suspension or discontinuance of the Service.</p></li>
</ol>
</li>
<li><b>Copyright and Content Ownership</b>
<ol>
<li><p>You shall defend "JH" against any claim, demand, suit or proceeding made or
brought
against "JH" by a third-party alleging that Your Content, or Your use of the
Service in
violation of this Agreement, infringes or misappropriates the intellectual property rights
of a third-party or violates applicable law, and shall indemnify "JH" for any
damages
finally awarded against, and for reasonable attorney’s fees incurred by, "JH" in
connection with any such claim, demand, suit or proceeding; provided, that "JH" (a)
promptly gives You written notice of the claim, demand, suit or proceeding; (b) gives You
sole control of the defense and settlement of the claim, demand, suit or proceeding
(provided that You may not settle any claim, demand, suit or proceeding unless the
settlement unconditionally releases "JH" of all liability); and (c) provides to You all
reasonable assistance, at Your expense.</p></li>
<li><p>The look and feel of the Service is copyright ©2014 "JH" Inc. All rights reserved.
You
may not duplicate, copy, or reuse any portion of the HTML/CSS, Javascript, or visual design
elements or concepts without express written permission from "JH".</p></li>
</ol>
</li>
<li><b>General Conditions</b>
<ol>
<li><p>Your use of the Service is at your sole risk. The service is provided on an "as is" and
"as available" basis.</p></li>
<li><p>Support for "JH" services is only available in English, via email.</p></li>
<li><p>You understand that "JH" uses third-party vendors and hosting partners to
provide the
necessary hardware, software, networking, storage, and related technology required to run
the Service.</p></li>
<li><p>You must not modify, adapt or hack the Service or modify another website so as to falsely
imply that it is associated with the Service, "JH", or any other "JH"
service.</p></li>
<li><p>You agree not to reproduce, duplicate, copy, sell, resell or exploit any portion of the
Service, use of the Service, or access to the Service without the express written permission
by "JH".</p></li>
<li><p>We may, but have no obligation to, remove Content and Accounts containing Content that we
determine in our sole discretion are unlawful, offensive, threatening, libelous, defamatory,
pornographic, obscene or otherwise objectionable or violates any party''s intellectual
property or these Terms of Service.</p></li>
<li><p>Verbal, physical, written or other abuse (including threats of abuse or retribution) of
any "JH" customer, employee, member, or officer will result in immediate account
termination.</p></li>
<li><p>You understand that the technical processing and transmission of the Service, including
your Content, may be transferred unencrypted and involve (a) transmissions over various
networks; and (b) changes to conform and adapt to technical requirements of connecting
networks or devices.</p></li>
<li><p>You must not upload, post, host, or transmit unsolicited email, SMSs, or "spam"
messages.</p></li>
<li><p>You must not transmit any worms or viruses or any code of a destructive nature.</p></li>
<li><p>If your bandwidth usage significantly exceeds the average bandwidth usage (as determined
solely by "JH") of other "JH" customers, we reserve the right to immediately disable
your account or throttle your file hosting until you can reduce your bandwidth
consumption.</p></li>
<li><p>"JH" does not warrant that (i) the service will meet your specific requirements, (ii)
the service will be uninterrupted, timely, secure, or error-free, (iii) the results that may
be obtained from the use of the service will be accurate or reliable, (iv) the quality of
any products, services, information, or other material purchased or obtained by you through
the service will meet your expectations, and (v) any errors in the Service will be
corrected.</p></li>
<li><p>You expressly understand and agree that "JH" shall not be liable for any direct,
indirect, incidental, special, consequential or exemplary damages, including but not limited
to, damages for loss of profits, goodwill, use, data or other intangible losses (even if
"JH" has been advised of the possibility of such damages), resulting from: (i) the use
or
the inability to use the service; (ii) the cost of procurement of substitute goods and
services resulting from any goods, data, information or services purchased or obtained or
messages received or transactions entered into through or from the service; (iii)
unauthorized access to or alteration of your transmissions or data; (iv) statements or
conduct of any third-party on the service; (v) or any other matter relating to the
service.</p></li>
<li><p>The failure of "JH" to exercise or enforce any right or provision of the Terms of
Service shall not constitute a waiver of such right or provision. The Terms of Service
constitutes the entire agreement between you and "JH" and govern your use of the
Service,
superseding any prior agreements between you and "JH" (including, but not limited to,
any
prior versions of the Terms of Service). You agree that these Terms of Service and Your use
of the Service are governed under Czech law.</p></li>
</ol>
</li>
</ol>');
insert into LEGAL_DOCUMENT (ID, CODE, LOCALE, CONTENT) values (2, 'AUTH.PRIVACY', '<h1>Privacy Policy for Inodio</h1>
<p>At inodio.com, accessible from https://www.inodio.com, one of our main priorities is the privacy of our visitors. This Privacy Policy document contains types of information that is collected and recorded by inodio.com and how we use it.</p>
<p>If you have additional questions or require more information about our Privacy Policy, do not hesitate to contact us through email at info@inodio.com</p>
<h2>General Data Protection Regulation (GDPR)</h2>
<p>We are a Data Controller of your information.</p>
<p>Inodio legal basis for collecting and using the personal information described in this Privacy Policy depends on the Personal Information we collect and the specific context in which we collect the information:</p>
<ul>
<li>Inodio needs to perform a contract with you</li>
<li>You have given Inodio permission to do so</li>
<li>Processing your personal information is in Inodio legitimate interests</li>
<li>Inodio needs to comply with the law</li>
</ul>
<p>Inodio will retain your personal information only for as long as is necessary for the purposes set out in this Privacy Policy. We will retain and use your information to the extent necessary to comply with our legal obligations, resolve disputes, and enforce our policies. Our Privacy Policy was generated with the help of <a href="https://www.gdprprivacynotice.com/">GDPR Privacy Policy Generator</a>.</p>
<p>If you are a resident of the European Economic Area (EEA), you have certain data protection rights. If you wish to be informed what Personal Information we hold about you and if you want it to be removed from our systems, please contact us.</p>
<p>In certain circumstances, you have the following data protection rights:</p>
<ul>
<li>The right to access, update or to delete the information we have on you.</li>
<li>The right of rectification.</li>
<li>The right to object.</li>
<li>The right of restriction.</li>
<li>The right to data portability</li>
<li>The right to withdraw consent</li>
</ul>
<h2>Log Files</h2>
<p>inodio.com follows a standard procedure of using log files. These files log visitors when they visit websites. All hosting companies do this and a part of hosting services'' analytics. The information collected by log files include internet protocol (IP) addresses, browser type, Internet Service Provider (ISP), date and time stamp, referring/exit pages, and possibly the number of clicks. These are not linked to any information that is personally identifiable. The purpose of the information is for analyzing trends, administering the site, tracking users'' movement on the website, and gathering demographic information.</p>
<h2>Cookies and Web Beacons</h2>
<p>Like any other website, inodio.com uses ''cookies''. These cookies are used to store information including visitors'' preferences, and the pages on the website that the visitor accessed or visited. The information is used to optimize the users'' experience by customizing our web page content based on visitors'' browser type and/or other information.</p>
<h2>Privacy Policies</h2>
<P>You may consult this list to find the Privacy Policy for each of the advertising partners of inodio.com.</p>
<p>Third-party ad servers or ad networks uses technologies like cookies, JavaScript, or Web Beacons that are used in their respective advertisements and links that appear on inodio.com, which are sent directly to users'' browser. They automatically receive your IP address when this occurs. These technologies are used to measure the effectiveness of their advertising campaigns and/or to personalize the advertising content that you see on websites that you visit.</p>
<p>Note that inodio.com has no access to or control over these cookies that are used by third-party advertisers.</p>
<h2>Third Party Privacy Policies</h2>
<p>inodio.com''s Privacy Policy does not apply to other advertisers or websites. Thus, we are advising you to consult the respective Privacy Policies of these third-party ad servers for more detailed information. It may include their practices and instructions about how to opt-out of certain options. You may find a complete list of these Privacy Policies and their links here: Privacy Policy Links.</p>
<p>You can choose to disable cookies through your individual browser options. To know more detailed information about cookie management with specific web browsers, it can be found at the browsers'' respective websites. What Are Cookies?</p>
<h2>Children''s Information</h2>
<p>Another part of our priority is adding protection for children while using the internet. We encourage parents and guardians to observe, participate in, and/or monitor and guide their online activity.</p>
<p>inodio.com does not knowingly collect any Personal Identifiable Information from children under the age of 13. If you think that your child provided this kind of information on our website, we strongly encourage you to contact us immediately and we will do our best efforts to promptly remove such information from our records.</p>
<h2>Online Privacy Policy Only</h2>
<p>Our Privacy Policy applies only to our online activities and is valid for visitors to our website with regards to the information that they shared and/or collect in inodio.com. This policy is not applicable to any information collected offline or via channels other than this website.</p>
<h2>Consent</h2>
<p>By using our website, you hereby consent to our Privacy Policy and agree to its terms.</p>');
\ No newline at end of file
CREATE DATABASE suite CREATE DATABASE suite
WITH WITH
OWNER = postgres OWNER = postgres
ENCODING = 'utf8' ENCODING = 'utf8'
TABLESPACE = pg_default TABLESPACE = pg_default
CONNECTION LIMIT = -1; CONNECTION LIMIT = -1;
-- --
CREATE SEQUENCE ID_GENERATOR; CREATE SEQUENCE ID_GENERATOR;
-- version procedure -- version procedure
CREATE OR REPLACE FUNCTION process_version_check() RETURNS TRIGGER AS $version_check$ CREATE OR REPLACE FUNCTION process_version_check() RETURNS TRIGGER AS $version_check$
BEGIN BEGIN
IF (OLD.VERSION > NEW.VERSION) THEN IF (OLD.VERSION > NEW.VERSION) THEN
RAISE EXCEPTION 'row_version_conflict' using RAISE EXCEPTION 'row_version_conflict' using
ERRCODE = 99001, ERRCODE = 99001,
MESSAGE = ('Cannot update record % in table %. Actual version: %, provided version %', NEW.ID, TG_TABLE_NAME, OLD.VERSION, NEW.VERSION); MESSAGE = ('Cannot update record % in table %. Actual version: %, provided version %', NEW.ID, TG_TABLE_NAME, OLD.VERSION, NEW.VERSION);
END IF; END IF;
NEW.VERSION = OLD.VERSION + 1; NEW.VERSION = OLD.VERSION + 1;
RETURN NEW; RETURN NEW;
END; END;
$version_check$ LANGUAGE plpgsql; $version_check$ LANGUAGE plpgsql;
-- end of version procedure -- end of version procedure
-- shortid procedure -- shortid procedure
CREATE OR REPLACE FUNCTION pseudo_encrypt(VALUE bigint) returns bigint AS $$ CREATE OR REPLACE FUNCTION pseudo_encrypt(VALUE bigint) returns bigint AS $$
DECLARE DECLARE
l1 int; l1 int;
l2 int; l2 int;
r1 int; r1 int;
r2 int; r2 int;
i int:=0; i int:=0;
BEGIN BEGIN
l1:= (VALUE >> 16) & 65535; l1:= (VALUE >> 16) & 65535;
r1:= VALUE & 65535; r1:= VALUE & 65535;
WHILE i < 3 LOOP WHILE i < 3 LOOP
l2 := r1; l2 := r1;
r2 := l1 # ((((1366 * r1 + 150889) % 714025) / 714025.0) * 32767)::int; r2 := l1 # ((((1366 * r1 + 150889) % 714025) / 714025.0) * 32767)::int;
l1 := l2; l1 := l2;
r1 := r2; r1 := r2;
i := i + 1; i := i + 1;
END LOOP; END LOOP;
RETURN ((r1 << 16) + l1); RETURN ((r1 << 16) + l1);
END; END;
$$ LANGUAGE plpgsql strict immutable; $$ LANGUAGE plpgsql strict immutable;
CREATE OR REPLACE FUNCTION shortid(n bigint) RETURNS text CREATE OR REPLACE FUNCTION shortid(n bigint) RETURNS text
LANGUAGE plpgsql IMMUTABLE STRICT AS $$ LANGUAGE plpgsql IMMUTABLE STRICT AS $$
DECLARE DECLARE
alphabet text:='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'; alphabet text:='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
base int:=length(alphabet); base int:=length(alphabet);
_n bigint:=pseudo_encrypt(abs(n)); _n bigint:=pseudo_encrypt(abs(n));
output text:=''; output text:='';
BEGIN BEGIN
LOOP LOOP
output := output || substr(alphabet, 1+(_n%base)::int, 1); output := output || substr(alphabet, 1+(_n%base)::int, 1);
_n := _n / base; _n := _n / base;
EXIT WHEN _n=0; EXIT WHEN _n=0;
END LOOP; END LOOP;
RETURN output; RETURN output;
END $$; END $$;
-- end of shortid procedure -- end of shortid procedure
CREATE TABLE APP_USER ( CREATE TABLE APP_USER (
ID INT8 NOT NULL, ID INT8 NOT NULL,
VERSION INT8 NOT NULL DEFAULT 0, VERSION INT8 NOT NULL DEFAULT 0,
DELETED BOOLEAN DEFAULT FALSE, DELETED BOOLEAN DEFAULT FALSE,
EMAIL VARCHAR(250) NOT NULL, EMAIL VARCHAR(250) NOT NULL,
PASSWORD VARCHAR(500), PASSWORD VARCHAR(500),
PASSWORD_SALT VARCHAR(250), PASSWORD_SALT VARCHAR(250),
FIRST_NAME VARCHAR(250), FIRST_NAME VARCHAR(250),
LAST_NAME VARCHAR(250), LAST_NAME VARCHAR(250),
TIMEZONE_ID VARCHAR(50), TIMEZONE_ID VARCHAR(50),
LOCALE VARCHAR(50), LOCALE VARCHAR(50),
CONSTRAINT PK_APP_USER PRIMARY KEY(ID) CONSTRAINT PK_APP_USER PRIMARY KEY(ID)
); );
CREATE INDEX APP_USER_EMAIL_IDX ON APP_USER(lower(EMAIL)); CREATE INDEX APP_USER_EMAIL_IDX ON APP_USER(lower(EMAIL));
CREATE TABLE APP_ROLE ( CREATE TABLE APP_ROLE (
ID INT8 NOT NULL, ID INT8 NOT NULL,
NAME VARCHAR(250) NOT NULL, NAME VARCHAR(250) NOT NULL,
CONSTRAINT PK_APP_ROLE PRIMARY KEY(ID) CONSTRAINT PK_APP_ROLE PRIMARY KEY(ID)
); );
CREATE TABLE APP_USER_ROLE ( CREATE TABLE APP_USER_ROLE (
USER_ID INT8 NOT NULL, USER_ID INT8 NOT NULL,
ROLE_ID INT8 NOT NULL ROLE_ID INT8 NOT NULL
); );
CREATE INDEX APP_USER_ROLE_IDX ON APP_USER_ROLE(USER_ID, ROLE_ID); CREATE INDEX APP_USER_ROLE_IDX ON APP_USER_ROLE(USER_ID, ROLE_ID);
CREATE TABLE RESET_PASSWORD_TOKEN ( CREATE TABLE RESET_PASSWORD_TOKEN (
ID INT8 NOT NULL, ID INT8 NOT NULL,
LOGIN VARCHAR(250) NOT NULL, LOGIN VARCHAR(250) NOT NULL,
TOKEN VARCHAR(250) NOT NULL, TOKEN VARCHAR(250) NOT NULL,
USED BOOLEAN DEFAULT FALSE, USED BOOLEAN DEFAULT FALSE,
CREATED TIMESTAMP, CREATED TIMESTAMP,
CONSTRAINT PK_RESET_PASSWORD_TOKEN PRIMARY KEY(ID) CONSTRAINT PK_RESET_PASSWORD_TOKEN PRIMARY KEY(ID)
); );
CREATE INDEX RESET_PASSWORD_TOKEN_LOGIN_IDX ON RESET_PASSWORD_TOKEN(LOGIN); CREATE INDEX RESET_PASSWORD_TOKEN_LOGIN_IDX ON RESET_PASSWORD_TOKEN(LOGIN);
-- EMAILS -- EMAILS
CREATE TABLE EMAIL ( CREATE TABLE EMAIL (
ID INT8 NOT NULL, ID INT8 NOT NULL,
LOCKED BOOLEAN DEFAULT FALSE, LOCKED BOOLEAN DEFAULT FALSE,
TO_BE_SENT BOOLEAN DEFAULT FALSE, TO_BE_SENT BOOLEAN DEFAULT FALSE,
STATUS VARCHAR(10), STATUS VARCHAR(10),
SENT_DATE TIMESTAMP, SENT_DATE TIMESTAMP,
TO_BE_SENT_DATE TIMESTAMP, TO_BE_SENT_DATE TIMESTAMP,
EMAIL_FROM VARCHAR(250) NOT NULL, EMAIL_FROM VARCHAR(250) NOT NULL,
SUBJECT VARCHAR(1000), SUBJECT VARCHAR(1000),
TEXT_CONTENT TEXT, TEXT_CONTENT TEXT,
HTML_CONTENT TEXT, HTML_CONTENT TEXT,
ATTEMPTS NUMERIC(2, 0), ATTEMPTS NUMERIC(2, 0),
ERROR VARCHAR(2000), ERROR VARCHAR(2000),
RECEIPT BOOLEAN, RECEIPT BOOLEAN,
CONSTRAINT PK_EMAIL PRIMARY KEY(ID) CONSTRAINT PK_EMAIL PRIMARY KEY(ID)
); );
CREATE INDEX EMAIL_IDX ON EMAIL(TO_BE_SENT, LOCKED); CREATE INDEX EMAIL_IDX ON EMAIL(TO_BE_SENT, LOCKED);
CREATE TABLE EMAIL_RECIPIENT ( CREATE TABLE EMAIL_RECIPIENT (
ID INT8 NOT NULL, ID INT8 NOT NULL,
EMAIL_ID INT8 NOT NULL, EMAIL_ID INT8 NOT NULL,
ADDRESS VARCHAR(100), ADDRESS VARCHAR(100),
RECIPIENT_TYPE VARCHAR(10), RECIPIENT_TYPE VARCHAR(10),
CONSTRAINT PK_EMAIL_RECIPIENT PRIMARY KEY(ID), CONSTRAINT PK_EMAIL_RECIPIENT PRIMARY KEY(ID),
CONSTRAINT FK_RECIPIENT_EMAIL FOREIGN KEY (EMAIL_ID) REFERENCES EMAIL(ID) CONSTRAINT FK_RECIPIENT_EMAIL FOREIGN KEY (EMAIL_ID) REFERENCES EMAIL(ID)
); );
CREATE INDEX EMAIL_RECIPIENT_IDX ON EMAIL_RECIPIENT(EMAIL_ID); CREATE INDEX EMAIL_RECIPIENT_IDX ON EMAIL_RECIPIENT(EMAIL_ID);
CREATE TABLE EMAIL_ATTACHMENT ( CREATE TABLE EMAIL_ATTACHMENT (
ID INT8 NOT NULL, ID INT8 NOT NULL,
EMAIL_ID INT8 NOT NULL, EMAIL_ID INT8 NOT NULL,
CID VARCHAR(100), CID VARCHAR(100),
NAME VARCHAR(256), NAME VARCHAR(256),
MIME_TYPE VARCHAR(100), MIME_TYPE VARCHAR(100),
SIZE NUMERIC(19,0), SIZE NUMERIC(19,0),
DATA TEXT, DATA TEXT,
CONSTRAINT PK_EMAIL_ATTACHMENT PRIMARY KEY(ID), CONSTRAINT PK_EMAIL_ATTACHMENT PRIMARY KEY(ID),
CONSTRAINT FK_EMAIL_ATTACHMENT_EMAIL FOREIGN KEY (EMAIL_ID) REFERENCES EMAIL(ID) CONSTRAINT FK_EMAIL_ATTACHMENT_EMAIL FOREIGN KEY (EMAIL_ID) REFERENCES EMAIL(ID)
); );
CREATE INDEX EMAIL_ATTACHMENT_IDX ON EMAIL_ATTACHMENT(EMAIL_ID); CREATE INDEX EMAIL_ATTACHMENT_IDX ON EMAIL_ATTACHMENT(EMAIL_ID);
-- TEMPLATES -- TEMPLATES
CREATE TABLE TEMPLATE ( CREATE TABLE TEMPLATE (
ID INT8 NOT NULL, ID INT8 NOT NULL,
CODE VARCHAR(250), CODE VARCHAR(250),
NAME VARCHAR(100), NAME VARCHAR(100),
TEMPLATE TEXT, TEMPLATE TEXT,
CONSTRAINT PK_TEMPLATE PRIMARY KEY(ID) CONSTRAINT PK_TEMPLATE PRIMARY KEY(ID)
); );
CREATE INDEX TEMPLATE_CODE_IDX ON TEMPLATE(CODE); CREATE INDEX TEMPLATE_CODE_IDX ON TEMPLATE(CODE);
CREATE TABLE CUSTOMIZABLE_TEMPLATE_LABEL ( CREATE TABLE CUSTOMIZABLE_TEMPLATE_LABEL (
ID INT8 NOT NULL, ID INT8 NOT NULL,
TEMPLATE_ID INT8 NOT NULL, TEMPLATE_ID INT8 NOT NULL,
UNIT_ID INT8, UNIT_ID INT8,
CODE VARCHAR(1000) NOT NULL, CODE VARCHAR(1000) NOT NULL,
LANG VARCHAR(10), LANG VARCHAR(10),
LABEL VARCHAR, LABEL VARCHAR,
POSITION NUMERIC(19,0), POSITION NUMERIC(19,0),
CONSTRAINT PK_CUSTOMIZABLE_TEMPLATE_LABEL PRIMARY KEY(ID), CONSTRAINT PK_CUSTOMIZABLE_TEMPLATE_LABEL PRIMARY KEY(ID),
CONSTRAINT FK_CUSTOMIZABLE_TEMPLATE_LABEL_TEMPLATE FOREIGN KEY (TEMPLATE_ID) REFERENCES TEMPLATE(ID) CONSTRAINT FK_CUSTOMIZABLE_TEMPLATE_LABEL_TEMPLATE FOREIGN KEY (TEMPLATE_ID) REFERENCES TEMPLATE(ID)
); );
CREATE INDEX CUSTOMIZABLE_TEMPLATE_LABEL_TEMPLATE_IDX ON CUSTOMIZABLE_TEMPLATE_LABEL(TEMPLATE_ID); CREATE INDEX CUSTOMIZABLE_TEMPLATE_LABEL_TEMPLATE_IDX ON CUSTOMIZABLE_TEMPLATE_LABEL(TEMPLATE_ID);
CREATE INDEX CUSTOMIZABLE_TEMPLATE_LABEL_UNIT_IDX ON CUSTOMIZABLE_TEMPLATE_LABEL(UNIT_ID); CREATE INDEX CUSTOMIZABLE_TEMPLATE_LABEL_UNIT_IDX ON CUSTOMIZABLE_TEMPLATE_LABEL(UNIT_ID);
-- LEGAL DOCUMENTS
CREATE TABLE LEGAL_DOCUMENT (
ID INT8 NOT NULL,
CODE VARCHAR(1000) NOT NULL,
LOCALE VARCHAR(10),
CONTENT VARCHAR,
CONSTRAINT PK_LEGAL_DOCUMENT PRIMARY KEY(ID)
);
CREATE INDEX LEGAL_DOCUMENT_IDX ON LEGAL_DOCUMENT(CODE, LOCALE);
-- TODO -- TODO
\ No newline at end of file
package com.jh.boot.security.model; package com.jh.boot.document;
import com.jh.boot.jpa.AbstractIdEntity; import com.jh.boot.jpa.AbstractIdEntity;
......
package com.jh.boot.document;
import javax.persistence.Query;
import org.springframework.stereotype.Repository;
import org.springframework.util.StringUtils;
import com.jh.boot.jpa.AbstractHibernateRepository;
@Repository
public class LegalDocumentRepository extends AbstractHibernateRepository {
public LegalDocument findByCodeAndLocale(String code, String locale) {
if (code == null) {
return null;
}
if (!StringUtils.hasText(locale)) {
locale = "en";
}
locale = locale.replace("-", "_");
Query q = entityManager.createQuery("select ld from LegalDocument ld where lower(ld.code) = :code and lower(ld.locale) = :locale");
q.setParameter("code", locale.trim().toLowerCase());
q.setParameter("locale", locale.trim().toLowerCase());
LegalDocument ld = singleResult(q);
if (ld == null) {
if (locale.indexOf('_') > -1) {
return findByCodeAndLocale(code, locale.substring(0, locale.lastIndexOf('_')));
} else if (!"en".equalsIgnoreCase(locale)) {
return findByCodeAndLocale(code, "en");
}
}
return null;
}
}
package com.jh.boot.document;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@Service
public class LegalDocumentService {
@Autowired
private LegalDocumentRepository repo;
@Transactional
public LegalDocument findByCodeAndLocale(String code, String locale) {
return repo.findByCodeAndLocale(code, locale);
}
}
...@@ -8,8 +8,7 @@ import java.util.ArrayList; ...@@ -8,8 +8,7 @@ import java.util.ArrayList;
import java.util.Base64; import java.util.Base64;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Locale;
import java.util.logging.ErrorManager;
import javax.servlet.http.HttpSession; import javax.servlet.http.HttpSession;
...@@ -31,6 +30,8 @@ import org.springframework.web.bind.annotation.RequestMethod; ...@@ -31,6 +30,8 @@ import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.ResponseStatus; import org.springframework.web.bind.annotation.ResponseStatus;
import com.jh.boot.document.LegalDocument;
import com.jh.boot.document.LegalDocumentService;
import com.jh.boot.security.AppUserAuthentication; import com.jh.boot.security.AppUserAuthentication;
import com.jh.boot.security.AuthError; import com.jh.boot.security.AuthError;
import com.jh.boot.security.AuthService; import com.jh.boot.security.AuthService;
...@@ -54,6 +55,10 @@ public class AuthApiController { ...@@ -54,6 +55,10 @@ public class AuthApiController {
@Autowired @Autowired
private AuthService authService; private AuthService authService;
@Autowired
private LegalDocumentService documentService;
@Value("${auth.controller.signup.enabled:true}") @Value("${auth.controller.signup.enabled:true}")
private boolean signupEnabled; private boolean signupEnabled;
...@@ -218,20 +223,17 @@ public class AuthApiController { ...@@ -218,20 +223,17 @@ public class AuthApiController {
} }
/*
@GetMapping("/auth/terms")
public @ResponseBody AppUser user() {
Authentication auth = SecurityContextHolder.getContext().getAuthentication();
if (auth instanceof AppUserAuthentication) {
return ((AppUserAuthentication) auth).getUser();
}
//TODO other auth types? @GetMapping("/auth/terms")
return null; public @ResponseBody LegalDocument terms(Locale locale) {
return documentService.findByCodeAndLocale("AUTH.TERMS", locale.toLanguageTag());
} }
@GetMapping("/auth/privacy") @GetMapping("/auth/privacy")
public @ResponseBody LegalDocument privacy(Locale locale) {
return documentService.findByCodeAndLocale("AUTH.PRIVACY", locale.toLanguageTag());
}
*/
} }
package com.jh.boot.security.repository;
import com.jh.boot.jpa.AbstractHibernateRepository;
public class LegalDocumentRepository extends AbstractHibernateRepository {
}
package com.jh.boot.security.service;
public class LegalDocumentService {
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment