Просмотр исходного кода

#347 OAuth2: URL checking, adding URL filed in list of clients

Alex Trofimov 10 лет назад
Родитель
Сommit
dfa90ab843

+ 4 - 3
modules/boonex/oauth2/classes/BxOAuthFormAdd.php

@@ -42,7 +42,7 @@ class BxOAuthFormAdd extends BxTemplFormView
                     'required' => true,
                     'checker' => array (
                         'func' => 'avail',
-                        'error' => _t ('_sys_adm_form_err_required_field'),
+                        'error' => _t ('_sys_form_account_input_name_error'),
                     ),
                     'db' => array (
                         'pass' => 'Xss',
@@ -55,8 +55,9 @@ class BxOAuthFormAdd extends BxTemplFormView
                     'caption' => _t('_bx_oauth_client_url'),
                     'required' => true,
                     'checker' => array (
-                        'func' => 'avail',
-                        'error' => _t ('_sys_adm_form_err_required_field'),
+                        'func' => 'preg',
+                        'params' => array('/^https?:\/\//'),
+                        'error' => _t ('_bx_oauth_form_valid_url'),
                     ),
                     'db' => array (
                         'pass' => 'Xss',

+ 3 - 1
modules/boonex/oauth2/install/langs/en.xml

@@ -14,7 +14,9 @@ Specify the following "Dolphin Connect URL" on the client sites:<br />
 	<string name="_bx_oauth_add"><![CDATA[Add new client]]></string>
 	<string name="_bx_oauth_clients"><![CDATA[OAuth2 clients]]></string>
 	<string name="_bx_oauth_authorization"><![CDATA[Authorization]]></string>
-	<string name="_bx_oauth_authorize_app"><![CDATA[Choose profile to use on "{0}" site:]]></string>
+    <string name="_bx_oauth_authorize_app"><![CDATA[Choose profile to use on "{0}" site:]]></string>
+    <string name="_bx_oauth_form_valid_url"><![CDATA[Valid URL is required]]></string>
+    <string name="_bx_oauth_url"><![CDATA[URL]]></string>
 
 	<string name="_bx_oauth_adm_stg_cpt_type"><![CDATA[OAuth2 Server]]></string>
 	<string name="_bx_oauth_adm_stg_cpt_category_general"><![CDATA[General]]></string>

+ 5 - 4
modules/boonex/oauth2/install/sql/enable.sql

@@ -2,13 +2,14 @@
 -- GRID
 
 INSERT INTO `sys_objects_grid` (`object`, `source_type`, `source`, `table`, `field_id`, `field_order`, `paginate_url`, `paginate_per_page`, `paginate_simple`, `paginate_get_start`, `paginate_get_per_page`, `filter_fields`, `filter_mode`, `sorting_fields`, `override_class_name`, `override_class_file`) VALUES
-('bx_oauth', 'Sql', 'SELECT * FROM `bx_oauth_clients`', 'bx_oauth_clients', 'id', '', '', 10, NULL, 'start', '', 'title,client_id,client_secret', 'auto', 'title,client_id,client_secret', 'BxOAuthGrid', 'modules/boonex/oauth2/classes/BxOAuthGrid.php');
+('bx_oauth', 'Sql', 'SELECT * FROM `bx_oauth_clients`', 'bx_oauth_clients', 'id', '', '', 10, NULL, 'start', '', 'title,client_id,client_secret,redirect_uri', 'auto', 'title,client_id,client_secret,redirect_uri', 'BxOAuthGrid', 'modules/boonex/oauth2/classes/BxOAuthGrid.php');
 
 INSERT INTO `sys_grid_fields` (`object`, `name`, `title`, `width`, `params`, `order`) VALUES
 ('bx_oauth', 'checkbox', 'Select', '2%', '', 10),
-('bx_oauth', 'title', '_Title', '28%', '', 20),
-('bx_oauth', 'client_id', '_bx_oauth_client_id', '35%', '', 30),
-('bx_oauth', 'client_secret', '_bx_oauth_client_secret', '35%', '', 40);
+('bx_oauth', 'title', '_Title', '20%', '', 20),
+('bx_oauth', 'client_id', '_bx_oauth_client_id', '15%', '', 30),
+('bx_oauth', 'client_secret', '_bx_oauth_client_secret', '30%', '', 40),
+('bx_oauth', 'redirect_uri', '_bx_oauth_url', '33%', '', 50);
 
 INSERT INTO `sys_grid_actions` (`object`, `type`, `name`, `title`, `confirm`, `order`) VALUES
 ('bx_oauth', 'bulk', 'delete', '_Delete', 1, 1),

+ 3 - 1
modules/boonex/russian/data/langs/bx_oauth/ru.xml

@@ -14,7 +14,9 @@
 	<string name="_bx_oauth_add"><![CDATA[Добавить]]></string>
 	<string name="_bx_oauth_clients"><![CDATA[Клиенты OAuth2]]></string>
 	<string name="_bx_oauth_authorization"><![CDATA[Authorization]]></string>
-	<string name="_bx_oauth_authorize_app"><![CDATA[Выбери профайл, для использования на "{0}" сайте:]]></string>
+    <string name="_bx_oauth_authorize_app"><![CDATA[Выбери профайл, для использования на "{0}" сайте:]]></string>
+    <string name="_bx_oauth_form_valid_url"><![CDATA[Нужно ввести правильный URL]]></string>
+    <string name="_bx_oauth_url"><![CDATA[URL]]></string>
 
 	<string name="_bx_oauth_adm_stg_cpt_type"><![CDATA[OAuth2 сервер]]></string>
 	<string name="_bx_oauth_adm_stg_cpt_category_general"><![CDATA[Общие]]></string>