Skip to content

Commit 78ef7af

Browse files
committed
Removed obsolete calls, harmonized predefine response, added non admin user pages.
When access is denied, also provide when possible and wanted, the needed permissions so that in the future, user will be able to ask for permission easily. Renamed previous user handlers as admin user handlers. Added non admin user handler /user/{uid} . Add new `send_...` response to `CMS_API.response_api`, and use them instead of `create {...RESPONSE}.... ; execute`. Fixed potential issue with storage mailer initialization if folder does not exist. Added utf_8_encoded helpers function on CMS_API interface. Fixed a few unicode potential issues. Removed a few obsolete calls.
1 parent 359344c commit 78ef7af

File tree

73 files changed

+903
-343
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+903
-343
lines changed

dev_modules/masquerade_auth/masquerade_auth_module.e

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,10 +183,10 @@ feature {NONE} -- Implementation: routes
183183
create {BAD_REQUEST_ERROR_CMS_RESPONSE} r.make (req, res, api)
184184
r.add_block (login_block ("login", "Wrong username", r), "content")
185185
end
186+
r.execute
186187
else
187-
create {FORBIDDEN_ERROR_CMS_RESPONSE} r.make (req, res, api)
188+
api.response_api.send_access_denied (Void, req, res)
188189
end
189-
r.execute
190190
end
191191

