Updated CMS code.
Separated code to have a lib and an example. Improved design, fixed a few issues related to folder location. This is still experimental and require more work to be really friendly to use.
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
note
|
||||
description: "Summary description for {ADMIN_BLOCKS_CMS_EXECUTION}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
ADMIN_BLOCKS_CMS_EXECUTION
|
||||
|
||||
inherit
|
||||
CMS_EXECUTION
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature -- Execution
|
||||
|
||||
process
|
||||
-- Computed response message.
|
||||
local
|
||||
b: STRING_8
|
||||
do
|
||||
set_title ("Blocks")
|
||||
-- check Permission !!!
|
||||
create b.make_empty
|
||||
if has_permission ("administrate blocks") then
|
||||
b.append ("<ul id=%"block-list%">")
|
||||
across
|
||||
blocks as c
|
||||
loop
|
||||
if attached c.item as b_info then
|
||||
if b_info.block.is_enabled then
|
||||
b.append ("<li class=%"enabled%">")
|
||||
else
|
||||
b.append ("<li class=%"disabled%">")
|
||||
end
|
||||
b.append ("<strong>" + b_info.name + "</strong> (region=" + b_info.region + ")")
|
||||
if b_info.block.is_enabled then
|
||||
b.append (" [<a href=%"%">disable</a>]")
|
||||
else
|
||||
b.append (" [<a href=%"%">enable</a>]")
|
||||
end
|
||||
if attached b_info.block.title as l_title then
|
||||
b.append ("<div>title=<em>" + l_title + "</em></div>")
|
||||
end
|
||||
b.append ("</li>")
|
||||
end
|
||||
end
|
||||
b.append ("</ul>")
|
||||
else
|
||||
b.append ("<div class=%"denied%">Access denied</div>")
|
||||
end
|
||||
|
||||
set_main_content (b)
|
||||
end
|
||||
|
||||
end
|
||||
@@ -0,0 +1,43 @@
|
||||
note
|
||||
description: "Summary description for {CMS_ADMIN_EXECUTION}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
ADMIN_CMS_EXECUTION
|
||||
|
||||
inherit
|
||||
CMS_EXECUTION
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature -- Execution
|
||||
|
||||
process
|
||||
-- Computed response message.
|
||||
local
|
||||
b: STRING_8
|
||||
do
|
||||
set_title ("Administration")
|
||||
-- check Permission !!!
|
||||
create b.make_empty
|
||||
if has_permission ("administrate modules") then
|
||||
b.append ("<li>" + link ("Modules", "/admin/modules/", Void) + "</li>")
|
||||
end
|
||||
if has_permission ("administrate blocks") then
|
||||
b.append ("<li>" + link ("Blocks", "/admin/blocks/", Void) + "</li>")
|
||||
end
|
||||
if has_permission ("administrate users") then
|
||||
b.append ("<li>" + link ("Users", "/admin/users/", Void) + "</li>")
|
||||
end
|
||||
if has_permission ("administrate logs") then
|
||||
b.append ("<li>" + link ("Logs", "/admin/logs/", Void) + "</li>")
|
||||
end
|
||||
|
||||
|
||||
set_main_content (b)
|
||||
end
|
||||
|
||||
end
|
||||
@@ -0,0 +1,47 @@
|
||||
note
|
||||
description: "Summary description for {ADMIN_LOGS_CMS_EXECUTION}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
ADMIN_LOGS_CMS_EXECUTION
|
||||
|
||||
inherit
|
||||
CMS_EXECUTION
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature -- Execution
|
||||
|
||||
process
|
||||
-- Computed response message.
|
||||
local
|
||||
b: STRING_8
|
||||
do
|
||||
set_title ("Logs")
|
||||
-- check Permission !!!
|
||||
create b.make_empty
|
||||
if has_permission ("admin logs") then
|
||||
b.append ("<ul id=%"log-list%">")
|
||||
across
|
||||
storage.recent_logs (1, 25) as c
|
||||
loop
|
||||
if attached c.item as l_log then
|
||||
b.append ("<li class=%"log%">")
|
||||
b.append (link ("[" + l_log.id.out + "]", "/admin/log/" + l_log.id.out, Void))
|
||||
b.append (" <strong>" + l_log.category + "</strong> (level=" + l_log.level_name + ")")
|
||||
b.append (": " + truncated_string (l_log.message, 60, "..."))
|
||||
b.append ("</li>")
|
||||
end
|
||||
end
|
||||
b.append ("</ul>")
|
||||
else
|
||||
b.append ("<div class=%"denied%">Access denied</div>")
|
||||
end
|
||||
|
||||
set_main_content (b)
|
||||
end
|
||||
|
||||
end
|
||||
100
draft/application/cms/src/modules/admin/admin_module.e
Normal file
100
draft/application/cms/src/modules/admin/admin_module.e
Normal file
@@ -0,0 +1,100 @@
|
||||
note
|
||||
description: "Summary description for {ADMIN_MODULE}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
ADMIN_MODULE
|
||||
|
||||
inherit
|
||||
CMS_MODULE
|
||||
|
||||
CMS_HOOK_MENU_ALTER
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make (a_service: like service)
|
||||
do
|
||||
service := a_service
|
||||
name := "admin"
|
||||
version := "1.0"
|
||||
description := "Set of service to administrate the site"
|
||||
package := "core"
|
||||
|
||||
enable
|
||||
end
|
||||
|
||||
feature {CMS_SERVICE} -- Registration
|
||||
|
||||
service: CMS_SERVICE
|
||||
|
||||
register (a_service: CMS_SERVICE)
|
||||
do
|
||||
a_service.map_uri ("/admin/", agent handle_admin)
|
||||
a_service.map_uri ("/admin/users/", agent handle_admin_users)
|
||||
a_service.map_uri ("/admin/blocks/", agent handle_admin_blocks)
|
||||
a_service.map_uri ("/admin/modules/", agent handle_admin_modules)
|
||||
a_service.map_uri ("/admin/logs/", agent handle_admin_logs)
|
||||
a_service.map_uri_template ("/admin/log/{log-id}", agent handle_admin_log_view)
|
||||
|
||||
a_service.add_menu_alter_hook (Current)
|
||||
end
|
||||
|
||||
feature -- Hooks
|
||||
|
||||
menu_alter (a_menu_system: CMS_MENU_SYSTEM; a_execution: CMS_EXECUTION)
|
||||
local
|
||||
lnk: CMS_LOCAL_LINK
|
||||
do
|
||||
create lnk.make ("Administer", "/admin/")
|
||||
lnk.set_permission_arguments (<<"administer">>)
|
||||
a_menu_system.management_menu.extend (lnk)
|
||||
end
|
||||
|
||||
links: HASH_TABLE [CMS_MODULE_LINK, STRING]
|
||||
-- Link indexed by path
|
||||
local
|
||||
-- lnk: CMS_MODULE_LINK
|
||||
do
|
||||
create Result.make (3)
|
||||
-- create lnk.make ("Date/time demo")
|
||||
-- lnk.set_callback (agent process_date_time_demo, <<"arg">>)
|
||||
-- Result["/demo/date/{arg}"] := lnk
|
||||
end
|
||||
|
||||
handle_admin (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
do
|
||||
(create {ADMIN_CMS_EXECUTION}.make (req, res, service)).execute
|
||||
end
|
||||
|
||||
handle_admin_users (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
do
|
||||
(create {ADMIN_USERS_CMS_EXECUTION}.make (req, res, service)).execute
|
||||
end
|
||||
|
||||
handle_admin_blocks (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
do
|
||||
(create {ADMIN_BLOCKS_CMS_EXECUTION}.make (req, res, service)).execute
|
||||
end
|
||||
|
||||
handle_admin_modules (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
do
|
||||
(create {ADMIN_MODULES_CMS_EXECUTION}.make (req, res, service)).execute
|
||||
end
|
||||
|
||||
handle_admin_logs (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
do
|
||||
(create {ADMIN_LOGS_CMS_EXECUTION}.make (req, res, service)).execute
|
||||
end
|
||||
|
||||
handle_admin_log_view (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
do
|
||||
(create {LOG_VIEW_CMS_EXECUTION}.make (req, res, service)).execute
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
@@ -0,0 +1,57 @@
|
||||
note
|
||||
description: "Summary description for {ADMIN_MODULES_CMS_EXECUTION}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
ADMIN_MODULES_CMS_EXECUTION
|
||||
|
||||
inherit
|
||||
CMS_EXECUTION
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature -- Execution
|
||||
|
||||
process
|
||||
-- Computed response message.
|
||||
local
|
||||
b: STRING_8
|
||||
do
|
||||
set_title ("Modules")
|
||||
-- check Permission !!!
|
||||
create b.make_empty
|
||||
if has_permission ("administrate modules") then
|
||||
b.append ("<ul id=%"module-list%">")
|
||||
across
|
||||
service.modules as m
|
||||
loop
|
||||
if attached m.item as mod then
|
||||
if mod.is_enabled then
|
||||
b.append ("<li class=%"enabled%">")
|
||||
else
|
||||
b.append ("<li class=%"disabled%">")
|
||||
end
|
||||
b.append ("<strong>" + mod.name + "</strong> (version:" + mod.version + ")")
|
||||
b.append (" package=" + mod.package)
|
||||
if mod.is_enabled then
|
||||
b.append (" [<a href=%"%">disable</a>]")
|
||||
else
|
||||
b.append (" [<a href=%"%">enable</a>]")
|
||||
end
|
||||
b.append ("<pre>" + mod.description + "</pre>")
|
||||
|
||||
b.append ("</li>")
|
||||
end
|
||||
end
|
||||
b.append ("</ul>")
|
||||
else
|
||||
b.append ("<div class=%"denied%">Access denied</div>")
|
||||
end
|
||||
|
||||
set_main_content (b)
|
||||
end
|
||||
|
||||
end
|
||||
@@ -0,0 +1,56 @@
|
||||
note
|
||||
description: "Summary description for {ADMIN_USERS_CMS_EXECUTION}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
ADMIN_USERS_CMS_EXECUTION
|
||||
|
||||
inherit
|
||||
CMS_EXECUTION
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature -- Execution
|
||||
|
||||
process
|
||||
-- Computed response message.
|
||||
local
|
||||
b: STRING_8
|
||||
do
|
||||
set_title ("Users")
|
||||
-- check Permission !!!
|
||||
create b.make_empty
|
||||
if has_permission ("administrate users") then
|
||||
|
||||
b.append ("<ul id=%"user-list%">")
|
||||
across
|
||||
service.storage.all_users as c
|
||||
loop
|
||||
if attached c.item as u then
|
||||
b.append ("<li class=%"user%">")
|
||||
b.append ("<strong>" + user_link (u) + "</strong> (id=" + u.id.out + ")")
|
||||
if attached u.email as l_email then
|
||||
b.append (" [<a mailto=%""+ l_email +"%">"+ l_email +"</a>]")
|
||||
end
|
||||
if attached u.creation_date as dt then
|
||||
b.append (" - created: " + dt.out)
|
||||
end
|
||||
if attached u.last_login_date as dt then
|
||||
b.append (" - last signed: " + dt.out)
|
||||
end
|
||||
|
||||
b.append ("</li>")
|
||||
end
|
||||
end
|
||||
b.append ("</ul>")
|
||||
else
|
||||
b.append ("<div class=%"denied%">Access denied</div>")
|
||||
end
|
||||
|
||||
set_main_content (b)
|
||||
end
|
||||
|
||||
end
|
||||
@@ -0,0 +1,39 @@
|
||||
note
|
||||
description: "Summary description for {LOG_VIEW_CMS_EXECUTION}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
LOG_VIEW_CMS_EXECUTION
|
||||
|
||||
inherit
|
||||
CMS_EXECUTION
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature -- Execution
|
||||
|
||||
process
|
||||
-- Computed response message.
|
||||
local
|
||||
b: STRING_8
|
||||
do
|
||||
if attached {WSF_STRING} request.path_parameter ("log-id") as p_id and then p_id.is_integer then
|
||||
create b.make_empty
|
||||
|
||||
if attached storage.log (p_id.integer_value) as l_log then
|
||||
set_title ("Log #" + l_log.id.out)
|
||||
b.append (l_log.to_html (theme))
|
||||
else
|
||||
set_title ("Log [" + p_id.value + "] does not exists!")
|
||||
end
|
||||
set_main_content (b)
|
||||
else
|
||||
set_redirection ("/admin/logs")
|
||||
set_main_content ("not found")
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
57
draft/application/cms/src/modules/cms_module.e
Normal file
57
draft/application/cms/src/modules/cms_module.e
Normal file
@@ -0,0 +1,57 @@
|
||||
note
|
||||
description: "Summary description for {WSF_CMS_MODULE}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
deferred class
|
||||
CMS_MODULE
|
||||
|
||||
feature -- Access
|
||||
|
||||
is_enabled: BOOLEAN
|
||||
|
||||
name: STRING
|
||||
|
||||
description: STRING
|
||||
|
||||
package: STRING
|
||||
|
||||
version: STRING
|
||||
|
||||
feature {CMS_SERVICE} -- Registration
|
||||
|
||||
register (a_service: CMS_SERVICE)
|
||||
deferred
|
||||
end
|
||||
|
||||
feature -- Settings
|
||||
|
||||
enable
|
||||
do
|
||||
is_enabled := True
|
||||
end
|
||||
|
||||
disable
|
||||
do
|
||||
is_enabled := False
|
||||
end
|
||||
|
||||
feature -- Hooks
|
||||
|
||||
help_text (a_path: STRING): STRING
|
||||
do
|
||||
Result := ""
|
||||
end
|
||||
|
||||
permissions: LIST [TUPLE [title: detachable STRING; description: detachable STRING]]
|
||||
do
|
||||
create {ARRAYED_LIST [like permissions.item]} Result.make (0)
|
||||
end
|
||||
|
||||
links: HASH_TABLE [CMS_MODULE_LINK, STRING]
|
||||
-- Link indexed by path
|
||||
deferred
|
||||
end
|
||||
|
||||
end
|
||||
50
draft/application/cms/src/modules/cms_module_link.e
Normal file
50
draft/application/cms/src/modules/cms_module_link.e
Normal file
@@ -0,0 +1,50 @@
|
||||
note
|
||||
description: "Summary description for {CMS_MODULE_LINK}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
CMS_MODULE_LINK
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make (a_title: like title)
|
||||
do
|
||||
title := a_title
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
title: STRING_32
|
||||
|
||||
description: detachable STRING_32
|
||||
|
||||
callback: detachable PROCEDURE [ANY, TUPLE [cms: detachable CMS_EXECUTION; args: detachable ITERABLE [STRING]]]
|
||||
callback_arguments: detachable ITERABLE [STRING]
|
||||
|
||||
permission: detachable LIST [STRING]
|
||||
|
||||
parent: detachable CMS_MODULE_LINK
|
||||
|
||||
feature -- Element change
|
||||
|
||||
set_callback (cb: like callback; args: like callback_arguments)
|
||||
do
|
||||
callback := cb
|
||||
callback_arguments := args
|
||||
end
|
||||
|
||||
feature -- Execution
|
||||
|
||||
execute
|
||||
do
|
||||
if attached callback as cb then
|
||||
cb.call ([Void, callback_arguments])
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
75
draft/application/cms/src/modules/node/cms_page.e
Normal file
75
draft/application/cms/src/modules/node/cms_page.e
Normal file
@@ -0,0 +1,75 @@
|
||||
note
|
||||
description: "Summary description for {CMS_PAGE}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
CMS_PAGE
|
||||
|
||||
inherit
|
||||
CMS_NODE
|
||||
|
||||
create
|
||||
make_new,
|
||||
make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make (a_id: like id; a_title: like title; dt: like creation_date)
|
||||
require
|
||||
a_id > 0
|
||||
do
|
||||
set_id (a_id)
|
||||
creation_date := dt
|
||||
modification_date := dt
|
||||
title := a_title
|
||||
initialize
|
||||
end
|
||||
|
||||
make_new (a_title: like title)
|
||||
do
|
||||
title := a_title
|
||||
create creation_date.make_now_utc
|
||||
modification_date := creation_date
|
||||
initialize
|
||||
end
|
||||
|
||||
initialize
|
||||
do
|
||||
format := formats.default_format
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
title: detachable READABLE_STRING_32
|
||||
|
||||
body: detachable READABLE_STRING_8
|
||||
|
||||
format: CMS_FORMAT
|
||||
|
||||
content_type_name: STRING = "page"
|
||||
|
||||
feature -- Change
|
||||
|
||||
set_title (a_title: like title)
|
||||
-- Set `title' to `a_title'
|
||||
do
|
||||
title := a_title
|
||||
end
|
||||
|
||||
set_body (a_body: like body; a_format: like format)
|
||||
-- Set `body' and associated `format'
|
||||
do
|
||||
body := a_body
|
||||
format := a_format
|
||||
end
|
||||
|
||||
feature -- Conversion
|
||||
|
||||
-- to_html (a_theme: CMS_THEME): STRING_8
|
||||
-- do
|
||||
-- Result := Precursor (a_theme)
|
||||
-- end
|
||||
|
||||
end
|
||||
177
draft/application/cms/src/modules/node/cms_page_content_type.e
Normal file
177
draft/application/cms/src/modules/node/cms_page_content_type.e
Normal file
@@ -0,0 +1,177 @@
|
||||
note
|
||||
description: "Summary description for {CMS_PAGE_CONTENT_TYPE}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
CMS_PAGE_CONTENT_TYPE
|
||||
|
||||
inherit
|
||||
CMS_CONTENT_TYPE
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make
|
||||
do
|
||||
create {ARRAYED_LIST [like available_formats.item]} available_formats.make (1)
|
||||
available_formats.extend (formats.plain_text)
|
||||
available_formats.extend (formats.filtered_html)
|
||||
available_formats.extend (formats.full_html)
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
name: STRING = "page"
|
||||
|
||||
title: STRING = "basic page"
|
||||
|
||||
description: detachable READABLE_STRING_8
|
||||
-- Optional description
|
||||
do
|
||||
Result := "Use <em>basic pages</em> for your static content, such as an 'About us' page."
|
||||
end
|
||||
|
||||
available_formats: LIST [CMS_FORMAT]
|
||||
|
||||
feature -- Factory
|
||||
|
||||
fill_edit_form (f: CMS_FORM; a_node: detachable CMS_NODE)
|
||||
local
|
||||
ti: CMS_FORM_TEXT_INPUT
|
||||
fset: CMS_FORM_FIELD_SET
|
||||
ta: CMS_FORM_TEXTAREA
|
||||
tselect: CMS_FORM_SELECT
|
||||
opt: CMS_FORM_SELECT_OPTION
|
||||
do
|
||||
create ti.make ("title")
|
||||
ti.set_label ("Title")
|
||||
ti.set_size (70)
|
||||
if a_node /= Void then
|
||||
ti.set_text_value (a_node.title)
|
||||
end
|
||||
ti.set_is_required (True)
|
||||
f.extend (ti)
|
||||
|
||||
f.extend (create {CMS_FORM_RAW_TEXT}.make ("<br/>"))
|
||||
|
||||
create ta.make ("body")
|
||||
ta.set_rows (10)
|
||||
ta.set_cols (70)
|
||||
if a_node /= Void then
|
||||
ta.set_text_value (a_node.body)
|
||||
end
|
||||
-- ta.set_label ("Body")
|
||||
ta.set_description ("This is the main content")
|
||||
ta.set_is_required (False)
|
||||
|
||||
create fset.make
|
||||
fset.set_legend ("Body")
|
||||
fset.extend (ta)
|
||||
|
||||
|
||||
fset.extend (create {CMS_FORM_RAW_TEXT}.make ("<br/>"))
|
||||
|
||||
create tselect.make ("format")
|
||||
tselect.set_label ("Body's format")
|
||||
tselect.set_is_required (True)
|
||||
across
|
||||
available_formats as c
|
||||
loop
|
||||
create opt.make (c.item.name, c.item.title)
|
||||
if attached c.item.help as f_help then
|
||||
opt.set_description ("<ul>" + f_help + "</ul>")
|
||||
end
|
||||
tselect.add_option (opt)
|
||||
end
|
||||
if a_node /= Void then
|
||||
tselect.set_text_by_value (a_node.format.name)
|
||||
end
|
||||
|
||||
fset.extend (tselect)
|
||||
|
||||
f.extend (fset)
|
||||
|
||||
end
|
||||
|
||||
change_node (a_execution: CMS_EXECUTION; fd: CMS_FORM_DATA; a_node: like new_node)
|
||||
local
|
||||
b: detachable READABLE_STRING_8
|
||||
f: detachable CMS_FORMAT
|
||||
do
|
||||
if attached fd.integer_item ("id") as l_id and then l_id > 0 then
|
||||
check a_node.id = l_id end
|
||||
end
|
||||
if attached fd.string_item ("title") as l_title then
|
||||
a_node.set_title (l_title)
|
||||
end
|
||||
|
||||
if attached fd.string_item ("body") as l_body then
|
||||
b := l_body
|
||||
end
|
||||
if attached fd.string_item ("format") as s_format and then attached formats.format (s_format) as f_format then
|
||||
f := f_format
|
||||
elseif a_node /= Void then
|
||||
f := a_node.format
|
||||
else
|
||||
f := formats.default_format
|
||||
end
|
||||
if b /= Void then
|
||||
a_node.set_body (b, f)
|
||||
end
|
||||
end
|
||||
|
||||
new_node (a_execution: CMS_EXECUTION; fd: CMS_FORM_DATA; a_node: detachable like new_node): CMS_PAGE
|
||||
-- <Precursor>
|
||||
local
|
||||
b: detachable READABLE_STRING_8
|
||||
f: detachable CMS_FORMAT
|
||||
l_node: detachable like new_node
|
||||
do
|
||||
l_node := a_node
|
||||
if attached fd.integer_item ("id") as l_id and then l_id > 0 then
|
||||
if l_node /= Void then
|
||||
check l_node.id = l_id end
|
||||
else
|
||||
if attached {like new_node} a_execution.service.storage.node (l_id) as n then
|
||||
l_node := n
|
||||
else
|
||||
-- FIXME: Error
|
||||
end
|
||||
end
|
||||
end
|
||||
if attached fd.string_item ("title") as l_title then
|
||||
if l_node = Void then
|
||||
create l_node.make_new (l_title)
|
||||
else
|
||||
l_node.set_title (l_title)
|
||||
end
|
||||
else
|
||||
if l_node = Void then
|
||||
create l_node.make_new ("...")
|
||||
end
|
||||
end
|
||||
l_node.set_author (a_execution.user)
|
||||
|
||||
if attached fd.string_item ("body") as l_body then
|
||||
b := l_body
|
||||
end
|
||||
if attached fd.string_item ("format") as s_format and then attached formats.format (s_format) as f_format then
|
||||
f := f_format
|
||||
elseif a_node /= Void then
|
||||
f := a_node.format
|
||||
else
|
||||
f := formats.default_format
|
||||
end
|
||||
if b /= Void then
|
||||
l_node.set_body (b, f)
|
||||
end
|
||||
Result := l_node
|
||||
end
|
||||
|
||||
invariant
|
||||
|
||||
end
|
||||
143
draft/application/cms/src/modules/node/node_add_cms_execution.e
Normal file
143
draft/application/cms/src/modules/node/node_add_cms_execution.e
Normal file
@@ -0,0 +1,143 @@
|
||||
note
|
||||
description: "[
|
||||
]"
|
||||
|
||||
class
|
||||
NODE_ADD_CMS_EXECUTION
|
||||
|
||||
inherit
|
||||
CMS_EXECUTION
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature -- Execution
|
||||
|
||||
process
|
||||
-- Computed response message.
|
||||
local
|
||||
b: STRING_8
|
||||
f: like edit_form
|
||||
fd: detachable CMS_FORM_DATA
|
||||
l_preview: BOOLEAN
|
||||
l_format: detachable CMS_FORMAT
|
||||
do
|
||||
create b.make_empty
|
||||
if attached non_empty_string_path_parameter ("type") as s_type then
|
||||
if attached service.content_type (s_type) as l_type then
|
||||
f := edit_form (Void, request.path_info, "add-" + l_type.name, l_type)
|
||||
if request.is_post_request_method then
|
||||
create fd.make (request, f)
|
||||
l_preview := attached {WSF_STRING} fd.item ("op") as l_op and then l_op.same_string ("Preview")
|
||||
end
|
||||
|
||||
set_title ("Create " + l_type.title)
|
||||
if has_permission ("create " + l_type.name) then
|
||||
|
||||
if fd /= Void and l_preview then
|
||||
b.append ("<strong>Preview</strong><div class=%"preview%">")
|
||||
if attached fd.string_item ("format") as s_format and then attached formats.format (s_format) as f_format then
|
||||
l_format := f_format
|
||||
end
|
||||
if attached fd.string_item ("title") as l_title then
|
||||
b.append ("<strong>Title:</strong><div class=%"title%">" + html_encoded (l_title) + "</div>")
|
||||
end
|
||||
if attached fd.string_item ("body") as l_body then
|
||||
b.append ("<strong>Body:</strong><div class=%"body%">")
|
||||
if l_format /= Void then
|
||||
b.append (l_format.to_html (l_body))
|
||||
else
|
||||
b.append (html_encoded (l_body))
|
||||
end
|
||||
b.append ("</div>")
|
||||
end
|
||||
b.append ("</div>")
|
||||
end
|
||||
|
||||
if fd /= Void and then fd.is_valid and not l_preview then
|
||||
across
|
||||
fd as c
|
||||
loop
|
||||
b.append ("<li>" + html_encoded (c.key) + "=")
|
||||
if attached c.item as v then
|
||||
b.append (html_encoded (v.string_representation))
|
||||
end
|
||||
b.append ("</li>")
|
||||
end
|
||||
if attached l_type.new_node (Current, fd, Void) as l_node then
|
||||
service.storage.save_node (l_node)
|
||||
if attached user as u then
|
||||
service.log ("node", "User %"" + user_link (u) + "%" created node " + link (l_type.name +" #" + l_node.id.out, "/node/" + l_node.id.out , Void), 0, node_local_link (l_node))
|
||||
else
|
||||
service.log ("node", "Anonymous created node "+ l_type.name +" #" + l_node.id.out, 0, node_local_link (l_node))
|
||||
end
|
||||
add_success_message ("Node #" + l_node.id.out + " saved.")
|
||||
set_redirection (node_url (l_node))
|
||||
end
|
||||
-- Creation ...
|
||||
else
|
||||
if fd /= Void then
|
||||
if not fd.is_valid then
|
||||
report_form_errors (fd)
|
||||
end
|
||||
fd.apply_to_associated_form
|
||||
end
|
||||
b.append (f.to_html (theme))
|
||||
end
|
||||
else
|
||||
set_title ("Access denied")
|
||||
end
|
||||
else
|
||||
set_title ("Unknown content type [" + s_type + "]")
|
||||
end
|
||||
else
|
||||
set_title ("Create new content ...")
|
||||
b.append ("<ul id=%"content-types%">")
|
||||
across
|
||||
service.content_types as c
|
||||
loop
|
||||
if has_permission ("create " + c.item.name) then
|
||||
b.append ("<li>" + link (c.item.name, "/node/add/" + c.item.name, Void))
|
||||
if attached c.item.description as d then
|
||||
b.append ("<div class=%"description%">" + d + "</div>")
|
||||
end
|
||||
b.append ("</li>")
|
||||
end
|
||||
end
|
||||
b.append ("</ul>")
|
||||
end
|
||||
set_main_content (b)
|
||||
end
|
||||
|
||||
edit_form (a_node: detachable CMS_NODE; a_url: READABLE_STRING_8; a_name: STRING; a_type: CMS_CONTENT_TYPE): CMS_FORM
|
||||
local
|
||||
f: CMS_FORM
|
||||
ts: CMS_FORM_SUBMIT_INPUT
|
||||
th: CMS_FORM_HIDDEN_INPUT
|
||||
do
|
||||
create f.make (a_url, a_name)
|
||||
|
||||
create th.make ("node-id")
|
||||
if a_node /= Void then
|
||||
th.set_text_value (a_node.id.out)
|
||||
else
|
||||
th.set_text_value ("0")
|
||||
end
|
||||
f.extend (th)
|
||||
|
||||
a_type.fill_edit_form (f, a_node)
|
||||
|
||||
f.extend (create {CMS_FORM_RAW_TEXT}.make ("<br/>"))
|
||||
|
||||
create ts.make ("op")
|
||||
ts.set_default_value ("Save")
|
||||
f.extend (ts)
|
||||
|
||||
create ts.make ("op")
|
||||
ts.set_default_value ("Preview")
|
||||
f.extend (ts)
|
||||
|
||||
Result := f
|
||||
end
|
||||
|
||||
end
|
||||
148
draft/application/cms/src/modules/node/node_edit_cms_execution.e
Normal file
148
draft/application/cms/src/modules/node/node_edit_cms_execution.e
Normal file
@@ -0,0 +1,148 @@
|
||||
note
|
||||
description: "[
|
||||
]"
|
||||
|
||||
class
|
||||
NODE_EDIT_CMS_EXECUTION
|
||||
|
||||
inherit
|
||||
CMS_EXECUTION
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature -- Execution
|
||||
|
||||
process
|
||||
-- Computed response message.
|
||||
local
|
||||
b: STRING_8
|
||||
f: like edit_form
|
||||
fd: detachable CMS_FORM_DATA
|
||||
l_preview: BOOLEAN
|
||||
l_format: detachable CMS_FORMAT
|
||||
do
|
||||
create b.make_empty
|
||||
if
|
||||
attached {WSF_STRING} request.path_parameter ("nid") as p_nid and then
|
||||
p_nid.is_integer and then
|
||||
attached service.storage.node (p_nid.integer_value) as l_node
|
||||
then
|
||||
if attached service.content_type (l_node.content_type_name) as l_type then
|
||||
if has_permission ("edit " + l_type.name) then
|
||||
f := edit_form (l_node, request.path_info, "edit-" + l_type.name, l_type)
|
||||
if request.is_post_request_method then
|
||||
create fd.make (request, f)
|
||||
l_preview := attached {WSF_STRING} fd.item ("op") as l_op and then l_op.same_string ("Preview")
|
||||
end
|
||||
|
||||
set_title ("Edit #" + l_node.id.out)
|
||||
|
||||
add_to_menu (create {CMS_LOCAL_LINK}.make ("View", node_url (l_node)), primary_tabs)
|
||||
add_to_menu (create {CMS_LOCAL_LINK}.make ("Edit", "/node/" + l_node.id.out + "/edit"), primary_tabs)
|
||||
|
||||
if fd /= Void and l_preview then
|
||||
b.append ("<strong>Preview</strong><div class=%"preview%">")
|
||||
if attached fd.string_item ("format") as s_format and then attached formats.format (s_format) as f_format then
|
||||
l_format := f_format
|
||||
end
|
||||
if attached fd.string_item ("title") as l_title then
|
||||
b.append ("<strong>Title:</strong><div class=%"title%">" + html_encoded (l_title) + "</div>")
|
||||
end
|
||||
if attached fd.string_item ("body") as l_body then
|
||||
b.append ("<strong>Body:</strong><div class=%"body%">")
|
||||
if l_format /= Void then
|
||||
b.append (l_format.to_html (l_body))
|
||||
else
|
||||
b.append (html_encoded (l_body))
|
||||
end
|
||||
b.append ("</div>")
|
||||
end
|
||||
b.append ("</div>")
|
||||
end
|
||||
|
||||
if fd /= Void and then fd.is_valid and not l_preview then
|
||||
across
|
||||
fd as c
|
||||
loop
|
||||
b.append ("<li>" + html_encoded (c.key) + "=")
|
||||
if attached c.item as v then
|
||||
b.append (html_encoded (v.string_representation))
|
||||
end
|
||||
b.append ("</li>")
|
||||
end
|
||||
l_type.change_node (Current, fd, l_node)
|
||||
service.storage.save_node (l_node)
|
||||
if attached user as u then
|
||||
service.log ("node", "User %"" + user_link (u) + "%" modified node " + link (l_type.name +" #" + l_node.id.out, "/node/" + l_node.id.out , Void), 0, node_local_link (l_node))
|
||||
else
|
||||
service.log ("node", "Anonymous modified node "+ l_type.name +" #" + l_node.id.out, 0, node_local_link (l_node))
|
||||
end
|
||||
add_success_message ("Node #" + l_node.id.out + " saved.")
|
||||
set_redirection (node_url (l_node))
|
||||
else
|
||||
if fd /= Void then
|
||||
if not fd.is_valid then
|
||||
report_form_errors (fd)
|
||||
end
|
||||
fd.apply_to_associated_form
|
||||
end
|
||||
b.append (f.to_html (theme))
|
||||
end
|
||||
else
|
||||
b.append ("<h1>Access denied</h1>")
|
||||
end
|
||||
else
|
||||
set_title ("Unknown node")
|
||||
end
|
||||
else
|
||||
set_title ("Create new content ...")
|
||||
b.append ("<ul id=%"content-types%">")
|
||||
across
|
||||
service.content_types as c
|
||||
loop
|
||||
if has_permission ("create " + c.item.name) then
|
||||
b.append ("<li>" + link (c.item.name, "/node/add/" + c.item.name, Void))
|
||||
if attached c.item.description as d then
|
||||
b.append ("<div class=%"description%">" + d + "</div>")
|
||||
end
|
||||
b.append ("</li>")
|
||||
end
|
||||
end
|
||||
b.append ("</ul>")
|
||||
end
|
||||
set_main_content (b)
|
||||
end
|
||||
|
||||
edit_form (a_node: detachable CMS_NODE; a_url: READABLE_STRING_8; a_name: STRING; a_type: CMS_CONTENT_TYPE): CMS_FORM
|
||||
local
|
||||
f: CMS_FORM
|
||||
ts: CMS_FORM_SUBMIT_INPUT
|
||||
th: CMS_FORM_HIDDEN_INPUT
|
||||
do
|
||||
create f.make (a_url, a_name)
|
||||
|
||||
create th.make ("node-id")
|
||||
if a_node /= Void then
|
||||
th.set_text_value (a_node.id.out)
|
||||
else
|
||||
th.set_text_value ("0")
|
||||
end
|
||||
f.extend (th)
|
||||
|
||||
a_type.fill_edit_form (f, a_node)
|
||||
|
||||
f.extend (create {CMS_FORM_RAW_TEXT}.make ("<br/>"))
|
||||
|
||||
create ts.make ("op")
|
||||
ts.set_default_value ("Save")
|
||||
f.extend (ts)
|
||||
|
||||
create ts.make ("op")
|
||||
ts.set_default_value ("Preview")
|
||||
f.extend (ts)
|
||||
|
||||
Result := f
|
||||
end
|
||||
|
||||
end
|
||||
113
draft/application/cms/src/modules/node/node_module.e
Normal file
113
draft/application/cms/src/modules/node/node_module.e
Normal file
@@ -0,0 +1,113 @@
|
||||
note
|
||||
description: "Summary description for {NODE_MODULE}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
NODE_MODULE
|
||||
|
||||
inherit
|
||||
CMS_MODULE
|
||||
|
||||
CMS_HOOK_MENU_ALTER
|
||||
|
||||
CMS_HOOK_BLOCK
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make (a_service: like service)
|
||||
do
|
||||
service := a_service
|
||||
name := "node"
|
||||
version := "1.0"
|
||||
description := "Service to manage content based on 'node'"
|
||||
package := "core"
|
||||
|
||||
enable
|
||||
end
|
||||
|
||||
feature {CMS_SERVICE} -- Registration
|
||||
|
||||
service: CMS_SERVICE
|
||||
|
||||
register (a_service: CMS_SERVICE)
|
||||
local
|
||||
h: CMS_HANDLER
|
||||
do
|
||||
a_service.map_uri ("/node/add", agent handle_node_add)
|
||||
a_service.map_uri_template ("/node/add/{type}", agent handle_node_add)
|
||||
|
||||
create {CMS_HANDLER} h.make (agent handle_node_view)
|
||||
a_service.router.map (create {WSF_URI_TEMPLATE_MAPPING}.make ("/node/{nid}", h))
|
||||
a_service.router.map (create {WSF_URI_TEMPLATE_MAPPING}.make ("/node/{nid}/view", h))
|
||||
|
||||
a_service.map_uri_template ("/node/{nid}/edit", agent handle_node_edit)
|
||||
|
||||
a_service.add_content_type (create {CMS_PAGE_CONTENT_TYPE}.make)
|
||||
|
||||
a_service.add_menu_alter_hook (Current)
|
||||
a_service.add_block_hook (Current)
|
||||
end
|
||||
|
||||
feature -- Hooks
|
||||
|
||||
block_list: ITERABLE [like {CMS_BLOCK}.name]
|
||||
do
|
||||
Result := <<"node-info">>
|
||||
end
|
||||
|
||||
get_block_view (a_block_id: detachable READABLE_STRING_8; a_execution: CMS_EXECUTION)
|
||||
-- local
|
||||
-- b: CMS_CONTENT_BLOCK
|
||||
do
|
||||
-- if
|
||||
-- a_execution.is_front and then
|
||||
-- attached a_execution.user as u
|
||||
-- then
|
||||
-- create b.make ("node-info", "Node", "Node ...", a_execution.formats.plain_text)
|
||||
-- a_execution.add_block (b, Void)
|
||||
-- end
|
||||
end
|
||||
|
||||
menu_alter (a_menu_system: CMS_MENU_SYSTEM; a_execution: CMS_EXECUTION)
|
||||
local
|
||||
lnk: CMS_LOCAL_LINK
|
||||
do
|
||||
if a_execution.authenticated then
|
||||
create lnk.make ("Add content", "/node/add/")
|
||||
lnk.set_permission_arguments (<<"authenticated">>)
|
||||
a_menu_system.navigation_menu.extend (lnk)
|
||||
end
|
||||
end
|
||||
|
||||
links: HASH_TABLE [CMS_MODULE_LINK, STRING]
|
||||
-- Link indexed by path
|
||||
local
|
||||
-- lnk: CMS_MODULE_LINK
|
||||
do
|
||||
create Result.make (3)
|
||||
-- create lnk.make ("Date/time demo")
|
||||
-- lnk.set_callback (agent process_date_time_demo, <<"arg">>)
|
||||
-- Result["/demo/date/{arg}"] := lnk
|
||||
end
|
||||
|
||||
handle_node_view (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
do
|
||||
(create {NODE_VIEW_CMS_EXECUTION}.make (req, res, service)).execute
|
||||
end
|
||||
|
||||
handle_node_edit (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
do
|
||||
(create {NODE_EDIT_CMS_EXECUTION}.make (req, res, service)).execute
|
||||
end
|
||||
|
||||
handle_node_add (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
do
|
||||
(create {NODE_ADD_CMS_EXECUTION}.make (req, res, service)).execute
|
||||
end
|
||||
|
||||
end
|
||||
@@ -0,0 +1,41 @@
|
||||
note
|
||||
description: "[
|
||||
]"
|
||||
|
||||
class
|
||||
NODE_VIEW_CMS_EXECUTION
|
||||
|
||||
inherit
|
||||
CMS_EXECUTION
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature -- Execution
|
||||
|
||||
process
|
||||
-- Computed response message.
|
||||
local
|
||||
b: STRING_8
|
||||
do
|
||||
if attached {WSF_STRING} request.path_parameter ("nid") as p_nid and then p_nid.is_integer then
|
||||
create b.make_empty
|
||||
|
||||
if attached storage.node (p_nid.integer_value) as l_node then
|
||||
set_title ("Node [" + l_node.id.out + "]")
|
||||
add_to_menu (create {CMS_LOCAL_LINK}.make ("View", node_url (l_node)), primary_tabs)
|
||||
add_to_menu (create {CMS_LOCAL_LINK}.make ("Edit", "/node/" + l_node.id.out + "/edit"), primary_tabs)
|
||||
|
||||
b.append (l_node.to_html (theme))
|
||||
else
|
||||
set_title ("Node [" + p_nid.value + "] does not exists!")
|
||||
end
|
||||
set_main_content (b)
|
||||
else
|
||||
set_title ("Node ...")
|
||||
create b.make_empty
|
||||
set_main_content (b)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
@@ -0,0 +1,59 @@
|
||||
note
|
||||
description: "[
|
||||
]"
|
||||
|
||||
class
|
||||
USER_ACCOUNT_CMS_EXECUTION
|
||||
|
||||
inherit
|
||||
CMS_EXECUTION
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature -- Execution
|
||||
|
||||
process
|
||||
-- Computed response message.
|
||||
local
|
||||
b: STRING_8
|
||||
vars: detachable ARRAY [READABLE_STRING_32]
|
||||
n: INTEGER
|
||||
-- vars: detachable WSF_TABLE
|
||||
do
|
||||
if attached {WSF_TABLE} request.path_parameter ("vars") as tb then
|
||||
vars := tb.as_array_of_string
|
||||
end
|
||||
if vars = Void or else vars.is_empty then
|
||||
set_title ("Account")
|
||||
create b.make_empty
|
||||
b.append ("Account")
|
||||
set_main_content (b)
|
||||
else
|
||||
n := vars.count
|
||||
create b.make_empty
|
||||
if n >= 1 then
|
||||
if vars[1].same_string ("password") then
|
||||
set_title ("Password")
|
||||
if n >= 2 then
|
||||
if vars[2].same_string ("reset") then
|
||||
b.append ("Reset password")
|
||||
else
|
||||
b.append ("password ???")
|
||||
end
|
||||
end
|
||||
elseif vars[1].same_string ("register") then
|
||||
set_title ("Registration")
|
||||
b.append ("Register new account")
|
||||
else
|
||||
b.append ("???")
|
||||
end
|
||||
else
|
||||
set_title ("Account/")
|
||||
b.append ("...")
|
||||
end
|
||||
set_main_content (b)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
182
draft/application/cms/src/modules/user/user_cms_execution.e
Normal file
182
draft/application/cms/src/modules/user/user_cms_execution.e
Normal file
@@ -0,0 +1,182 @@
|
||||
note
|
||||
description: "[
|
||||
]"
|
||||
|
||||
class
|
||||
USER_CMS_EXECUTION
|
||||
|
||||
inherit
|
||||
CMS_EXECUTION
|
||||
|
||||
USER_MODULE_LIB
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature -- Execution
|
||||
|
||||
process
|
||||
-- Computed response message.
|
||||
local
|
||||
b: STRING_8
|
||||
u: detachable CMS_USER
|
||||
do
|
||||
if attached {WSF_STRING} request.path_parameter ("uid") as p_uid then
|
||||
if p_uid.is_integer then
|
||||
u := service.storage.user_by_id (p_uid.integer_value)
|
||||
else
|
||||
u := service.storage.user_by_name (p_uid.value)
|
||||
end
|
||||
else
|
||||
u := user
|
||||
end
|
||||
initialize_primary_tabs (u)
|
||||
|
||||
if u /= Void then
|
||||
if not u.same_as (user) and then not has_permission ("admin view users") then
|
||||
set_main_content ("Access denied")
|
||||
else
|
||||
service.storage.fill_user_profile (u)
|
||||
create b.make_empty
|
||||
set_title ("User [" + u.name + "]")
|
||||
b.append ("<ul>%N")
|
||||
if attached u.email as l_email then
|
||||
b.append ("<li>Email: <a mailto=%""+ l_email +"%">"+ l_email +"</a></li>")
|
||||
end
|
||||
b.append ("<li>Created: "+ u.creation_date.out +"</li>%N")
|
||||
if attached u.last_login_date as dt then
|
||||
b.append ("<li>Last signed: "+ dt.out +"</li>%N")
|
||||
else
|
||||
b.append ("<li>Never signed yet</li>%N")
|
||||
end
|
||||
if u = user and then attached last_user_access_date as dt then
|
||||
b.append ("<li>Session date: "+ dt.out +"</li>%N")
|
||||
end
|
||||
|
||||
service.storage.fill_user_profile (u)
|
||||
if attached u.profile as prof then
|
||||
across
|
||||
prof as p
|
||||
loop
|
||||
b.append ("<li>" + p.key + "=" + p.item +"</li>%N")
|
||||
end
|
||||
end
|
||||
b.append ("</ul>")
|
||||
set_main_content (b)
|
||||
end
|
||||
else
|
||||
process_login
|
||||
end
|
||||
end
|
||||
|
||||
process_login
|
||||
local
|
||||
l_url: detachable READABLE_STRING_8
|
||||
b: STRING_8
|
||||
f: CMS_FORM
|
||||
fd: detachable CMS_FORM_DATA
|
||||
do
|
||||
if
|
||||
attached {WSF_STRING} request.item ("destination") as s_dest
|
||||
then
|
||||
l_url := request.script_url (s_dest.value)
|
||||
end
|
||||
if l_url = Void then
|
||||
l_url := request.script_url ("/user")
|
||||
end
|
||||
f := login_form (url ("/user", Void), "login-form", l_url)
|
||||
service.call_form_alter_hooks (f, Current)
|
||||
|
||||
if request.is_request_method ("post") then
|
||||
create fd.make (request, f)
|
||||
if fd.is_valid then
|
||||
on_form_submitted (fd)
|
||||
if attached {WSF_STRING} fd.integer_item ("form-destination") as s_dest then
|
||||
l_url := request.script_url (s_dest.value)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if authenticated then
|
||||
set_redirection (l_url)
|
||||
set_title ("Login")
|
||||
create b.make_empty
|
||||
set_main_content (b)
|
||||
set_redirection (url ("/user", Void))
|
||||
else
|
||||
set_title ("Login")
|
||||
create b.make_empty
|
||||
if fd /= Void then
|
||||
if not fd.is_valid then
|
||||
report_form_errors (fd)
|
||||
end
|
||||
fd.apply_to_associated_form
|
||||
end
|
||||
b.append (f.to_html (theme))
|
||||
set_main_content (b)
|
||||
end
|
||||
end
|
||||
|
||||
on_form_submitted (fd: CMS_FORM_DATA)
|
||||
local
|
||||
u: detachable CMS_USER
|
||||
do
|
||||
if attached {WSF_STRING} fd.item (form_username_or_email_name) as s_name and then not s_name.is_empty then
|
||||
u := service.storage.user_by_name (s_name.value)
|
||||
if u = Void then
|
||||
u := service.storage.user_by_email (s_name.value)
|
||||
end
|
||||
end
|
||||
if u = Void then
|
||||
fd.report_error ("Sorry, unrecognized username/email or password. " + link ("Have you forgotten your password?", "/user/password", Void))
|
||||
else
|
||||
if attached {WSF_STRING} fd.item (form_password_name) as s_passwd and then not s_passwd.is_empty then
|
||||
if service.auth_engine.valid_credential (u.name, s_passwd.value) then
|
||||
login (u, request)
|
||||
else
|
||||
fd.report_error ("Sorry, unrecognized username/email or password. " + link ("Have you forgotten your password?", "/user/password", Void))
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
login_form (a_action: READABLE_STRING_8; a_form_name: READABLE_STRING_8; a_destination: READABLE_STRING_8): CMS_FORM
|
||||
local
|
||||
th: CMS_FORM_HIDDEN_INPUT
|
||||
ti: CMS_FORM_TEXT_INPUT
|
||||
tp: CMS_FORM_PASSWORD_INPUT
|
||||
ts: CMS_FORM_SUBMIT_INPUT
|
||||
do
|
||||
create Result.make (a_action, a_form_name)
|
||||
|
||||
create th.make ("form-destination")
|
||||
th.set_default_value (a_destination)
|
||||
Result.extend (th)
|
||||
|
||||
create ti.make (form_username_or_email_name)
|
||||
ti.set_label ("Username or email")
|
||||
ti.set_is_required (True)
|
||||
Result.extend (ti)
|
||||
|
||||
create tp.make (form_password_name)
|
||||
tp.set_label ("Password")
|
||||
tp.set_is_required (True)
|
||||
tp.set_description (link ("Reset password", "/user/password", Void))
|
||||
Result.extend (tp)
|
||||
|
||||
Result.extend_text ("[
|
||||
<img alt="login" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAHiQAAB4kB+XNYvQAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAASmSURBVGiB1ZpbaBxVGMd/Mzu5bSRJY6LubmKJl4J9qShdwdpGGxGlharJSwpVVFrUUF+iT1VEUYRgaEGqsa2FGtu8xNtDsBQi5EFBS8UnsYWUtpsmaqppIdkkm+4eH77ZzWazl7lllv7gPOycmXP+/9kzM+d839GUUnjEOqAL2A7cCdSYJWjWx4F5s/wN/AgMAzNedK65NHI38CKwAwiZpcLitUvAlFlGgBPAFadCnBppAQ4DDwNhQHMqwEQBk8A5oAeYsNuAXSP1QD/wFNBqtzOLxIAzQC9ww/JVSimrZbdSalwplVJrT8rsa7dVfVZNHFRKTftgIJdps++SGksNrSDwLbAFqHUxXNwwB/wEPIe8+fJSzEi12cCDgO61OpukgN+RG7qQ74RiRkaApylg4sj4YZLqpgcalwloBvvu7SlUnQJOI6/6VRQy8jHwKkWG04aRMIlUwp7SElTqlVzYMVnslDlgAHgztyLf3e5GPnLleiaKUYto686tyDXSCHwANPkgyilNiMbG7INGzkn9QJvdltdVNnJg43uOVH34x7vMJP6ze1kbovWl9IFsI+uBJ3Ew3QgGaulqXfVvW+Lg+T5msG1EQ7SuBy7DyqH1GTKHulVoQTQDy0YiwKayyHHHJkR7xsgLyBTcFYupRbdN2CWEaM8Y2Yn7qTjHLw4w9s+o22bsoCHa0YEGZE3hmsXkInvP7vHbTBhoMJDlacTu1fs39JJMJQGoq6jLHE+kEuw9u4ejmwdpv6PDI61FiQBdBtCB9eVphv339xas89lMBdCh48FDno+0GZ+GWchAIh0F+f7q15y6fMJSaxPx2IrfPv4zNQbL4Zq8TM5P8Mu/PzvuwSczQZ0SRrzAh2EW9G3lp6Ghaa4/VQXRKbIO9ooqvYqj0UG2NW9fqy7iBiWMhGtaeOT2Ry21NhGPcXV+5QNfpVdxLPoVW5ufcKzSAnEDicUWZFekk12RTkutHTrfx6ELfZnfYuIkW5sfdyPSCvMGEnv1nOpANcc2n+Sx5va1aD6XKQMYBTqx+XXv//MjbqolAOoqGnjtvjcydT6bWAJGDSS0/w4SWbfM5+OfZKIokZrWjJHqQDVfRE+xpWmbt3ILMwUM68B1PBpeNUaQ49EhP02AaL+eXrN/A0RxuSZ5uW0fFXqlW2F2UIj2zMJqEMlPuMJnEyCaB2HZyBSSZLnVOIf5WGRPUXpwkfoqA1cQzcDKuNYEkil6BZvPSjw5x3BsyJGaeHLOyWUK0ZpJ0eUGseuB34B7SrVUpiB2movAQ2Sl5nJnvzeAt4Fpz9R5zzSicUV+Md80fghJFc/6IMous4i2VeM4N4id5i3gASTRE8h3woGN769JoqcISWDM1LaKUqm3MSSXnteMjySRV207BVJvxVaIC+aFpynvMJs1NRQ0AaWTnAtISHIAuOaZNOtcM/veSRETgK0NA91KqUvKvw0Dl8w+Pd0wkC71SqkjSqnYGpqImX3U29HmdFNNCPgUmTGH8GZTzRTwK/A6DpYVbrc53YXkJ55FouJh7G1zmjTLd8CXwF9Ohbg1ks1twPPAM8i/FCT/xrM4csd/QNYSnrwR/wfI5AekDWyX2QAAAABJRU5ErkJggg=="
|
||||
style="float:right; margin: 5px;"/>
|
||||
]")
|
||||
|
||||
create ts.make ("op")
|
||||
ts.set_default_value ("Log in")
|
||||
Result.extend (ts)
|
||||
|
||||
Result.extend_text ("<p>Need an account?<br/>" + link ("Sign up now!", "/user/register", Void) + "</p>")
|
||||
end
|
||||
|
||||
form_username_or_email_name: STRING = "name"
|
||||
form_password_name: STRING = "password"
|
||||
|
||||
end
|
||||
168
draft/application/cms/src/modules/user/user_edit_cms_execution.e
Normal file
168
draft/application/cms/src/modules/user/user_edit_cms_execution.e
Normal file
@@ -0,0 +1,168 @@
|
||||
note
|
||||
description: "[
|
||||
]"
|
||||
|
||||
class
|
||||
USER_EDIT_CMS_EXECUTION
|
||||
|
||||
inherit
|
||||
CMS_EXECUTION
|
||||
|
||||
USER_MODULE_LIB
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature -- Execution
|
||||
|
||||
process
|
||||
-- Computed response message.
|
||||
local
|
||||
b: STRING_8
|
||||
f: CMS_FORM
|
||||
fd: detachable CMS_FORM_DATA
|
||||
u, fu: detachable CMS_USER
|
||||
up: detachable CMS_USER_PROFILE
|
||||
l_is_editing_current_user: BOOLEAN
|
||||
do
|
||||
if attached {WSF_STRING} request.path_parameter ("uid") as p_uid and then p_uid.is_integer then
|
||||
u := service.storage.user_by_id (p_uid.integer_value)
|
||||
if has_permission ("view users") then
|
||||
else
|
||||
if u /= Void and then u.same_as (user) then
|
||||
else
|
||||
u := Void
|
||||
end
|
||||
end
|
||||
else
|
||||
u := user
|
||||
end
|
||||
if attached user as l_active_user then
|
||||
l_is_editing_current_user := l_active_user.same_as (u)
|
||||
end
|
||||
create b.make_empty
|
||||
initialize_primary_tabs (u)
|
||||
if u = Void then
|
||||
b.append ("Access denied")
|
||||
set_redirection (url ("/user/register", Void))
|
||||
else
|
||||
service.storage.fill_user_profile (u)
|
||||
f := edit_form (u, request.path_info, "user-edit")
|
||||
|
||||
if request.is_post_request_method then
|
||||
create fd.make (request, f)
|
||||
if attached {WSF_STRING} fd.item ("username") as s_username then
|
||||
fu := service.storage.user_by_name (s_username.value)
|
||||
if fu = Void then
|
||||
fd.report_invalid_field ("username", "User does not exist!")
|
||||
end
|
||||
end
|
||||
if attached {WSF_STRING} fd.item ("email") as s_email then
|
||||
fu := service.storage.user_by_email (s_email.value)
|
||||
if fu /= Void and then fu.id /= u.id then
|
||||
fd.report_invalid_field ("email", "Email is already used by another user!")
|
||||
end
|
||||
end
|
||||
fu := Void
|
||||
end
|
||||
if fd /= Void and then fd.is_valid then
|
||||
across
|
||||
fd as c
|
||||
loop
|
||||
b.append ("<li>" + html_encoded (c.key) + "=")
|
||||
if attached c.item as v then
|
||||
b.append (html_encoded (v.string_representation))
|
||||
end
|
||||
b.append ("</li>")
|
||||
end
|
||||
|
||||
if attached {WSF_STRING} fd.item ("password") as s_password then
|
||||
u.set_password (s_password.value)
|
||||
end
|
||||
if attached {WSF_STRING} fd.item ("email") as s_email then
|
||||
u.set_email (s_email.value)
|
||||
end
|
||||
|
||||
if attached {WSF_STRING} fd.item ("note") as s_note then
|
||||
up := u.profile
|
||||
if up = Void then
|
||||
create up.make
|
||||
end
|
||||
up.force (s_note.value, "note")
|
||||
u.set_profile (up)
|
||||
end
|
||||
|
||||
service.storage.save_user (u)
|
||||
if l_is_editing_current_user and u /= user then
|
||||
set_user (u)
|
||||
end
|
||||
set_redirection (url ("/user", Void))
|
||||
set_main_content (b)
|
||||
else
|
||||
if fd /= Void then
|
||||
if not fd.is_valid then
|
||||
report_form_errors (fd)
|
||||
end
|
||||
fd.apply_to_associated_form
|
||||
end
|
||||
b.append (f.to_html (theme))
|
||||
end
|
||||
end
|
||||
set_main_content (b)
|
||||
end
|
||||
|
||||
edit_form (u: CMS_USER; a_url: READABLE_STRING_8; a_name: STRING): CMS_FORM
|
||||
local
|
||||
f: CMS_FORM
|
||||
ti: CMS_FORM_TEXT_INPUT
|
||||
tp: CMS_FORM_PASSWORD_INPUT
|
||||
ta: CMS_FORM_TEXTAREA
|
||||
ts: CMS_FORM_SUBMIT_INPUT
|
||||
do
|
||||
create f.make (a_url, a_name)
|
||||
|
||||
create ti.make ("username")
|
||||
ti.set_label ("Username")
|
||||
ti.set_default_value (u.name)
|
||||
ti.set_is_required (False)
|
||||
ti.set_is_readonly (True)
|
||||
f.extend (ti)
|
||||
|
||||
f.extend (create {CMS_FORM_RAW_TEXT}.make ("<br/>"))
|
||||
|
||||
create tp.make ("password")
|
||||
tp.set_label ("Password")
|
||||
tp.set_is_required (False)
|
||||
f.extend (tp)
|
||||
|
||||
f.extend (create {CMS_FORM_RAW_TEXT}.make ("<br/>"))
|
||||
|
||||
create ti.make ("email")
|
||||
ti.set_label ("Valid email address")
|
||||
if attached u.email as l_email then
|
||||
ti.set_default_value (l_email)
|
||||
end
|
||||
ti.set_is_required (True)
|
||||
f.extend (ti)
|
||||
|
||||
f.extend (create {CMS_FORM_RAW_TEXT}.make ("<br/>"))
|
||||
|
||||
create ta.make ("note")
|
||||
ta.set_label ("Additional note about you")
|
||||
ta.set_description ("You can use this input to tell us more about you")
|
||||
if attached u.profile as p and then attached p.item ("note") as l_note then
|
||||
ta.set_default_value (l_note)
|
||||
end
|
||||
ta.set_is_required (False)
|
||||
f.extend (ta)
|
||||
|
||||
f.extend (create {CMS_FORM_RAW_TEXT}.make ("<br/>"))
|
||||
|
||||
create ts.make ("op")
|
||||
ts.set_default_value ("Save")
|
||||
f.extend (ts)
|
||||
|
||||
Result := f
|
||||
end
|
||||
|
||||
end
|
||||
@@ -0,0 +1,114 @@
|
||||
note
|
||||
description: "[
|
||||
]"
|
||||
|
||||
class
|
||||
USER_LOGIN_CMS_EXECUTION
|
||||
|
||||
inherit
|
||||
CMS_EXECUTION
|
||||
|
||||
CMS_AUTH_ENGINE
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature -- Status
|
||||
|
||||
valid_credential (u,p: READABLE_STRING_32): BOOLEAN
|
||||
do
|
||||
if attached service.storage.user_by_name (u) as l_user then
|
||||
Result := attached l_user.encoded_password as l_pass and then l_pass.same_string (service.storage.encoded_password (p))
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Execution
|
||||
|
||||
process
|
||||
-- Computed response message.
|
||||
local
|
||||
auth_engine: CMS_AUTH_ENGINE
|
||||
l_url: detachable READABLE_STRING_8
|
||||
err: detachable STRING_8
|
||||
b: STRING_8
|
||||
u: detachable STRING_32
|
||||
do
|
||||
if request.is_request_method ("post") then
|
||||
if
|
||||
attached {WSF_STRING} request.form_parameter (form_login_name) as s_login and then not s_login.is_empty and
|
||||
attached {WSF_STRING} request.form_parameter (form_password_name) as s_passwd and then not s_passwd.is_empty
|
||||
then
|
||||
auth_engine := Current
|
||||
u := s_login.value
|
||||
if attached service.storage.user_by_name (u) as l_user and auth_engine.valid_credential (u, s_passwd.value) then
|
||||
login (l_user, request)
|
||||
else
|
||||
err := "Authentication failed for [" + html_encoded (u) + "]"
|
||||
end
|
||||
if attached {WSF_STRING} request.form_parameter ("form-destination") as s_dest then
|
||||
l_url := request.script_url (s_dest.value)
|
||||
end
|
||||
end
|
||||
else
|
||||
if
|
||||
attached {WSF_STRING} request.item ("destination") as s_dest
|
||||
then
|
||||
l_url := request.script_url (s_dest.value)
|
||||
end
|
||||
end
|
||||
|
||||
if l_url = Void then
|
||||
l_url := request.script_url ("/user")
|
||||
end
|
||||
|
||||
if authenticated then
|
||||
set_redirection (l_url)
|
||||
set_title ("Login")
|
||||
create b.make_empty
|
||||
b.append ("<h1>Login</h1>%N")
|
||||
set_main_content (b)
|
||||
else
|
||||
set_title ("Login")
|
||||
create b.make_empty
|
||||
b.append ("<h1>Login</h1>%N")
|
||||
|
||||
if err /= Void then
|
||||
b.append ("<div id=%"error-box%" style=%"background-color: #fcc; color:#f00;%">" + err + "</div>")
|
||||
end
|
||||
|
||||
b.append ("<form action=%"" + request.path_info + "%" method=%"POST%" id=%"form-login%" style=%"border: dotted 1px #099; display: inline-block; padding: 10px; margin: 10px;%">%N")
|
||||
-- b.append ("<div style=%"display:none%"><input type=%"hidden%" name=%"form-login-token%" value=%""+ cms.session.uuid +"%"></div>")
|
||||
b.append ("<div style=%"display:none%"><input type=%"hidden%" name=%"form-destination%" value=%""+ l_url +"%"></div>")
|
||||
b.append ("<div class=%"required username%">")
|
||||
b.append ("<strong><label for=%"id_username%">Username or email</label></strong> <em>(required)</em><br/>")
|
||||
b.append ("<input type=%"text%" id=%"id_username%" autofocus=%"autofocus%" name=%"" + form_login_name + "%" ")
|
||||
if u /= Void then
|
||||
b.append (" value=%""+ html_encoded (u) +"%" ")
|
||||
end
|
||||
b.append ("/>")
|
||||
b.append ("</div>")
|
||||
b.append ("<div class=%"required password%">")
|
||||
b.append ("<strong><label for=%"id_password%">Password</label></strong> <em>(required)</em><br/>")
|
||||
b.append ("<input type=%"password%" id=%"id_password%" name=%"" + form_password_name + "%" />")
|
||||
b.append ("</div>")
|
||||
|
||||
b.append ("<p class=%"description%"><a href=%"" + url ("/user/password", Void) + "%" tabindex=%"-1%">Reset password</a></p>%N")
|
||||
|
||||
b.append ("<div class=%"submit%">")
|
||||
b.append ("<input type=%"submit%" value=%"Log in%" name=%"submit%" >%N")
|
||||
b.append ("[
|
||||
<img alt="login" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAHiQAAB4kB+XNYvQAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAASmSURBVGiB1ZpbaBxVGMd/Mzu5bSRJY6LubmKJl4J9qShdwdpGGxGlharJSwpVVFrUUF+iT1VEUYRgaEGqsa2FGtu8xNtDsBQi5EFBS8UnsYWUtpsmaqppIdkkm+4eH77ZzWazl7lllv7gPOycmXP+/9kzM+d839GUUnjEOqAL2A7cCdSYJWjWx4F5s/wN/AgMAzNedK65NHI38CKwAwiZpcLitUvAlFlGgBPAFadCnBppAQ4DDwNhQHMqwEQBk8A5oAeYsNuAXSP1QD/wFNBqtzOLxIAzQC9ww/JVSimrZbdSalwplVJrT8rsa7dVfVZNHFRKTftgIJdps++SGksNrSDwLbAFqHUxXNwwB/wEPIe8+fJSzEi12cCDgO61OpukgN+RG7qQ74RiRkaApylg4sj4YZLqpgcalwloBvvu7SlUnQJOI6/6VRQy8jHwKkWG04aRMIlUwp7SElTqlVzYMVnslDlgAHgztyLf3e5GPnLleiaKUYto686tyDXSCHwANPkgyilNiMbG7INGzkn9QJvdltdVNnJg43uOVH34x7vMJP6ze1kbovWl9IFsI+uBJ3Ew3QgGaulqXfVvW+Lg+T5msG1EQ7SuBy7DyqH1GTKHulVoQTQDy0YiwKayyHHHJkR7xsgLyBTcFYupRbdN2CWEaM8Y2Yn7qTjHLw4w9s+o22bsoCHa0YEGZE3hmsXkInvP7vHbTBhoMJDlacTu1fs39JJMJQGoq6jLHE+kEuw9u4ejmwdpv6PDI61FiQBdBtCB9eVphv339xas89lMBdCh48FDno+0GZ+GWchAIh0F+f7q15y6fMJSaxPx2IrfPv4zNQbL4Zq8TM5P8Mu/PzvuwSczQZ0SRrzAh2EW9G3lp6Ghaa4/VQXRKbIO9ooqvYqj0UG2NW9fqy7iBiWMhGtaeOT2Ry21NhGPcXV+5QNfpVdxLPoVW5ufcKzSAnEDicUWZFekk12RTkutHTrfx6ELfZnfYuIkW5sfdyPSCvMGEnv1nOpANcc2n+Sx5va1aD6XKQMYBTqx+XXv//MjbqolAOoqGnjtvjcydT6bWAJGDSS0/w4SWbfM5+OfZKIokZrWjJHqQDVfRE+xpWmbt3ILMwUM68B1PBpeNUaQ49EhP02AaL+eXrN/A0RxuSZ5uW0fFXqlW2F2UIj2zMJqEMlPuMJnEyCaB2HZyBSSZLnVOIf5WGRPUXpwkfoqA1cQzcDKuNYEkil6BZvPSjw5x3BsyJGaeHLOyWUK0ZpJ0eUGseuB34B7SrVUpiB2movAQ2Sl5nJnvzeAt4Fpz9R5zzSicUV+Md80fghJFc/6IMous4i2VeM4N4id5i3gASTRE8h3woGN769JoqcISWDM1LaKUqm3MSSXnteMjySRV207BVJvxVaIC+aFpynvMJs1NRQ0AaWTnAtISHIAuOaZNOtcM/veSRETgK0NA91KqUvKvw0Dl8w+Pd0wkC71SqkjSqnYGpqImX3U29HmdFNNCPgUmTGH8GZTzRTwK/A6DpYVbrc53YXkJ55FouJh7G1zmjTLd8CXwF9Ohbg1ks1twPPAM8i/FCT/xrM4csd/QNYSnrwR/wfI5AekDWyX2QAAAABJRU5ErkJggg=="
|
||||
style="float:right; margin: 5px;"/>
|
||||
]")
|
||||
b.append ("</div>")
|
||||
b.append ("<p>Need an account? <a href=%"" + url ("/user/register", Void) + "%">Sign up now!</a></p>%N")
|
||||
b.append ("</form>%N")
|
||||
|
||||
set_main_content (b)
|
||||
end
|
||||
end
|
||||
|
||||
form_login_name: STRING = "login"
|
||||
form_password_name: STRING = "password"
|
||||
|
||||
end
|
||||
@@ -0,0 +1,39 @@
|
||||
note
|
||||
description: "[
|
||||
]"
|
||||
|
||||
class
|
||||
USER_LOGOUT_CMS_EXECUTION
|
||||
|
||||
inherit
|
||||
CMS_EXECUTION
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature -- Execution
|
||||
|
||||
process
|
||||
-- Computed response message.
|
||||
local
|
||||
-- l_url: READABLE_STRING_8
|
||||
b: STRING_8
|
||||
do
|
||||
logout (request)
|
||||
|
||||
if
|
||||
attached {WSF_STRING} request.item ("destination") as s_dest
|
||||
then
|
||||
set_redirection (request.script_url (s_dest.value))
|
||||
else
|
||||
set_redirection (request.script_url ("/"))
|
||||
end
|
||||
|
||||
set_title ("Logout")
|
||||
create b.make_empty
|
||||
set_main_content (b)
|
||||
-- l_url := request.script_url ("/info/")
|
||||
-- res.redirect_now_with_content (l_url, "Redirection to " + l_url, "text/html")
|
||||
end
|
||||
|
||||
end
|
||||
157
draft/application/cms/src/modules/user/user_module.e
Normal file
157
draft/application/cms/src/modules/user/user_module.e
Normal file
@@ -0,0 +1,157 @@
|
||||
note
|
||||
description: "Summary description for {USER_MODULE}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
USER_MODULE
|
||||
|
||||
inherit
|
||||
CMS_MODULE
|
||||
|
||||
CMS_HOOK_MENU_ALTER
|
||||
|
||||
CMS_HOOK_BLOCK
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make (a_service: like service)
|
||||
do
|
||||
service := a_service
|
||||
name := "user"
|
||||
version := "1.0"
|
||||
description := "Users management"
|
||||
package := "core"
|
||||
|
||||
enable
|
||||
end
|
||||
|
||||
feature {CMS_SERVICE} -- Registration
|
||||
|
||||
service: CMS_SERVICE
|
||||
|
||||
register (a_service: CMS_SERVICE)
|
||||
local
|
||||
h: CMS_HANDLER
|
||||
do
|
||||
-- a_service.map_uri ("/user", agent handle_login)
|
||||
a_service.map_uri ("/user/logout", agent handle_logout)
|
||||
a_service.map_uri ("/user/register", agent handle_register)
|
||||
a_service.map_uri ("/user/password", agent handle_request_new_password)
|
||||
|
||||
create {CMS_HANDLER} h.make (agent handle_user)
|
||||
a_service.router.map (create {WSF_URI_TEMPLATE_MAPPING}.make ("/user/{uid}", h))
|
||||
a_service.router.map (create {WSF_URI_MAPPING}.make_trailing_slash_ignored ("/user", h))
|
||||
a_service.map_uri_template ("/user/{uid}/edit", agent handle_edit)
|
||||
a_service.map_uri_template ("/user/reset/{uid}/{last-signed}/{extra}", agent handle_reset_password)
|
||||
|
||||
a_service.add_menu_alter_hook (Current)
|
||||
a_service.add_block_hook (Current)
|
||||
end
|
||||
|
||||
feature -- Hooks
|
||||
|
||||
block_list: ITERABLE [like {CMS_BLOCK}.name]
|
||||
do
|
||||
Result := <<"user-info">>
|
||||
end
|
||||
|
||||
get_block_view (a_block_id: detachable READABLE_STRING_8; a_execution: CMS_EXECUTION)
|
||||
local
|
||||
b: CMS_CONTENT_BLOCK
|
||||
do
|
||||
if
|
||||
a_execution.is_front and then
|
||||
attached a_execution.user as u
|
||||
then
|
||||
create b.make ("user-info", "User", "Welcome " + a_execution.html_encoded (u.name), a_execution.formats.plain_text)
|
||||
a_execution.add_block (b, Void)
|
||||
end
|
||||
end
|
||||
|
||||
menu_alter (a_menu_system: CMS_MENU_SYSTEM; a_execution: CMS_EXECUTION)
|
||||
local
|
||||
lnk: CMS_LOCAL_LINK
|
||||
opts: CMS_API_OPTIONS
|
||||
do
|
||||
if attached a_execution.user as u then
|
||||
create lnk.make ("Logout", "/user/logout")
|
||||
a_execution.add_to_main_menu (lnk)
|
||||
else
|
||||
create lnk.make ("Login", "/user")
|
||||
create opts.make_from_manifest (<<["query", <<["destination", a_execution.request.path_info]>> ]>>)
|
||||
lnk.set_options (opts)
|
||||
a_execution.add_to_main_menu (lnk)
|
||||
|
||||
create lnk.make ("Sign up", "/user/register")
|
||||
lnk.set_options (opts)
|
||||
a_execution.add_to_main_menu (lnk)
|
||||
end
|
||||
if a_execution.authenticated then
|
||||
create lnk.make ("My Account", "/user")
|
||||
a_menu_system.user_menu.extend (lnk)
|
||||
create lnk.make ("Logout", "/user/logout")
|
||||
a_menu_system.user_menu.extend (lnk)
|
||||
else
|
||||
create lnk.make ("Login", "/user")
|
||||
a_menu_system.user_menu.extend (lnk)
|
||||
end
|
||||
end
|
||||
|
||||
links: HASH_TABLE [CMS_MODULE_LINK, STRING]
|
||||
-- Link indexed by path
|
||||
local
|
||||
-- lnk: CMS_MODULE_LINK
|
||||
do
|
||||
create Result.make (3)
|
||||
-- create lnk.make ("Date/time demo")
|
||||
-- lnk.set_callback (agent process_date_time_demo, <<"arg">>)
|
||||
-- Result["/demo/date/{arg}"] := lnk
|
||||
end
|
||||
|
||||
-- handle_login (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
-- do
|
||||
-- (create {USER_LOGIN_CMS_EXECUTION}.make (req, res, service)).execute
|
||||
-- end
|
||||
|
||||
handle_logout (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
do
|
||||
(create {USER_LOGOUT_CMS_EXECUTION}.make (req, res, service)).execute
|
||||
end
|
||||
|
||||
handle_user (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
do
|
||||
(create {USER_CMS_EXECUTION}.make (req, res, service)).execute
|
||||
end
|
||||
|
||||
handle_edit (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
do
|
||||
(create {USER_EDIT_CMS_EXECUTION}.make (req, res, service)).execute
|
||||
end
|
||||
|
||||
-- handle_account (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
-- do
|
||||
-- (create {USER_ACCOUNT_CMS_EXECUTION}.make (req, res, service)).execute
|
||||
-- end
|
||||
|
||||
handle_register (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
do
|
||||
(create {USER_REGISTER_CMS_EXECUTION}.make (req, res, service)).execute
|
||||
end
|
||||
|
||||
handle_request_new_password (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
do
|
||||
(create {USER_NEW_PASSWORD_CMS_EXECUTION}.make (req, res, service)).execute
|
||||
end
|
||||
|
||||
handle_reset_password (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
do
|
||||
(create {USER_RESET_PASSWORD_CMS_EXECUTION}.make (req, res, service)).execute
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
29
draft/application/cms/src/modules/user/user_module_lib.e
Normal file
29
draft/application/cms/src/modules/user/user_module_lib.e
Normal file
@@ -0,0 +1,29 @@
|
||||
note
|
||||
description: "Summary description for {USER_MODULE_LIB}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
deferred class
|
||||
USER_MODULE_LIB
|
||||
|
||||
inherit
|
||||
CMS_COMMON_API
|
||||
|
||||
CMS_EXECUTION
|
||||
|
||||
feature -- Initialization
|
||||
|
||||
initialize_primary_tabs (u: detachable CMS_USER)
|
||||
do
|
||||
if u /= Void then
|
||||
primary_tabs.extend (create {CMS_LOCAL_LINK}.make ("View", "/user/" + u.id.out))
|
||||
primary_tabs.extend (create {CMS_LOCAL_LINK}.make ("Edit", "/user/" + u.id.out + "/edit"))
|
||||
else
|
||||
primary_tabs.extend (create {CMS_LOCAL_LINK}.make ("Create new account", "/user/register"))
|
||||
primary_tabs.extend (create {CMS_LOCAL_LINK}.make ("Log in", "/user"))
|
||||
primary_tabs.extend (create {CMS_LOCAL_LINK}.make ("Request new password", "/user/password"))
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
@@ -0,0 +1,154 @@
|
||||
note
|
||||
description: "[
|
||||
]"
|
||||
|
||||
class
|
||||
USER_NEW_PASSWORD_CMS_EXECUTION
|
||||
|
||||
inherit
|
||||
CMS_EXECUTION
|
||||
|
||||
USER_MODULE_LIB
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature -- Execution
|
||||
|
||||
process
|
||||
-- Computed response message.
|
||||
local
|
||||
b: STRING_8
|
||||
f: CMS_FORM
|
||||
u: detachable CMS_USER
|
||||
fd: detachable CMS_FORM_DATA
|
||||
e: detachable CMS_EMAIL
|
||||
l_uuid: UUID
|
||||
do
|
||||
set_title ("Request new password")
|
||||
create b.make_empty
|
||||
if not request.is_post_request_method and authenticated then
|
||||
u := user
|
||||
initialize_primary_tabs (u)
|
||||
if u /= Void then
|
||||
if attached u.email as l_email then
|
||||
f := new_password_form (request.path_info, "new-password")
|
||||
b.append ("Password reset instructions will be mailed to <em>" + l_email + "</em>. You must " + link ("log out", "/user/logout", Void) + " to use the password reset link in the e-mail.")
|
||||
b.append (f.to_html (theme))
|
||||
else
|
||||
b.append ("Your account does not have any email address set!")
|
||||
set_redirection (url ("/user/"+ u.id.out +"/edit", Void))
|
||||
end
|
||||
else
|
||||
b.append ("Unexpected issue")
|
||||
end
|
||||
else
|
||||
f := new_password_form (request.path_info, "new-password")
|
||||
if request.is_post_request_method then
|
||||
create fd.make (request, f)
|
||||
if attached {WSF_STRING} fd.item ("name") as s_name then
|
||||
u := service.storage.user_by_name (s_name.value)
|
||||
if u = Void then
|
||||
u := service.storage.user_by_email (s_name.value)
|
||||
if u = Void then
|
||||
fd.report_invalid_field ("name", "Sorry, " + html_encoded (s_name.value)+ " is not recognized as a user name or an e-mail address.")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
initialize_primary_tabs (u)
|
||||
if fd /= Void and then fd.is_valid then
|
||||
across
|
||||
fd as c
|
||||
loop
|
||||
b.append ("<li>" + html_encoded (c.key) + "=")
|
||||
if attached c.item as v then
|
||||
b.append (html_encoded (v.string_representation))
|
||||
end
|
||||
b.append ("</li>")
|
||||
end
|
||||
if u /= Void and then attached u.email as l_mail_address then
|
||||
l_uuid := (create {UUID_GENERATOR}).generate_uuid
|
||||
e := new_password_email (u, l_mail_address, l_uuid.out)
|
||||
u.set_data_item ("new_password_extra", l_uuid.out)
|
||||
service.storage.save_user (u)
|
||||
service.mailer.safe_process_email (e)
|
||||
add_success_message ("Further instructions have been sent to your e-mail address.")
|
||||
set_redirection (url ("/user", Void))
|
||||
end
|
||||
set_main_content (b)
|
||||
else
|
||||
if fd /= Void then
|
||||
if not fd.is_valid then
|
||||
report_form_errors (fd)
|
||||
end
|
||||
fd.apply_to_associated_form
|
||||
end
|
||||
b.append (f.to_html (theme))
|
||||
end
|
||||
end
|
||||
set_main_content (b)
|
||||
end
|
||||
|
||||
new_password_form (a_url: READABLE_STRING_8; a_name: STRING): CMS_FORM
|
||||
require
|
||||
attached user as l_auth_user implies l_auth_user.has_email
|
||||
local
|
||||
u: like user
|
||||
f: CMS_FORM
|
||||
ti: CMS_FORM_TEXT_INPUT
|
||||
th: CMS_FORM_HIDDEN_INPUT
|
||||
ts: CMS_FORM_SUBMIT_INPUT
|
||||
err: BOOLEAN
|
||||
do
|
||||
create f.make (a_url, a_name)
|
||||
u := user
|
||||
if u = Void then
|
||||
create ti.make ("name")
|
||||
ti.set_label ("Username or e-mail address")
|
||||
ti.set_is_required (True)
|
||||
f.extend (ti)
|
||||
elseif attached u.email as l_mail then
|
||||
create th.make ("name")
|
||||
th.set_default_value (l_mail)
|
||||
th.set_is_required (True)
|
||||
f.extend (th)
|
||||
else
|
||||
f.extend (create {CMS_FORM_RAW_TEXT}.make ("The associated account has no e-mail address."))
|
||||
err := True
|
||||
end
|
||||
|
||||
if not err then
|
||||
create ts.make ("op")
|
||||
ts.set_default_value ("E-mail new password")
|
||||
f.extend (ts)
|
||||
end
|
||||
|
||||
Result := f
|
||||
end
|
||||
|
||||
new_password_email (u: CMS_USER; a_mail_address: STRING; a_extra: READABLE_STRING_8): CMS_EMAIL
|
||||
local
|
||||
b: STRING
|
||||
opts: CMS_URL_API_OPTIONS
|
||||
dt: detachable DATE_TIME
|
||||
do
|
||||
create b.make_empty
|
||||
create opts.make_absolute
|
||||
|
||||
b.append ("A request to reset the password for your account has been made at " + service.site_name + ".%N")
|
||||
b.append ("You may now log in by clicking this link or copying and pasting it to your browser:%N%N")
|
||||
dt := u.last_login_date
|
||||
if dt = Void then
|
||||
dt := u.creation_date
|
||||
end
|
||||
b.append (url ("/user/reset/" + u.id.out + "/" + unix_timestamp (dt).out + "/" + a_extra, opts))
|
||||
b.append ("%N")
|
||||
b.append ("%N")
|
||||
b.append ("This link can only be used once to log in and will lead you to a page where you can set your password. It expires after one day and nothing will happen if it's not used.%N")
|
||||
b.append ("%N%N-- The %"" + service.site_name + "%" team")
|
||||
|
||||
create Result.make (service.site_email, a_mail_address, "Account details for " + u.name + " at " + service.site_name, b)
|
||||
end
|
||||
|
||||
end
|
||||
@@ -0,0 +1,205 @@
|
||||
note
|
||||
description: "[
|
||||
]"
|
||||
|
||||
class
|
||||
USER_REGISTER_CMS_EXECUTION
|
||||
|
||||
inherit
|
||||
CMS_EXECUTION
|
||||
|
||||
USER_MODULE_LIB
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature -- Execution
|
||||
|
||||
process
|
||||
-- Computed response message.
|
||||
local
|
||||
b: STRING_8
|
||||
f: CMS_FORM
|
||||
fd: detachable CMS_FORM_DATA
|
||||
u: detachable CMS_USER
|
||||
up: detachable CMS_USER_PROFILE
|
||||
e: detachable CMS_EMAIL
|
||||
l_pass: detachable READABLE_STRING_32
|
||||
l_uuid: UUID
|
||||
do
|
||||
set_title ("Create new account")
|
||||
create b.make_empty
|
||||
if authenticated then
|
||||
initialize_primary_tabs (user)
|
||||
b.append ("You are already " + link ("signed in", "/user", Void) + ", please " + link ("signout", "/user/logout", Void) + " before trying to " + link ("register a new account", "/account/register", Void) + ".")
|
||||
set_redirection (url ("/user", Void))
|
||||
else
|
||||
f := registration_form (request.path_info, "reg")
|
||||
|
||||
if request.is_post_request_method then
|
||||
create fd.make (request, f)
|
||||
if attached {WSF_STRING} fd.item ("username") as s_username then
|
||||
u := service.storage.user_by_name (s_username.value)
|
||||
if u /= Void then
|
||||
fd.report_invalid_field ("username", "User already exists!")
|
||||
end
|
||||
end
|
||||
if attached {WSF_STRING} fd.item ("email") as s_email then
|
||||
u := service.storage.user_by_email (s_email.value)
|
||||
if u /= Void then
|
||||
fd.report_invalid_field ("email", "Email is already used!")
|
||||
end
|
||||
end
|
||||
u := Void
|
||||
end
|
||||
if fd /= Void and then fd.is_valid then
|
||||
across
|
||||
fd as c
|
||||
loop
|
||||
b.append ("<li>" + html_encoded (c.key) + "=")
|
||||
if attached c.item as v then
|
||||
b.append (html_encoded (v.string_representation))
|
||||
end
|
||||
b.append ("</li>")
|
||||
end
|
||||
if attached {WSF_STRING} fd.item ("username") as s_username then
|
||||
u := service.storage.user_by_name (s_username.value)
|
||||
|
||||
create u.make_new (s_username.value)
|
||||
if attached {WSF_STRING} fd.item ("password") as s_password then
|
||||
u.set_password (s_password.value)
|
||||
l_pass := u.password
|
||||
end
|
||||
if attached {WSF_STRING} fd.item ("email") as s_email then
|
||||
u.set_email (s_email.value)
|
||||
end
|
||||
|
||||
if attached {WSF_STRING} fd.item ("note") as s_note then
|
||||
create up.make
|
||||
up.force (s_note.value, "note")
|
||||
u.set_profile (up)
|
||||
end
|
||||
|
||||
l_uuid := (create {UUID_GENERATOR}).generate_uuid
|
||||
u.set_data_item ("new_password_extra", l_uuid.out)
|
||||
|
||||
service.storage.save_user (u)
|
||||
if attached u.email as l_mail_address then
|
||||
e := new_registration_email (l_mail_address, u, l_pass, l_uuid.out)
|
||||
service.mailer.safe_process_email (e)
|
||||
end
|
||||
e := new_user_account_email (service.site_email, u)
|
||||
service.mailer.safe_process_email (e)
|
||||
|
||||
login (u, request)
|
||||
set_redirection (url ("/user", Void))
|
||||
end
|
||||
set_main_content (b)
|
||||
else
|
||||
initialize_primary_tabs (user)
|
||||
if fd /= Void then
|
||||
if not fd.is_valid then
|
||||
report_form_errors (fd)
|
||||
end
|
||||
fd.apply_to_associated_form
|
||||
end
|
||||
b.append (f.to_html (theme))
|
||||
end
|
||||
end
|
||||
set_main_content (b)
|
||||
end
|
||||
|
||||
registration_form (a_url: READABLE_STRING_8; a_name: STRING): CMS_FORM
|
||||
local
|
||||
f: CMS_FORM
|
||||
ti: CMS_FORM_TEXT_INPUT
|
||||
tp: CMS_FORM_PASSWORD_INPUT
|
||||
ta: CMS_FORM_TEXTAREA
|
||||
ts: CMS_FORM_SUBMIT_INPUT
|
||||
do
|
||||
create f.make (a_url, a_name)
|
||||
|
||||
create ti.make ("username")
|
||||
ti.set_label ("Username")
|
||||
ti.set_is_required (True)
|
||||
ti.set_validation_action (agent (fd: CMS_FORM_DATA)
|
||||
do
|
||||
if attached {WSF_STRING} fd.item ("username") as f_username and then f_username.value.count >= 5 then
|
||||
else
|
||||
fd.report_invalid_field ("username", "Username should contain at least 5 characters!")
|
||||
end
|
||||
end)
|
||||
f.extend (ti)
|
||||
|
||||
f.extend (create {CMS_FORM_RAW_TEXT}.make ("<br/>"))
|
||||
|
||||
create tp.make ("password")
|
||||
tp.set_label ("Password")
|
||||
tp.set_is_required (True)
|
||||
f.extend (tp)
|
||||
|
||||
f.extend (create {CMS_FORM_RAW_TEXT}.make ("<br/>"))
|
||||
|
||||
create ti.make ("email")
|
||||
ti.set_label ("Valid email address")
|
||||
ti.set_is_required (True)
|
||||
f.extend (ti)
|
||||
|
||||
f.extend (create {CMS_FORM_RAW_TEXT}.make ("<br/>"))
|
||||
|
||||
create ta.make ("note")
|
||||
ta.set_label ("Additional note about you")
|
||||
ta.set_description ("You can use this input to tell us more about you")
|
||||
ta.set_is_required (False)
|
||||
f.extend (ta)
|
||||
|
||||
f.extend (create {CMS_FORM_RAW_TEXT}.make ("<br/>"))
|
||||
|
||||
create ts.make ("Register")
|
||||
ts.set_default_value ("Register")
|
||||
f.extend (ts)
|
||||
|
||||
Result := f
|
||||
end
|
||||
|
||||
new_registration_email (a_mail_address: STRING; u: CMS_USER; a_password: detachable like {CMS_USER}.password; a_extra: READABLE_STRING_8): CMS_EMAIL
|
||||
require
|
||||
has_clear_password: u.password /= Void or else a_password /= Void
|
||||
local
|
||||
p: detachable like {CMS_USER}.password
|
||||
b: STRING
|
||||
opts: CMS_URL_API_OPTIONS
|
||||
do
|
||||
p := a_password
|
||||
if p = Void then
|
||||
p := u.password
|
||||
end
|
||||
|
||||
create b.make_from_string (u.name + "%N" + "Thank you for registering at " + service.site_name + ". ")
|
||||
create opts.make_absolute
|
||||
-- if p /= Void then
|
||||
b.append ("You may now log in to " + url ("/user", opts) + " using your username %""+ u.name +"%" and password%N")
|
||||
-- b.append ("%Nusername: " + u.name + "%Npassword: " + p + "%N%N")
|
||||
-- end
|
||||
b.append ("You may also log in by clicking on this link or copying and pasting it in your browser:%N%N")
|
||||
b.append (url ("/user/reset/" + u.id.out + "/" + unix_timestamp (u.creation_date).out + "/" + a_extra, opts))
|
||||
-- b.append (url ("/user/reset/" + u.id.out + "/" + unix_timestamp (u.creation_date).out + "/", opts))
|
||||
b.append ("%N%NThis is a one-time login, so it can be used only once.%N%NAfter logging in, you will be redirected to " + url ("/user/" + u.id.out + "/edit", opts) + " so you can change your password.%N")
|
||||
b.append ("%N%N-- The %"" + service.site_name + "%" team")
|
||||
|
||||
create Result.make (service.site_email, a_mail_address, "Account details for " + u.name + " at " + service.site_name, b)
|
||||
end
|
||||
|
||||
new_user_account_email (a_mail_address: STRING; u: CMS_USER): CMS_EMAIL
|
||||
local
|
||||
b: STRING
|
||||
opts: CMS_URL_API_OPTIONS
|
||||
do
|
||||
create b.make_from_string ("New user account %"" + u.name + "%" at " + service.site_name + ". ")
|
||||
create opts.make_absolute
|
||||
b.append ("See user account: " + user_url (u) + "%N")
|
||||
b.append ("%N%N-- The %"" + service.site_name + "%" team")
|
||||
create Result.make (service.site_email, a_mail_address, "New User Account %"" + u.name + "%" at " + service.site_name, b)
|
||||
end
|
||||
|
||||
end
|
||||
@@ -0,0 +1,86 @@
|
||||
note
|
||||
description: "[
|
||||
]"
|
||||
|
||||
class
|
||||
USER_RESET_PASSWORD_CMS_EXECUTION
|
||||
|
||||
inherit
|
||||
CMS_EXECUTION
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature -- Execution
|
||||
|
||||
process
|
||||
-- Computed response message.
|
||||
local
|
||||
b: STRING_8
|
||||
u: detachable CMS_USER
|
||||
err: BOOLEAN
|
||||
t: INTEGER_64
|
||||
l_extra: detachable READABLE_STRING_8
|
||||
do
|
||||
create b.make_empty
|
||||
u := user
|
||||
if u /= Void then
|
||||
add_success_message ("You are logged in as " + u.name + ". " + link ("Change your password", "/user/" + u.id.out + "/edit", Void))
|
||||
set_redirection (front_page_url)
|
||||
else
|
||||
if attached {WSF_STRING} request.path_parameter ("uid") as p_uid and then p_uid.is_integer then
|
||||
u := service.storage.user_by_id (p_uid.integer_value)
|
||||
end
|
||||
if u /= Void then
|
||||
if attached non_empty_string_path_parameter ("last-signed") as p_last_signed then
|
||||
if p_last_signed.is_integer_64 then
|
||||
t := p_last_signed.to_integer_64
|
||||
else
|
||||
err := True
|
||||
end
|
||||
if t > 0 then
|
||||
if attached u.last_login_date as l_last then
|
||||
if t /= unix_timestamp (l_last) then
|
||||
err := True
|
||||
end
|
||||
else
|
||||
if t /= unix_timestamp (u.creation_date) then
|
||||
err := True
|
||||
end
|
||||
end
|
||||
end
|
||||
else
|
||||
err := True
|
||||
end
|
||||
if attached non_empty_string_path_parameter ("extra") as s_extra then
|
||||
l_extra := s_extra
|
||||
if l_extra /= Void then
|
||||
if attached {READABLE_STRING_8} u.data_item ("new_password_extra") as u_extra and then u_extra.same_string (l_extra) then
|
||||
else
|
||||
err := True
|
||||
end
|
||||
else
|
||||
err := True
|
||||
end
|
||||
else
|
||||
err := True
|
||||
end
|
||||
if not err then
|
||||
login (u, request)
|
||||
u.remove_data_item ("new_password_extra")
|
||||
service.storage.save_user (u)
|
||||
set_redirection (url ("/user/" + u.id.out + "/edit", Void))
|
||||
set_main_content (b)
|
||||
end
|
||||
else
|
||||
err := True
|
||||
end
|
||||
if err then
|
||||
add_warning_message ("The one-time login link you clicked is invalid.")
|
||||
set_redirection (front_page_url)
|
||||
end
|
||||
end
|
||||
set_main_content (b)
|
||||
end
|
||||
|
||||
end
|
||||
Reference in New Issue
Block a user