Worlflow 1- Register 1.1 Create a new temporal user 1.2 Email to the new User 1.3 Email to Web Master 2 Web Master Review th Account Application 2.1 Accept and Send an confirmation email to the user and remove the temporal user 2.2 Reject the application send a rejection email to the user and remove the temporal Added a new table to save temporal users to review their Application to the site. Updated Register Form with an new input Application and Recaptcha validation. Updated Emails templates and messages. (TODO improve messages) Updated mails templates. Simple messages (Todo improve messages). Added a new handler to reject a user Updated existing hanlders to handler the new workflow.
353 lines
9.3 KiB
Plaintext
353 lines
9.3 KiB
Plaintext
note
|
|
description: "Summary description for {CMS_AUTHENTICATION_EMAIL_SERVICE_PARAMETERS}."
|
|
date: "$Date$"
|
|
revision: "$Revision$"
|
|
|
|
class
|
|
CMS_AUTHENTICATION_EMAIL_SERVICE_PARAMETERS
|
|
|
|
inherit
|
|
EMAIL_SERVICE_PARAMETERS
|
|
|
|
create
|
|
make
|
|
|
|
feature {NONE} -- Initialization
|
|
|
|
make (a_cms_api: CMS_API)
|
|
local
|
|
utf: UTF_CONVERTER
|
|
l_site_name: READABLE_STRING_8
|
|
s: detachable READABLE_STRING_32
|
|
l_contact_email, l_subject_register, l_subject_activate, l_subject_password, l_subject_oauth: detachable READABLE_STRING_8
|
|
do
|
|
cms_api := a_cms_api
|
|
-- Use global smtp setting if any, otherwise "localhost"
|
|
smtp_server := utf.escaped_utf_32_string_to_utf_8_string_8 (a_cms_api.setup.text_item_or_default ("smtp", "localhost"))
|
|
l_site_name := utf.escaped_utf_32_string_to_utf_8_string_8 (a_cms_api.setup.site_name)
|
|
admin_email := a_cms_api.setup.site_email
|
|
|
|
if not admin_email.has ('<') then
|
|
admin_email := l_site_name + " <" + admin_email +">"
|
|
end
|
|
|
|
if attached {CONFIG_READER} a_cms_api.module_configuration_by_name ({CMS_AUTHENTICATION_MODULE}.name, Void) as cfg then
|
|
if attached cfg.text_item ("smtp") as l_smtp then
|
|
-- Overwrite global smtp setting if any.
|
|
smtp_server := utf.utf_32_string_to_utf_8_string_8 (l_smtp)
|
|
end
|
|
s := cfg.text_item ("email")
|
|
if s /= Void then
|
|
l_contact_email := utf.utf_32_string_to_utf_8_string_8 (s)
|
|
end
|
|
s := cfg.text_item ("subject_register")
|
|
if s /= Void then
|
|
l_subject_register := utf.utf_32_string_to_utf_8_string_8 (s)
|
|
end
|
|
s := cfg.text_item ("subject_activate")
|
|
if s /= Void then
|
|
l_subject_register := utf.utf_32_string_to_utf_8_string_8 (s)
|
|
end
|
|
s := cfg.text_item ("subject_password")
|
|
if s /= Void then
|
|
l_subject_register := utf.utf_32_string_to_utf_8_string_8 (s)
|
|
end
|
|
s := cfg.text_item ("subject_oauth")
|
|
if s /= Void then
|
|
l_subject_oauth := utf.utf_32_string_to_utf_8_string_8 (s)
|
|
end
|
|
|
|
end
|
|
if l_contact_email /= Void then
|
|
if not l_contact_email.has ('<') then
|
|
l_contact_email := l_site_name + " <" + l_contact_email + ">"
|
|
end
|
|
contact_email := l_contact_email
|
|
else
|
|
contact_email := admin_email
|
|
end
|
|
if l_subject_register /= Void then
|
|
contact_subject_register := l_subject_register
|
|
else
|
|
contact_subject_register := "Thank you for registering with us."
|
|
end
|
|
|
|
if l_subject_activate /= Void then
|
|
contact_subject_activate := l_subject_activate
|
|
else
|
|
contact_subject_activate := "New account activation token."
|
|
end
|
|
if l_subject_password /= Void then
|
|
contact_subject_password := l_subject_password
|
|
else
|
|
contact_subject_password := "Password Recovery."
|
|
end
|
|
if l_subject_oauth /= Void then
|
|
contact_subject_oauth := l_subject_oauth
|
|
else
|
|
contact_subject_oauth := "Welcome."
|
|
end
|
|
|
|
contact_subject_account_evaluation := "New register, account evalution"
|
|
|
|
contact_subject_rejected := "Your account was rejected"
|
|
|
|
contact_subject_activated := "Your account was activated"
|
|
end
|
|
|
|
feature -- Access
|
|
|
|
cms_api: CMS_API
|
|
|
|
smtp_server: IMMUTABLE_STRING_8
|
|
|
|
admin_email: IMMUTABLE_STRING_8
|
|
|
|
contact_email: IMMUTABLE_STRING_8
|
|
-- Contact email.
|
|
|
|
contact_subject_account_evaluation: IMMUTABLE_STRING_8
|
|
contact_subject_register: IMMUTABLE_STRING_8
|
|
contact_subject_activate: IMMUTABLE_STRING_8
|
|
contact_subject_password: IMMUTABLE_STRING_8
|
|
contact_subject_oauth: IMMUTABLE_STRING_8
|
|
contact_subject_rejected: IMMUTABLE_STRING_8
|
|
contact_subject_activated: IMMUTABLE_STRING_8
|
|
|
|
|
|
account_evaluation: STRING
|
|
-- Account evaluation template email message.
|
|
do
|
|
Result := template_string ("account_evaluation.html", default_template_account_evaluation)
|
|
end
|
|
|
|
account_activation: STRING
|
|
-- Account activation template email message.
|
|
do
|
|
Result := template_string ("account_activation.html", default_template_account_activation)
|
|
end
|
|
|
|
account_activation_confirmation: STRING
|
|
-- Account activation confirmation template email message.
|
|
do
|
|
Result := template_string ("account_activation_confirmation.html", default_template_account_activation_confirmation)
|
|
end
|
|
|
|
account_re_activation: STRING
|
|
-- Account re_activation template email message.
|
|
do
|
|
Result := template_string ("accunt_re_activation.html", default_template_account_re_activation)
|
|
end
|
|
|
|
account_rejected: STRING
|
|
-- Account rejected template email message.
|
|
do
|
|
Result := template_string ("accunt_rejected.html", default_template_account_rejected)
|
|
end
|
|
|
|
account_password: STRING
|
|
-- Account password template email message.
|
|
do
|
|
Result := template_string ("account_new_password.html", default_template_account_new_password)
|
|
end
|
|
|
|
account_welcome: STRING
|
|
-- Account welcome template email message.
|
|
do
|
|
Result := template_string ("account_welcome.html", default_template_account_welcome)
|
|
end
|
|
|
|
feature {NONE} -- Implementation: Template
|
|
|
|
template_path (a_name: READABLE_STRING_GENERAL): PATH
|
|
-- Location of template named `a_name'.
|
|
local
|
|
p: PATH
|
|
do
|
|
create p.make_from_string (a_name)
|
|
Result := cms_api.module_location_by_name ({CMS_AUTHENTICATION_MODULE}.name).extended ("mail_templates").extended (a_name)
|
|
end
|
|
|
|
template_string (a_name: READABLE_STRING_GENERAL; a_default: STRING): STRING
|
|
-- Content of template named `a_name', or `a_default' if template is not found.
|
|
local
|
|
p: PATH
|
|
do
|
|
p := template_path (a_name)
|
|
if attached read_template_file (p) as l_content then
|
|
Result := l_content
|
|
else
|
|
create Result.make_from_string (a_default)
|
|
end
|
|
end
|
|
|
|
feature {NONE} -- Implementation
|
|
|
|
read_template_file (a_path: PATH): detachable STRING
|
|
-- Read the content of the file at path `a_path'.
|
|
local
|
|
l_file: FILE
|
|
n: INTEGER
|
|
do
|
|
create {PLAIN_TEXT_FILE} l_file.make_with_path (a_path)
|
|
if l_file.exists and then l_file.is_readable then
|
|
n := l_file.count
|
|
l_file.open_read
|
|
l_file.read_stream (n)
|
|
Result := l_file.last_string
|
|
l_file.close
|
|
else
|
|
-- Error
|
|
end
|
|
end
|
|
|
|
|
|
feature {NONE} -- Message email
|
|
|
|
default_template_account_evaluation: STRING = "[
|
|
<!doctype html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<title>Account Evaluation</title>
|
|
<meta name="description" content="Account Evaluation">
|
|
<meta name="author" content="ROC CMS">
|
|
</head>
|
|
|
|
<body>
|
|
<h2> Account Evaluation </h2>
|
|
<p>The user $user ($email) wants to register to the site</p>
|
|
|
|
<blockquote><p>This is his/her application.</p>
|
|
<p>$application</p>
|
|
</blockquote>
|
|
|
|
<p>To complete the registration, please click on the following link to activate the user account:<p>
|
|
|
|
<p><a href="$activate">$activate</a></p>
|
|
|
|
<p>To reject the registration, please click on the following link <p>
|
|
|
|
<p><a href="$reject">$reject</a></p>
|
|
</body>
|
|
</html>
|
|
]"
|
|
|
|
|
|
default_template_account_activation: STRING = "[
|
|
<!doctype html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<title>Activation</title>
|
|
<meta name="description" content="Activation">
|
|
<meta name="author" content="ROC CMS">
|
|
</head>
|
|
|
|
<body>
|
|
<p>Thank you for applying to <a href="...">ROC CMS</a> $user</p>
|
|
|
|
<p>We will review your application and send you an email<p>
|
|
<p>Thank you for joining us.</p>
|
|
</body>
|
|
</html>
|
|
]"
|
|
|
|
|
|
default_template_account_activation_confirmation: STRING = "[
|
|
<!doctype html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<title>Activation</title>
|
|
<meta name="description" content="Activation Confirmation">
|
|
<meta name="author" content="ROC CMS">
|
|
</head>
|
|
|
|
<body>
|
|
<p>Your account has been confirmed <a href="...">ROC CMS</a> $email</p>
|
|
|
|
<p>Thank you for joining us.</p>
|
|
</body>
|
|
</html>
|
|
]"
|
|
|
|
default_template_account_rejected: STRING = "[
|
|
<!doctype html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<title>New Activation</title>
|
|
<meta name="description" content="Application Rejected">
|
|
<meta name="author" content="ROC CMS">
|
|
</head>
|
|
|
|
<body>
|
|
<p>You requested has been rejected, your application does not conform our rules <a href="...">ROC CMS</a></p>
|
|
</body>
|
|
</html>
|
|
]"
|
|
|
|
default_template_account_re_activation: STRING = "[
|
|
<!doctype html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<title>New Activation</title>
|
|
<meta name="description" content="New Activation token">
|
|
<meta name="author" content="ROC CMS">
|
|
</head>
|
|
|
|
<body>
|
|
<p>You have requested a new activation token at <a href="...">ROC CMS</a></p>
|
|
|
|
<p>To complete your registration, please click on the following link to activate your account:<p>
|
|
|
|
<p><a href="$link">$link</a></p>
|
|
<p>Thank you for joining us.</p>
|
|
</body>
|
|
</html>
|
|
]"
|
|
|
|
|
|
|
|
default_template_account_new_password: STRING = "[
|
|
<!doctype html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<title>New Password</title>
|
|
<meta name="description" content="New Password">
|
|
<meta name="author" content="ROC CMS">
|
|
</head>
|
|
|
|
<body>
|
|
<p>You have required a new password at <a href="...">ROC CMS</a></p>
|
|
|
|
<p>To complete your request, please click on this link to generate a new password:<p>
|
|
|
|
<p><a href="$link">$link</a></p>
|
|
</body>
|
|
</html>
|
|
]"
|
|
|
|
|
|
default_template_account_welcome: STRING = "[
|
|
<!doctype html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<title>Welcome</title>
|
|
<meta name="description" content="Welcome">
|
|
<meta name="author" content="ROC CMS">
|
|
</head>
|
|
|
|
<body>
|
|
<p>Welcome to<a href="...">ROC CMS</a></p>
|
|
<p>Thank you for joining us.</p>
|
|
</body>
|
|
</html>
|
|
]"
|
|
|
|
end
|