192192
feature -- Hooks configuration
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
ul.horizontal {
2+
li {
3+
display: inline-block;
4+
}
5+
}
6+
7+
#header {
8+
#primary.menu {
9+
ul {
10+
li {
11+
color: #555;
12+
a {
13+
color: #555;
14+
text-decoration: none;
15+
&:hover { color: black; }
16+
}
17+
background-color: #fff;
18+
padding: 10px;
19+
margin: 0;
20+
}
21+
&.horizontal {
22+
border-bottom: solid 1px #ddd;
23+
li {
24+
border-top: solid 3px #fff;
25+
&:hover {
26+
background-color: #ffe;
27+
border-top: solid 3px #999;
28+
}
29+
&.active {
30+
font-weight: bold;
31+
border-top: solid 3px #ddd;
32+
background-color: #ddd;
33+
}
34+
&.active:hover {
35+
border-top: solid 3px blue;
36+
}
37+
}
38+
}
39+
}
40+
}
41+
}
42+
#content {
43+
margin-left: 20px;
44+
#highlighted {
45+
position: relative;
46+
border: solid 1px #ddd;
47+
background-color: #ffc;
48+
width: 70%;
49+
left: 15%;
50+
right: 15%;
51+
padding: 5px;
52+
font-style: italic;
53+
}
54+
.preview {
55+
border: solid 1px red;
56+
}
57+
}
58+
.sidebar {
59+
padding: 5px;
60+
margin: 3px;
61+
/* border: solid 1px #ccc; */
62+
&#sidebar_first {
63+
width: 250px;
64+
position: fixed;
65+
top: 45px;
66+
left: 0;
67+
bottom: 0;
68+
width: 200px;
69+
border-right: solid 1px #ddd;
70+
}
71+
&#sidebar_second {
72+
width: 250px;
73+
float: right;
74+
}
75+
76+
&+.main {
77+
margin-left: 200px;
78+
}
79+
}
80+
#primary-tabs {
81+
ul.horizontal {
82+
list-style-type: none;
83+
li {
84+
display: inline;
85+
padding: 2px 5px;
86+
border: solid 1px #ccf;
87+
}
88+
li.active {
89+
border-color: #99f #99f #ddd;
90+
border-style: solid solid none;
91+
border-width: 2px 1px 0;
92+
padding: 2px 7px 1px;
93+
}
94+
}
95+
}
96+
#message li.error {
97+
background-color: #f99;
98+
border: solid 1px red;
99+
padding: 5px 2px 5px 2px;
100+
}
101+
102+
table.with_border {
103+
thead td {
104+
font-weight: bold;
105+
}
106+
td {
107+
border: solid 1px #ccc;
108+
padding: 2px 5px 2px 5px;
109+
}
110+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{assign name="debug_enabled" value="True"/}
2+
{if condition="$debug_enabled"}
3+
<!-- start debug -->
4+
{literal}
5+
<style>
6+
div.cms-debug>span {
7+
position: absolute;
8+
bottom: 5px;
9+
right: 5px;
10+
color: #ccc;
11+
padding: 5px;
12+
}
13+
div.cms-debug:hover>span {
14+
color: red;
15+
}
16+
div.cms-debug>span+ul {
17+
display: none;
18+
border: solid 2px red;
19+
background-color: #ccc;
20+
white-space: pre-wrap;
21+
}
22+
div.cms-debug:hover>span+ul {
23+
display: block;
24+
position: relative;
25+
bottom: 5px;
26+
left: 1%; right: 1%;
27+
width: 98%;
28+
}
29+
</style>
30+
{/literal}
31+
<div class="cms-debug"><span>Show debug</span>
32+
<ul>
33+
{assign name="kpage" value="page"/}{assign name="kregions" value="regions"/}{foreach key="k" item="i" from="$page.variables"}{unless condition="$k ~ $kpage"}{unless condition="$k ~ $kregions"}<li><strong>{$k/}</strong>={htmlentities}{$i/}{/htmlentities}</li>{/unless}{/unless}
34+
{/foreach}
35+
</ul>
36+
</div>
37+
<!-- end debug -->
38+
{/if}

library/model/src/user/cms_user.e

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,19 @@ create
1717

1818
feature {NONE} -- Initialization
1919

20-
make (a_name: READABLE_STRING_32)
20+
make (a_name: READABLE_STRING_GENERAL)
2121
-- Create an object with name `a_name'.
2222
require
2323
a_name_not_empty: not a_name.is_whitespace
2424
do
25-
name := a_name
25+
if attached {READABLE_STRING_32} a_name as n32 then
26+
name := n32
27+
else
28+
name := a_name.to_string_32
29+
end
2630
initialize
2731
ensure
28-
name_set: name = a_name
32+
name_set: name.same_string_general (a_name)
2933
status_not_active: status = not_active
3034
end
3135

library/recaptcha/recaptcha-safe.ecf

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,18 @@
33
<target name="recaptcha">
44
<root all_classes="true"/>
55
<file_rule>
6-
<exclude>/.git$</exclude>
6+
<exclude>/\.git$</exclude>
77
<exclude>/EIFGENs$</exclude>
88
<exclude>/CVS$</exclude>
9-
<exclude>/.svn$</exclude>
9+
<exclude>/\.svn$</exclude>
1010
</file_rule>
1111
<option warning="true" void_safety="all">
1212
</option>
1313
<setting name="concurrency" value="scoop"/>
1414
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/>
1515
<library name="http_client_extension" location="..\http_client_extension\http_client_extension-safe.ecf"/>
16-
<library name="json" location="$ISE_LIBRARY\contrib\library\text\parser\json\library\json-safe.ecf" readonly="false"/>
16+
<library name="json" location="$ISE_LIBRARY\contrib\library\text\parser\json\library\json-safe.ecf"/>
17+
<library name="uri" location="$ISE_LIBRARY\library\text\uri\uri-safe.ecf"/>
1718
<cluster name="recaptcha" location=".\src\" recursive="true"/>
1819
</target>
1920
</system>

library/recaptcha/recaptcha.ecf

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,18 @@
33
<target name="recaptcha">
44
<root all_classes="true"/>
55
<file_rule>
6-
<exclude>/.git$</exclude>
6+
<exclude>/\.git$</exclude>
77
<exclude>/EIFGENs$</exclude>
88
<exclude>/CVS$</exclude>
9-
<exclude>/.svn$</exclude>
9+
<exclude>/\.svn$</exclude>
1010
</file_rule>
1111
<option warning="true" void_safety="none">
12-
<assertions precondition="true" postcondition="true" check="true" invariant="true" loop="true" supplier_precondition="true"/>
1312
</option>
14-
<setting name="console_application" value="true"/>
13+
<setting name="concurrency" value="scoop"/>
1514
<library name="base" location="$ISE_LIBRARY\library\base\base.ecf"/>
16-
<library name="base_extension" location="$ISE_LIBRARY\library\base_extension\base_extension.ecf"/>
1715
<library name="http_client_extension" location="..\http_client_extension\http_client_extension.ecf"/>
18-
<library name="json" location="$ISE_LIBRARY\contrib\library\text\parser\json\library\json.ecf" readonly="false"/>
16+
<library name="json" location="$ISE_LIBRARY\contrib\library\text\parser\json\library\json.ecf"/>
17+
<library name="uri" location="$ISE_LIBRARY\library\text\uri\uri.ecf"/>
1918
<cluster name="recaptcha" location=".\src\" recursive="true">
2019
</cluster>
2120
</target>

library/recaptcha/src/recaptcha_api.e

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -98,26 +98,24 @@ feature {NONE} -- REST API
9898

9999
get: detachable RESPONSE
100100
-- Reading Data
101-
local
102-
l_request: REQUEST
103101
do
104-
create l_request.make ("GET", new_uri)
105-
Result := l_request.execute
102+
Result := (create {REQUEST}.make ("GET", new_uri)).execute
106103
end
107104

108105
feature {NONE} -- Implementation
109106

110107
new_uri: STRING_8
111108
-- new uri (BaseUri?secret=secret_value&response=response_value[&remoteip=remoteip_value]
109+
local
110+
l_uri: URI
112111
do
113-
create Result.make_from_string (base_uri)
114-
Result.append ("?secret=")
115-
Result.append (secret)
116-
Result.append ("&response=")
117-
Result.append (response)
112+
create l_uri.make_from_string (base_uri)
113+
l_uri.add_query_parameter ("secret", secret)
114+
l_uri.add_query_parameter ("response", response)
118115
if attached remoteip as l_remoteip then
119-
Result.append ("&remoteip=" + l_remoteip)
116+
l_uri.add_query_parameter ("remoteip", l_remoteip)
120117
end
118+
Result := l_uri.string
121119
end
122120

123121
put_error (a_code: READABLE_STRING_GENERAL)
@@ -134,7 +132,7 @@ feature {NONE} -- Implementation
134132
end
135133

136134
note
137-
copyright: "2011-2015 Javier Velilla, Jocelyn Fiat, Eiffel Software and others"
135+
copyright: "2011-2017 Javier Velilla, Jocelyn Fiat, Eiffel Software and others"
138136
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
139137
source: "[
140138
Eiffel Software

modules/admin/cms_admin_module_administration.e

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ feature {NONE} -- Router/administration
5151
l_roles_handler: CMS_ADMIN_ROLES_HANDLER
5252
l_formats_handler: CMS_ADMIN_FORMATS_HANDLER
5353

54-
l_user_handler: CMS_USER_HANDLER
54+
l_user_handler: CMS_ADMIN_USER_HANDLER
5555
l_role_handler: CMS_ROLE_HANDLER
5656
l_admin_logs_handler: CMS_LOGS_HANDLER
5757

modules/admin/handler/cms_admin_cache_handler.e

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,10 @@ feature -- Execution
4747
create s.make_empty
4848
f.append_to_html (l_response.wsf_theme, s)
4949
l_response.set_main_content (s)
50+
l_response.execute
5051
else
51-
create {FORBIDDEN_ERROR_CMS_RESPONSE} l_response.make (req, res, api)
52+
send_custom_access_denied (Void, <<"admin cache">>, req, res)
5253
end
53-
l_response.execute
5454
end
5555

5656
do_post (req: WSF_REQUEST; res: WSF_RESPONSE)
@@ -77,10 +77,10 @@ feature -- Execution
7777
create s.make_empty
7878
f.append_to_html (l_response.wsf_theme, s)
7979
l_response.set_main_content (s)
80+
l_response.execute
8081
else
81-
create {FORBIDDEN_ERROR_CMS_RESPONSE} l_response.make (req, res, api)
82+
send_custom_access_denied (Void, <<"admin cache">>, req, res)
8283
end
83-
l_response.execute
8484
end
8585

8686
feature -- Widget

modules/admin/handler/cms_admin_export_handler.e

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,10 @@ feature -- Execution
4747
create s.make_empty
4848
f.append_to_html (l_response.wsf_theme, s)
4949
l_response.set_main_content (s)
50+
l_response.execute
5051
else
51-
create {FORBIDDEN_ERROR_CMS_RESPONSE} l_response.make (req, res, api)
52+
send_access_denied (req, res)
5253
end
53-
l_response.execute
5454
end
5555

5656
do_post (req: WSF_REQUEST; res: WSF_RESPONSE)
@@ -92,10 +92,10 @@ feature -- Execution
9292
create s.make_empty
9393
f.append_to_html (l_response.wsf_theme, s)
9494
l_response.set_main_content (s)
95+
l_response.execute
9596
else
96-
create {FORBIDDEN_ERROR_CMS_RESPONSE} l_response.make (req, res, api)
97+
send_access_denied (req, res)
9798
end
98-
l_response.execute
9999
end
100100

101101
feature -- Widget

modules/admin/handler/cms_admin_handler.e

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ note
33
handler for CMS admin in the CMS interface.
44
55
TODO: implement REST API.
6-
]"
6+
]"
77
date: "$Date$"
88
revision: "$Revision$"
99

@@ -64,25 +64,23 @@ feature -- HTTP Methods
6464
local
6565
r: CMS_RESPONSE
6666
do
67-
create {FORBIDDEN_ERROR_CMS_RESPONSE} r.make (req, res, api)
68-
if r.has_permission ("manage " + {CMS_ADMIN_MODULE}.name) then
67+
if api.has_permission ("manage " + {CMS_ADMIN_MODULE}.name) then
6968
create {CMS_ADMIN_RESPONSE} r.make (req, res, api)
7069
r.execute
7170
else
72-
r.execute
71+
send_access_denied (req, res)
7372
end
7473
end
7574

7675
do_post (req: WSF_REQUEST; res: WSF_RESPONSE)
7776
local
7877
r: CMS_RESPONSE
7978
do
80-
create {FORBIDDEN_ERROR_CMS_RESPONSE} r.make (req, res, api)
81-
if r.has_permission ("manage " + {CMS_ADMIN_MODULE}.name) then
79+
if api.has_permission ("manage " + {CMS_ADMIN_MODULE}.name) then
8280
create {CMS_ADMIN_RESPONSE} r.make (req, res, api)
8381
r.execute
8482
else
85-
r.execute
83+
send_access_denied (req, res)
8684
end
8785
end
8886

0 commit comments

Comments
 (0)