@opengis/pay 1.1.11 → 1.1.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/module/pay/card/billing.accounts.table/general_info.hbs +10 -10
- package/module/pay/card/billing.accounts.table/index.yml +15 -15
- package/module/pay/card/billing.accounts.table/users.hbs +11 -11
- package/module/pay/card/billing.payments.table/general_info.hbs +12 -12
- package/module/pay/card/billing.payments.table/index.yml +9 -9
- package/module/pay/card/billing.users.table/general_info.hbs +10 -10
- package/module/pay/card/billing.users.table/index.yml +9 -9
- package/module/pay/form/billing.account_user.form.json +14 -14
- package/module/pay/form/billing.accounts.form.json +30 -30
- package/module/pay/form/billing.payment.form.json +22 -22
- package/module/pay/form/billing.users.form.json +38 -38
- package/module/pay/menu.json +24 -24
- package/module/pay/table/billing.accounts.table.json +60 -60
- package/module/pay/table/billing.payments.table.json +67 -67
- package/module/pay/table/billing.users.table.json +70 -70
- package/package.json +2 -2
- package/plugin.js +6 -0
- package/server/migrations/1_users.sql +120 -120
- package/server/migrations/2_accounts.sql +59 -59
- package/server/migrations/3_utils.sql +73 -73
- package/server/migrations/4_subscriptions.sql +35 -35
- package/server/migrations/5_payments.sql +36 -36
- package/server/migrations/6_invoices.sql +54 -54
- package/server/plugins/cron.js +22 -0
- package/server/routes/portmone.redirect.js +4 -2
- package/server/routes/portmone.status.js +8 -4
- package/server/routes/utils/portmone.check.status.js +33 -0
|
@@ -1,68 +1,68 @@
|
|
|
1
|
-
{
|
|
2
|
-
"key": "payment_id",
|
|
3
|
-
"table": "billing.payments",
|
|
4
|
-
"order": "cdate desc",
|
|
5
|
-
"title_column": "account_id",
|
|
6
|
-
"form": "billing.payment.form",
|
|
7
|
-
"title_full": {
|
|
8
|
-
"ua": "Реєстр платежів"
|
|
9
|
-
},
|
|
10
|
-
"actions": [
|
|
11
|
-
"add",
|
|
12
|
-
"edit",
|
|
13
|
-
"del"
|
|
14
|
-
],
|
|
15
|
-
"columns": [
|
|
16
|
-
{
|
|
17
|
-
"name": "account_id",
|
|
18
|
-
"data": "billing.account_id",
|
|
19
|
-
"format": "select",
|
|
20
|
-
"ua": "Назва організації"
|
|
21
|
-
},
|
|
22
|
-
{
|
|
23
|
-
"name": "payment_amount",
|
|
24
|
-
"format": "text",
|
|
25
|
-
"ua": "Сума поповнення рахунку"
|
|
26
|
-
},
|
|
27
|
-
{
|
|
28
|
-
"name": "total_balance",
|
|
29
|
-
"format": "text",
|
|
30
|
-
"ua": "Поточний баланс"
|
|
31
|
-
},
|
|
32
|
-
{
|
|
33
|
-
"name": "payment_status",
|
|
34
|
-
"data": "billing.payment_status",
|
|
35
|
-
"format": "badge",
|
|
36
|
-
"ua": "Статус транзації"
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
"name": "success_date",
|
|
40
|
-
"format": "date",
|
|
41
|
-
"ua": "Дата успішного завершення транзакції"
|
|
42
|
-
}
|
|
43
|
-
],
|
|
44
|
-
"filter_list": [
|
|
45
|
-
{
|
|
46
|
-
"name": "account_id",
|
|
47
|
-
"data": "billing.account_id",
|
|
48
|
-
"type": "Text",
|
|
49
|
-
"ua": "Назва організації"
|
|
50
|
-
},
|
|
51
|
-
{
|
|
52
|
-
"name": "payment_amount",
|
|
53
|
-
"type": "Range",
|
|
54
|
-
"ua": "Сума поповнення рахунку"
|
|
55
|
-
},
|
|
56
|
-
{
|
|
57
|
-
"name": "payment_status",
|
|
58
|
-
"data": "billing.payment_status",
|
|
59
|
-
"type": "Check",
|
|
60
|
-
"ua": "Статус транзації"
|
|
61
|
-
},
|
|
62
|
-
{
|
|
63
|
-
"name": "success_date",
|
|
64
|
-
"type": "Date",
|
|
65
|
-
"ua": "Дата успішного завершення транзакції"
|
|
66
|
-
}
|
|
67
|
-
]
|
|
1
|
+
{
|
|
2
|
+
"key": "payment_id",
|
|
3
|
+
"table": "billing.payments",
|
|
4
|
+
"order": "cdate desc",
|
|
5
|
+
"title_column": "account_id",
|
|
6
|
+
"form": "billing.payment.form",
|
|
7
|
+
"title_full": {
|
|
8
|
+
"ua": "Реєстр платежів"
|
|
9
|
+
},
|
|
10
|
+
"actions": [
|
|
11
|
+
"add",
|
|
12
|
+
"edit",
|
|
13
|
+
"del"
|
|
14
|
+
],
|
|
15
|
+
"columns": [
|
|
16
|
+
{
|
|
17
|
+
"name": "account_id",
|
|
18
|
+
"data": "billing.account_id",
|
|
19
|
+
"format": "select",
|
|
20
|
+
"ua": "Назва організації"
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"name": "payment_amount",
|
|
24
|
+
"format": "text",
|
|
25
|
+
"ua": "Сума поповнення рахунку"
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
"name": "total_balance",
|
|
29
|
+
"format": "text",
|
|
30
|
+
"ua": "Поточний баланс"
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"name": "payment_status",
|
|
34
|
+
"data": "billing.payment_status",
|
|
35
|
+
"format": "badge",
|
|
36
|
+
"ua": "Статус транзації"
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"name": "success_date",
|
|
40
|
+
"format": "date",
|
|
41
|
+
"ua": "Дата успішного завершення транзакції"
|
|
42
|
+
}
|
|
43
|
+
],
|
|
44
|
+
"filter_list": [
|
|
45
|
+
{
|
|
46
|
+
"name": "account_id",
|
|
47
|
+
"data": "billing.account_id",
|
|
48
|
+
"type": "Text",
|
|
49
|
+
"ua": "Назва організації"
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
"name": "payment_amount",
|
|
53
|
+
"type": "Range",
|
|
54
|
+
"ua": "Сума поповнення рахунку"
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
"name": "payment_status",
|
|
58
|
+
"data": "billing.payment_status",
|
|
59
|
+
"type": "Check",
|
|
60
|
+
"ua": "Статус транзації"
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
"name": "success_date",
|
|
64
|
+
"type": "Date",
|
|
65
|
+
"ua": "Дата успішного завершення транзакції"
|
|
66
|
+
}
|
|
67
|
+
]
|
|
68
68
|
}
|
|
@@ -1,71 +1,71 @@
|
|
|
1
|
-
{
|
|
2
|
-
"key": "user_id",
|
|
3
|
-
"table": "billing.users",
|
|
4
|
-
"order": "cdate desc",
|
|
5
|
-
"form": "billing.users.form",
|
|
6
|
-
"title_column": "user_name",
|
|
7
|
-
"title_full": {
|
|
8
|
-
"ua": "Реєстр користувачів"
|
|
9
|
-
},
|
|
10
|
-
"actions": [
|
|
11
|
-
"add",
|
|
12
|
-
"edit",
|
|
13
|
-
"del"
|
|
14
|
-
],
|
|
15
|
-
"columns": [
|
|
16
|
-
{
|
|
17
|
-
"name": "user_name",
|
|
18
|
-
"format": "text",
|
|
19
|
-
"title": "Ім'я"
|
|
20
|
-
},
|
|
21
|
-
{
|
|
22
|
-
"name": "sur_name",
|
|
23
|
-
"format": "text",
|
|
24
|
-
"title": "Прізвище"
|
|
25
|
-
},
|
|
26
|
-
{
|
|
27
|
-
"name": "father_name",
|
|
28
|
-
"format": "text",
|
|
29
|
-
"title": "По-батькові"
|
|
30
|
-
},
|
|
31
|
-
{
|
|
32
|
-
"name": "email",
|
|
33
|
-
"format": "text",
|
|
34
|
-
"title": "Email"
|
|
35
|
-
},
|
|
36
|
-
{
|
|
37
|
-
"name": "enabled",
|
|
38
|
-
"hidden": true,
|
|
39
|
-
"format": "yes/no",
|
|
40
|
-
"title": "On / off"
|
|
41
|
-
}
|
|
42
|
-
],
|
|
43
|
-
"filter_list": [
|
|
44
|
-
{
|
|
45
|
-
"name": "user_name",
|
|
46
|
-
"type": "Text",
|
|
47
|
-
"ua": "Ім'я користувача"
|
|
48
|
-
},
|
|
49
|
-
{
|
|
50
|
-
"name": "sur_name",
|
|
51
|
-
"type": "Text",
|
|
52
|
-
"ua": "Прізвище користувача"
|
|
53
|
-
},
|
|
54
|
-
{
|
|
55
|
-
"name": "father_name",
|
|
56
|
-
"type": "Text",
|
|
57
|
-
"ua": "По-батькові користувача"
|
|
58
|
-
},
|
|
59
|
-
{
|
|
60
|
-
"name": "email",
|
|
61
|
-
"type": "Text",
|
|
62
|
-
"ua": "Email"
|
|
63
|
-
},
|
|
64
|
-
{
|
|
65
|
-
"name": "enabled",
|
|
66
|
-
"type": "Check",
|
|
67
|
-
"data": "yes_no",
|
|
68
|
-
"ua": "On / off"
|
|
69
|
-
}
|
|
70
|
-
]
|
|
1
|
+
{
|
|
2
|
+
"key": "user_id",
|
|
3
|
+
"table": "billing.users",
|
|
4
|
+
"order": "cdate desc",
|
|
5
|
+
"form": "billing.users.form",
|
|
6
|
+
"title_column": "user_name",
|
|
7
|
+
"title_full": {
|
|
8
|
+
"ua": "Реєстр користувачів"
|
|
9
|
+
},
|
|
10
|
+
"actions": [
|
|
11
|
+
"add",
|
|
12
|
+
"edit",
|
|
13
|
+
"del"
|
|
14
|
+
],
|
|
15
|
+
"columns": [
|
|
16
|
+
{
|
|
17
|
+
"name": "user_name",
|
|
18
|
+
"format": "text",
|
|
19
|
+
"title": "Ім'я"
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
"name": "sur_name",
|
|
23
|
+
"format": "text",
|
|
24
|
+
"title": "Прізвище"
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"name": "father_name",
|
|
28
|
+
"format": "text",
|
|
29
|
+
"title": "По-батькові"
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"name": "email",
|
|
33
|
+
"format": "text",
|
|
34
|
+
"title": "Email"
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
"name": "enabled",
|
|
38
|
+
"hidden": true,
|
|
39
|
+
"format": "yes/no",
|
|
40
|
+
"title": "On / off"
|
|
41
|
+
}
|
|
42
|
+
],
|
|
43
|
+
"filter_list": [
|
|
44
|
+
{
|
|
45
|
+
"name": "user_name",
|
|
46
|
+
"type": "Text",
|
|
47
|
+
"ua": "Ім'я користувача"
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
"name": "sur_name",
|
|
51
|
+
"type": "Text",
|
|
52
|
+
"ua": "Прізвище користувача"
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
"name": "father_name",
|
|
56
|
+
"type": "Text",
|
|
57
|
+
"ua": "По-батькові користувача"
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
"name": "email",
|
|
61
|
+
"type": "Text",
|
|
62
|
+
"ua": "Email"
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
"name": "enabled",
|
|
66
|
+
"type": "Check",
|
|
67
|
+
"data": "yes_no",
|
|
68
|
+
"ua": "On / off"
|
|
69
|
+
}
|
|
70
|
+
]
|
|
71
71
|
}
|
package/package.json
CHANGED
package/plugin.js
CHANGED
|
@@ -14,11 +14,17 @@ import portmoneStatus from './server/routes/portmone.status.js';
|
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
16
|
async function plugin(app) {
|
|
17
|
+
app.register(import('./server/plugins/cron.js'));
|
|
18
|
+
|
|
17
19
|
app.route({
|
|
18
20
|
method: 'GET',
|
|
19
21
|
url: `${prefix}/portmone-redirect`,
|
|
22
|
+
config: {
|
|
23
|
+
policy: ['site'],
|
|
24
|
+
},
|
|
20
25
|
handler: portmoneRedirect,
|
|
21
26
|
});
|
|
27
|
+
|
|
22
28
|
app.route({
|
|
23
29
|
method: 'POST',
|
|
24
30
|
url: `${prefix}/portmone/:id/:status`,
|
|
@@ -1,121 +1,121 @@
|
|
|
1
|
-
create schema if not exists billing;
|
|
2
|
-
|
|
3
|
-
CREATE TABLE if not exists billing.users();
|
|
4
|
-
ALTER TABLE billing.users DROP CONSTRAINT if exists billing_user_id_pkey cascade;
|
|
5
|
-
|
|
6
|
-
ALTER TABLE billing.users add column if not exists user_id text NOT NULL DEFAULT next_id();
|
|
7
|
-
ALTER TABLE billing.users add column if not exists login text;
|
|
8
|
-
ALTER TABLE billing.users add column if not exists password text NOT NULL DEFAULT ''::text;
|
|
9
|
-
ALTER TABLE billing.users add column if not exists user_name text;
|
|
10
|
-
ALTER TABLE billing.users add column if not exists sur_name text;
|
|
11
|
-
ALTER TABLE billing.users add column if not exists father_name text;
|
|
12
|
-
ALTER TABLE billing.users add column if not exists email text;
|
|
13
|
-
ALTER TABLE billing.users add column if not exists phone text;
|
|
14
|
-
ALTER TABLE billing.users add column if not exists avatar text;
|
|
15
|
-
ALTER TABLE billing.users add column if not exists enabled boolean;
|
|
16
|
-
ALTER TABLE billing.users add column if not exists user_personal_code text;
|
|
17
|
-
ALTER TABLE billing.users add column if not exists last_activity_date timestamp without time zone;
|
|
18
|
-
ALTER TABLE billing.users add column if not exists user_type text DEFAULT 'regular'::text;
|
|
19
|
-
ALTER TABLE billing.users add column if not exists salt text;
|
|
20
|
-
ALTER TABLE billing.users add column if not exists uid text;
|
|
21
|
-
ALTER TABLE billing.users add column if not exists cdate timestamp without time zone DEFAULT date_trunc('seconds'::text, now());
|
|
22
|
-
ALTER TABLE billing.users add column if not exists editor_id text;
|
|
23
|
-
ALTER TABLE billing.users add column if not exists editor_date timestamp without time zone;
|
|
24
|
-
ALTER TABLE billing.users add column if not exists files json;
|
|
25
|
-
|
|
26
|
-
COMMENT ON TABLE billing.users IS 'Користувачі';
|
|
27
|
-
|
|
28
|
-
COMMENT ON COLUMN billing.users.user_id IS 'ID користувача';
|
|
29
|
-
COMMENT ON COLUMN billing.users.login IS 'Логін користувача';
|
|
30
|
-
COMMENT ON COLUMN billing.users.password IS 'Пароль користувача';
|
|
31
|
-
COMMENT ON COLUMN billing.users.user_name IS 'Ім''я користувача';
|
|
32
|
-
COMMENT ON COLUMN billing.users.sur_name IS 'Прізвище користувача';
|
|
33
|
-
COMMENT ON COLUMN billing.users.father_name IS 'По-батькові користувача';
|
|
34
|
-
COMMENT ON COLUMN billing.users.email IS 'Ел. пошта користувача';
|
|
35
|
-
COMMENT ON COLUMN billing.users.phone IS 'Номер телефону користувача';
|
|
36
|
-
COMMENT ON COLUMN billing.users.avatar IS 'Аватар';
|
|
37
|
-
COMMENT ON COLUMN billing.users.enabled IS 'On / Off';
|
|
38
|
-
COMMENT ON COLUMN billing.users.last_activity_date IS 'Дата останньої активності';
|
|
39
|
-
COMMENT ON COLUMN billing.users.user_type IS 'Тип користувача';
|
|
40
|
-
COMMENT ON COLUMN billing.users.salt IS 'Сіль';
|
|
41
|
-
|
|
42
|
-
CREATE EXTENSION if not exists pgcrypto SCHEMA public VERSION "1.3";
|
|
43
|
-
CREATE OR REPLACE FUNCTION billing.crypt(text, text) RETURNS text AS '$libdir/pgcrypto', 'pg_crypt' LANGUAGE c IMMUTABLE STRICT COST 1;
|
|
44
|
-
|
|
45
|
-
CREATE OR REPLACE FUNCTION billing.insert_update_user_before()
|
|
46
|
-
RETURNS trigger AS
|
|
47
|
-
|
|
48
|
-
$BODY$
|
|
49
|
-
DECLARE
|
|
50
|
-
|
|
51
|
-
iterations int;
|
|
52
|
-
hash character varying;
|
|
53
|
-
|
|
54
|
-
BEGIN
|
|
55
|
-
|
|
56
|
-
if(TG_OP='INSERT' or (TG_OP='UPDATE' and new.password<>old.password)) then
|
|
57
|
-
if(char_length(new.password) <> 0 and char_length(new.password) < 8) then
|
|
58
|
-
--raise exception 'password must be longer than 8 characters';
|
|
59
|
-
end if;
|
|
60
|
-
new.salt=md5(now()::text);
|
|
61
|
-
--raise exception '%','change pass';
|
|
62
|
-
if(new.salt ='') then
|
|
63
|
-
new.salt=gen_salt('md5');
|
|
64
|
-
end if;
|
|
65
|
-
iterations = 10;
|
|
66
|
-
hash='';
|
|
67
|
-
|
|
68
|
-
loop
|
|
69
|
-
if iterations=0 then
|
|
70
|
-
exit;
|
|
71
|
-
end if;
|
|
72
|
-
hash = md5(new.password||hash||new.salt);
|
|
73
|
-
iterations=iterations-1;
|
|
74
|
-
end loop;
|
|
75
|
-
new.password=billing.crypt(hash,new.salt);
|
|
76
|
-
|
|
77
|
-
end if;
|
|
78
|
-
RETURN new;
|
|
79
|
-
END
|
|
80
|
-
$BODY$
|
|
81
|
-
|
|
82
|
-
LANGUAGE plpgsql VOLATILE COST 100;
|
|
83
|
-
|
|
84
|
-
DROP TRIGGER if exists insert_update_user_before on billing.users;
|
|
85
|
-
CREATE TRIGGER insert_update_user_before BEFORE INSERT OR UPDATE ON billing.users FOR EACH ROW
|
|
86
|
-
EXECUTE PROCEDURE billing.insert_update_user_before();
|
|
87
|
-
|
|
88
|
-
CREATE TABLE if not exists billing.users_social_auth();
|
|
89
|
-
ALTER TABLE billing.users_social_auth DROP CONSTRAINT if exists billing_users_social_auth_usa_id_pkey cascade;
|
|
90
|
-
ALTER TABLE billing.users_social_auth DROP CONSTRAINT if exists billing_users_social_auth_user_id_fkey cascade;
|
|
91
|
-
|
|
92
|
-
CREATE TABLE if not exists billing.users_social_auth();
|
|
93
|
-
ALTER TABLE billing.users_social_auth add column if not exists usa_id text NOT NULL DEFAULT next_id();
|
|
94
|
-
ALTER TABLE billing.users_social_auth add column if not exists user_id text;
|
|
95
|
-
ALTER TABLE billing.users_social_auth add column if not exists user_name text;
|
|
96
|
-
ALTER TABLE billing.users_social_auth add column if not exists sur_name text;
|
|
97
|
-
ALTER TABLE billing.users_social_auth add column if not exists email text;
|
|
98
|
-
ALTER TABLE billing.users_social_auth add column if not exists city text;
|
|
99
|
-
ALTER TABLE billing.users_social_auth add column if not exists phone text;
|
|
100
|
-
ALTER TABLE billing.users_social_auth add column if not exists social_auth_id text;
|
|
101
|
-
ALTER TABLE billing.users_social_auth add column if not exists social_auth_type text;
|
|
102
|
-
ALTER TABLE billing.users_social_auth add column if not exists social_auth_code text;
|
|
103
|
-
ALTER TABLE billing.users_social_auth add column if not exists social_auth_obj json;
|
|
104
|
-
ALTER TABLE billing.users_social_auth add column if not exists social_auth_date timestamp without time zone;
|
|
105
|
-
ALTER TABLE billing.users_social_auth add column if not exists social_auth_softpro_code text;
|
|
106
|
-
ALTER TABLE billing.users_social_auth add column if not exists enabled boolean;
|
|
107
|
-
ALTER TABLE billing.users_social_auth add column if not exists cdate timestamp without time zone DEFAULT date_trunc('seconds'::text, now());
|
|
108
|
-
ALTER TABLE billing.users_social_auth add column if not exists editor_date timestamp without time zone;
|
|
109
|
-
ALTER TABLE billing.users_social_auth add column if not exists uid text;
|
|
110
|
-
ALTER TABLE billing.users_social_auth add column if not exists editor_id text;
|
|
111
|
-
ALTER TABLE billing.users_social_auth add column if not exists files json;
|
|
112
|
-
ALTER TABLE billing.users_social_auth add column if not exists lang text;
|
|
113
|
-
ALTER TABLE billing.users_social_auth add column if not exists social_auth_url text;
|
|
114
|
-
|
|
115
|
-
COMMENT ON TABLE billing.users_social_auth IS 'Авторизація користувачів через соц. мережі';
|
|
116
|
-
COMMENT ON COLUMN billing.users_social_auth.user_id IS 'ID користувача';
|
|
117
|
-
|
|
118
|
-
ALTER TABLE billing.users add CONSTRAINT billing_user_id_pkey PRIMARY KEY (user_id);
|
|
119
|
-
ALTER TABLE billing.users_social_auth add CONSTRAINT billing_users_social_auth_usa_id_pkey PRIMARY KEY (usa_id);
|
|
120
|
-
ALTER TABLE billing.users_social_auth add CONSTRAINT billing_users_social_auth_user_id_fkey FOREIGN KEY (user_id)
|
|
1
|
+
create schema if not exists billing;
|
|
2
|
+
|
|
3
|
+
CREATE TABLE if not exists billing.users();
|
|
4
|
+
ALTER TABLE billing.users DROP CONSTRAINT if exists billing_user_id_pkey cascade;
|
|
5
|
+
|
|
6
|
+
ALTER TABLE billing.users add column if not exists user_id text NOT NULL DEFAULT next_id();
|
|
7
|
+
ALTER TABLE billing.users add column if not exists login text;
|
|
8
|
+
ALTER TABLE billing.users add column if not exists password text NOT NULL DEFAULT ''::text;
|
|
9
|
+
ALTER TABLE billing.users add column if not exists user_name text;
|
|
10
|
+
ALTER TABLE billing.users add column if not exists sur_name text;
|
|
11
|
+
ALTER TABLE billing.users add column if not exists father_name text;
|
|
12
|
+
ALTER TABLE billing.users add column if not exists email text;
|
|
13
|
+
ALTER TABLE billing.users add column if not exists phone text;
|
|
14
|
+
ALTER TABLE billing.users add column if not exists avatar text;
|
|
15
|
+
ALTER TABLE billing.users add column if not exists enabled boolean;
|
|
16
|
+
ALTER TABLE billing.users add column if not exists user_personal_code text;
|
|
17
|
+
ALTER TABLE billing.users add column if not exists last_activity_date timestamp without time zone;
|
|
18
|
+
ALTER TABLE billing.users add column if not exists user_type text DEFAULT 'regular'::text;
|
|
19
|
+
ALTER TABLE billing.users add column if not exists salt text;
|
|
20
|
+
ALTER TABLE billing.users add column if not exists uid text;
|
|
21
|
+
ALTER TABLE billing.users add column if not exists cdate timestamp without time zone DEFAULT date_trunc('seconds'::text, now());
|
|
22
|
+
ALTER TABLE billing.users add column if not exists editor_id text;
|
|
23
|
+
ALTER TABLE billing.users add column if not exists editor_date timestamp without time zone;
|
|
24
|
+
ALTER TABLE billing.users add column if not exists files json;
|
|
25
|
+
|
|
26
|
+
COMMENT ON TABLE billing.users IS 'Користувачі';
|
|
27
|
+
|
|
28
|
+
COMMENT ON COLUMN billing.users.user_id IS 'ID користувача';
|
|
29
|
+
COMMENT ON COLUMN billing.users.login IS 'Логін користувача';
|
|
30
|
+
COMMENT ON COLUMN billing.users.password IS 'Пароль користувача';
|
|
31
|
+
COMMENT ON COLUMN billing.users.user_name IS 'Ім''я користувача';
|
|
32
|
+
COMMENT ON COLUMN billing.users.sur_name IS 'Прізвище користувача';
|
|
33
|
+
COMMENT ON COLUMN billing.users.father_name IS 'По-батькові користувача';
|
|
34
|
+
COMMENT ON COLUMN billing.users.email IS 'Ел. пошта користувача';
|
|
35
|
+
COMMENT ON COLUMN billing.users.phone IS 'Номер телефону користувача';
|
|
36
|
+
COMMENT ON COLUMN billing.users.avatar IS 'Аватар';
|
|
37
|
+
COMMENT ON COLUMN billing.users.enabled IS 'On / Off';
|
|
38
|
+
COMMENT ON COLUMN billing.users.last_activity_date IS 'Дата останньої активності';
|
|
39
|
+
COMMENT ON COLUMN billing.users.user_type IS 'Тип користувача';
|
|
40
|
+
COMMENT ON COLUMN billing.users.salt IS 'Сіль';
|
|
41
|
+
|
|
42
|
+
CREATE EXTENSION if not exists pgcrypto SCHEMA public VERSION "1.3";
|
|
43
|
+
CREATE OR REPLACE FUNCTION billing.crypt(text, text) RETURNS text AS '$libdir/pgcrypto', 'pg_crypt' LANGUAGE c IMMUTABLE STRICT COST 1;
|
|
44
|
+
|
|
45
|
+
CREATE OR REPLACE FUNCTION billing.insert_update_user_before()
|
|
46
|
+
RETURNS trigger AS
|
|
47
|
+
|
|
48
|
+
$BODY$
|
|
49
|
+
DECLARE
|
|
50
|
+
|
|
51
|
+
iterations int;
|
|
52
|
+
hash character varying;
|
|
53
|
+
|
|
54
|
+
BEGIN
|
|
55
|
+
|
|
56
|
+
if(TG_OP='INSERT' or (TG_OP='UPDATE' and new.password<>old.password)) then
|
|
57
|
+
if(char_length(new.password) <> 0 and char_length(new.password) < 8) then
|
|
58
|
+
--raise exception 'password must be longer than 8 characters';
|
|
59
|
+
end if;
|
|
60
|
+
new.salt=md5(now()::text);
|
|
61
|
+
--raise exception '%','change pass';
|
|
62
|
+
if(new.salt ='') then
|
|
63
|
+
new.salt=gen_salt('md5');
|
|
64
|
+
end if;
|
|
65
|
+
iterations = 10;
|
|
66
|
+
hash='';
|
|
67
|
+
|
|
68
|
+
loop
|
|
69
|
+
if iterations=0 then
|
|
70
|
+
exit;
|
|
71
|
+
end if;
|
|
72
|
+
hash = md5(new.password||hash||new.salt);
|
|
73
|
+
iterations=iterations-1;
|
|
74
|
+
end loop;
|
|
75
|
+
new.password=billing.crypt(hash,new.salt);
|
|
76
|
+
|
|
77
|
+
end if;
|
|
78
|
+
RETURN new;
|
|
79
|
+
END
|
|
80
|
+
$BODY$
|
|
81
|
+
|
|
82
|
+
LANGUAGE plpgsql VOLATILE COST 100;
|
|
83
|
+
|
|
84
|
+
DROP TRIGGER if exists insert_update_user_before on billing.users;
|
|
85
|
+
CREATE TRIGGER insert_update_user_before BEFORE INSERT OR UPDATE ON billing.users FOR EACH ROW
|
|
86
|
+
EXECUTE PROCEDURE billing.insert_update_user_before();
|
|
87
|
+
|
|
88
|
+
CREATE TABLE if not exists billing.users_social_auth();
|
|
89
|
+
ALTER TABLE billing.users_social_auth DROP CONSTRAINT if exists billing_users_social_auth_usa_id_pkey cascade;
|
|
90
|
+
ALTER TABLE billing.users_social_auth DROP CONSTRAINT if exists billing_users_social_auth_user_id_fkey cascade;
|
|
91
|
+
|
|
92
|
+
CREATE TABLE if not exists billing.users_social_auth();
|
|
93
|
+
ALTER TABLE billing.users_social_auth add column if not exists usa_id text NOT NULL DEFAULT next_id();
|
|
94
|
+
ALTER TABLE billing.users_social_auth add column if not exists user_id text;
|
|
95
|
+
ALTER TABLE billing.users_social_auth add column if not exists user_name text;
|
|
96
|
+
ALTER TABLE billing.users_social_auth add column if not exists sur_name text;
|
|
97
|
+
ALTER TABLE billing.users_social_auth add column if not exists email text;
|
|
98
|
+
ALTER TABLE billing.users_social_auth add column if not exists city text;
|
|
99
|
+
ALTER TABLE billing.users_social_auth add column if not exists phone text;
|
|
100
|
+
ALTER TABLE billing.users_social_auth add column if not exists social_auth_id text;
|
|
101
|
+
ALTER TABLE billing.users_social_auth add column if not exists social_auth_type text;
|
|
102
|
+
ALTER TABLE billing.users_social_auth add column if not exists social_auth_code text;
|
|
103
|
+
ALTER TABLE billing.users_social_auth add column if not exists social_auth_obj json;
|
|
104
|
+
ALTER TABLE billing.users_social_auth add column if not exists social_auth_date timestamp without time zone;
|
|
105
|
+
ALTER TABLE billing.users_social_auth add column if not exists social_auth_softpro_code text;
|
|
106
|
+
ALTER TABLE billing.users_social_auth add column if not exists enabled boolean;
|
|
107
|
+
ALTER TABLE billing.users_social_auth add column if not exists cdate timestamp without time zone DEFAULT date_trunc('seconds'::text, now());
|
|
108
|
+
ALTER TABLE billing.users_social_auth add column if not exists editor_date timestamp without time zone;
|
|
109
|
+
ALTER TABLE billing.users_social_auth add column if not exists uid text;
|
|
110
|
+
ALTER TABLE billing.users_social_auth add column if not exists editor_id text;
|
|
111
|
+
ALTER TABLE billing.users_social_auth add column if not exists files json;
|
|
112
|
+
ALTER TABLE billing.users_social_auth add column if not exists lang text;
|
|
113
|
+
ALTER TABLE billing.users_social_auth add column if not exists social_auth_url text;
|
|
114
|
+
|
|
115
|
+
COMMENT ON TABLE billing.users_social_auth IS 'Авторизація користувачів через соц. мережі';
|
|
116
|
+
COMMENT ON COLUMN billing.users_social_auth.user_id IS 'ID користувача';
|
|
117
|
+
|
|
118
|
+
ALTER TABLE billing.users add CONSTRAINT billing_user_id_pkey PRIMARY KEY (user_id);
|
|
119
|
+
ALTER TABLE billing.users_social_auth add CONSTRAINT billing_users_social_auth_usa_id_pkey PRIMARY KEY (usa_id);
|
|
120
|
+
ALTER TABLE billing.users_social_auth add CONSTRAINT billing_users_social_auth_user_id_fkey FOREIGN KEY (user_id)
|
|
121
121
|
REFERENCES billing.users (user_id);
|