diff --git a/examples/demo/site/config/modules/login/account_activation.html b/examples/demo/site/config/modules/login/account_activation.html new file mode 100644 index 0000000..0ab4c4f --- /dev/null +++ b/examples/demo/site/config/modules/login/account_activation.html @@ -0,0 +1,18 @@ + + + + + Activation + + + + + +

Thank you for registering at ROC CMS

+ +

To complete your registration, please click on this link to activate your account:

+ +

$link

+

Thank you for joining us.

+ + diff --git a/examples/demo/site/config/modules/login/account_new_password.html b/examples/demo/site/config/modules/login/account_new_password.html new file mode 100644 index 0000000..dfcd355 --- /dev/null +++ b/examples/demo/site/config/modules/login/account_new_password.html @@ -0,0 +1,17 @@ + + + + + New Password + + + + + +

You have required a new password at ROC CMS

+ +

To complete your request, please click on this link to genereate a new password:

+ +

$link

+ + \ No newline at end of file diff --git a/examples/demo/site/config/modules/login/account_re_activation.html b/examples/demo/site/config/modules/login/account_re_activation.html new file mode 100644 index 0000000..95aebb2 --- /dev/null +++ b/examples/demo/site/config/modules/login/account_re_activation.html @@ -0,0 +1,18 @@ + + + + + New Activation + + + + + +

You have request a new activation token atROC CMS

+ +

To complete your registration, please click on this link to activate your account:

+ +

$link

+

Thank you for joining us.

+ + \ No newline at end of file diff --git a/examples/demo/site/config/modules/login/account_welcome.html b/examples/demo/site/config/modules/login/account_welcome.html new file mode 100644 index 0000000..0ea987c --- /dev/null +++ b/examples/demo/site/config/modules/login/account_welcome.html @@ -0,0 +1,13 @@ + + + + + Welcome + + + + +

Welcome toROC CMS

+

Thank you for joining us.

+ + \ No newline at end of file diff --git a/examples/demo/site/config/modules/login/login.json b/examples/demo/site/config/modules/login/login.json index 5b44da3..2f3e155 100644 --- a/examples/demo/site/config/modules/login/login.json +++ b/examples/demo/site/config/modules/login/login.json @@ -1,5 +1,8 @@ { "email": "webmaster@example.com", - "subjet": "Thank you for regitering with us", + "subjet_register": "Thank you for regitering with us, activate account", + "subjet_activate": "New account ativation token", + "subjet_password": "Password Recovery!!!", + "subjet_oauth": "Welcome", "smtp": "127.0.0.1" } diff --git a/examples/demo/site/scripts/oauth_gmail.sql b/examples/demo/site/scripts/oauth2_gmail.sql similarity index 100% rename from examples/demo/site/scripts/oauth_gmail.sql rename to examples/demo/site/scripts/oauth2_gmail.sql diff --git a/examples/demo/site/themes/bootstrap/modules/login/templates/block_login.tpl b/examples/demo/site/themes/bootstrap/modules/login/templates/block_login.tpl index 18301e6..130aa76 100644 --- a/examples/demo/site/themes/bootstrap/modules/login/templates/block_login.tpl +++ b/examples/demo/site/themes/bootstrap/modules/login/templates/block_login.tpl @@ -1,9 +1,6 @@
- {if isset="$user"} -

Logout

- {/if} - {unless isset="$user"} -

Login or Register

+ {unless isset="$user"} +

Login or Register

@@ -24,12 +21,12 @@
- {/unless}
- +
+ {/unless}
\ No newline at end of file diff --git a/examples/demo/site/themes/bootstrap/modules/login/templates/block_new_password.tpl b/examples/demo/site/themes/bootstrap/modules/login/templates/block_new_password.tpl index 84b5de0..ef5407f 100644 --- a/examples/demo/site/themes/bootstrap/modules/login/templates/block_new_password.tpl +++ b/examples/demo/site/themes/bootstrap/modules/login/templates/block_new_password.tpl @@ -1,5 +1,5 @@
- +
Require new password
diff --git a/examples/demo/site/themes/bootstrap/modules/login/templates/block_reactivate.tpl b/examples/demo/site/themes/bootstrap/modules/login/templates/block_reactivate.tpl index 01a7960..bef65c0 100644 --- a/examples/demo/site/themes/bootstrap/modules/login/templates/block_reactivate.tpl +++ b/examples/demo/site/themes/bootstrap/modules/login/templates/block_reactivate.tpl @@ -1,5 +1,5 @@
- +
Reactivate Form
diff --git a/examples/demo/site/themes/bootstrap/modules/login/templates/block_register.tpl b/examples/demo/site/themes/bootstrap/modules/login/templates/block_register.tpl index 522bde9..58a4872 100644 --- a/examples/demo/site/themes/bootstrap/modules/login/templates/block_register.tpl +++ b/examples/demo/site/themes/bootstrap/modules/login/templates/block_register.tpl @@ -1,5 +1,5 @@
- +
Register Form
diff --git a/examples/demo/site/themes/bootstrap/modules/login/templates/block_reset_password.tpl b/examples/demo/site/themes/bootstrap/modules/login/templates/block_reset_password.tpl index aa2ee81..b99289d 100644 --- a/examples/demo/site/themes/bootstrap/modules/login/templates/block_reset_password.tpl +++ b/examples/demo/site/themes/bootstrap/modules/login/templates/block_reset_password.tpl @@ -1,5 +1,5 @@
- +
Generate New Password Form
diff --git a/modules/login/filter/oauth_gmail_filter.e b/modules/login/filter/oauth_gmail_filter.e index 95c4d62..c4f6310 100644 --- a/modules/login/filter/oauth_gmail_filter.e +++ b/modules/login/filter/oauth_gmail_filter.e @@ -1,6 +1,5 @@ note description: "Summary description for {OAUTH_GMAIL_FILTER}." - author: "" date: "$Date$" revision: "$Revision$" @@ -42,7 +41,7 @@ feature -- Basic operations end -- A valid user if - attached {WSF_STRING} req.cookie ("EWF_ROC_OAUTH_GMAIL_SESSION_") as l_roc_auth_session_token + attached {WSF_STRING} req.cookie ({LOGIN_CONSTANTS}.oauth_gmail_session) as l_roc_auth_session_token then if attached {CMS_USER} user_oauth_api.user_by_oauth2_gmail_token (l_roc_auth_session_token.value) as l_user then set_current_user (req, l_user) diff --git a/modules/login/login_constants.e b/modules/login/login_constants.e new file mode 100644 index 0000000..39886dc --- /dev/null +++ b/modules/login/login_constants.e @@ -0,0 +1,13 @@ +note + description: "Summary description for {LOGIN_CONSTANTS}." + date: "$Date$" + revision: "$Revision$" + +class + LOGIN_CONSTANTS + +feature -- Access + + oauth_gmail_session: STRING = "EWF_ROC_OAUTH_GMAIL_SESSION_" + +end diff --git a/modules/login/login_email_service.e b/modules/login/login_email_service.e index 2ada59e..9d885b4 100644 --- a/modules/login/login_email_service.e +++ b/modules/login/login_email_service.e @@ -38,8 +38,51 @@ feature -- Basic Operations -- Send successful contact message `a_token' to `a_to'. require attached_to: a_to /= Void + local + l_message: STRING do - send_message (contact_email, a_to, parameters.contact_subject_text, a_content) + create l_message.make_from_string (parameters.account_activation) + l_message.replace_substring_all ("$link", a_content) + send_message (contact_email, a_to, parameters.contact_subject_register, l_message) end + + send_contact_activation_email (a_to, a_content: READABLE_STRING_8) + -- Send successful contact message `a_token' to `a_to'. + require + attached_to: a_to /= Void + local + l_message: STRING + do + create l_message.make_from_string (parameters.account_re_activation) + l_message.replace_substring_all ("$link", a_content) + send_message (contact_email, a_to, parameters.contact_subject_activate, l_message) + end + + + send_contact_password_email (a_to, a_content: READABLE_STRING_8) + -- Send successful contact message `a_token' to `a_to'. + require + attached_to: a_to /= Void + local + l_message: STRING + do + create l_message.make_from_string (parameters.account_password) + l_message.replace_substring_all ("$link", a_content) + send_message (contact_email, a_to, parameters.contact_subject_password, l_message) + end + + send_contact_welcome_email (a_to, a_content: READABLE_STRING_8) + -- Send successful contact message `a_token' to `a_to'. + require + attached_to: a_to /= Void + local + l_message: STRING + do + create l_message.make_from_string (parameters.account_welcome) + l_message.replace_substring_all ("$link", a_content) + send_message (contact_email, a_to, parameters.contact_subject_oauth, l_message) + end + + end diff --git a/modules/login/login_email_service_parameters.e b/modules/login/login_email_service_parameters.e index d356af0..b3e8feb 100644 --- a/modules/login/login_email_service_parameters.e +++ b/modules/login/login_email_service_parameters.e @@ -19,8 +19,9 @@ feature {NONE} -- Initialization utf: UTF_CONVERTER l_site_name: READABLE_STRING_8 s: detachable READABLE_STRING_32 - l_contact_email, l_contact_subject: detachable READABLE_STRING_8 + l_contact_email, l_subject_register, l_subject_activate, l_subject_password, l_subject_oauth: detachable READABLE_STRING_8 do + setup := a_cms_api.setup -- 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) @@ -39,10 +40,23 @@ feature {NONE} -- Initialization if s /= Void then l_contact_email := utf.utf_32_string_to_utf_8_string_8 (s) end - s := cfg.text_item ("subject") + s := cfg.text_item ("subject_register") if s /= Void then - l_contact_subject := utf.utf_32_string_to_utf_8_string_8 (s) + 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 @@ -52,11 +66,28 @@ feature {NONE} -- Initialization else contact_email := admin_email end - if l_contact_subject /= Void then - contact_subject_text := l_contact_subject + if l_subject_register /= Void then + contact_subject_register := l_subject_register else - contact_subject_text := "Thank you for registering with us" + 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 + end feature -- Access @@ -68,6 +99,171 @@ feature -- Access contact_email: IMMUTABLE_STRING_8 -- Contact email. - contact_subject_text: 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 + + + + account_activation: STRING + -- Account activation template email message. + local + p: PATH + do + p := setup.environment.config_path.extended ("modules").extended ("login").extended("account_activation.html") + if attached read_template_file (p) as l_content then + Result := l_content + else + create Result.make_from_string (template_account_activation) + end + end + + account_re_activation: STRING + -- Account re_activation template email message. + local + p: PATH + do + p := setup.environment.config_path.extended ("modules").extended ("login").extended("accunt_re_activation.html") + if attached read_template_file (p) as l_content then + Result := l_content + else + create Result.make_from_string (template_account_re_activation) + end + end + + account_password: STRING + -- Account password template email message. + local + p: PATH + do + p := setup.environment.config_path.extended ("modules").extended ("login").extended("account_new_password.html") + if attached read_template_file (p) as l_content then + Result := l_content + else + create Result.make_from_string (template_account_new_password) + end + end + + account_welcome: STRING + -- Account welcome template email message. + local + p: PATH + do + p := setup.environment.config_path.extended ("modules").extended ("login").extended("account_welcome.html") + if attached read_template_file (p) as l_content then + Result := l_content + else + create Result.make_from_string (template_account_welcome) + end + end + +feature {NONE} -- Implementation + + setup: CMS_SETUP + + + read_template_file (a_path: PATH): detachable STRING + -- Read the content of the file at path `a_path'. + local + l_file: FILE + l_content: STRING + do + create {PLAIN_TEXT_FILE} l_file.make_with_path (a_path) + if l_file.exists and then l_file.is_readable then + l_file.open_read + l_file.read_stream (l_file.count) + Result := l_file.last_string + l_file.close + else + -- Error + end + end + + +feature {NONE} -- Message email + + template_account_activation: STRING= "[ + + + + + Activation + + + + + +

Thank you for registering at ROC CMS

+ +

To complete your registration, please click on this link to activate your account:

+ +

$link

+

Thank you for joining us.

+ + + ]" + + + template_account_re_activation: STRING= "[ + + + + + New Activation + + + + + +

You have request a new activation token atROC CMS

+ +

To complete your registration, please click on this link to activate your account:

+ +

$link

+

Thank you for joining us.

+ + + ]" + + + + template_account_new_password: STRING= "[ + + + + + New Password + + + + + +

You have required a new password at ROC CMS

+ +

To complete your request, please click on this link to genereate a new password:

+ +

$link

+ + + ]" + + + template_account_welcome: STRING= "[ + + + + + Welcome + + + + + +

Welcome toROC CMS

+

Thank you for joining us.

+ + + ]" end diff --git a/modules/login/login_module.e b/modules/login/login_module.e index 3c336cd..4db73b7 100644 --- a/modules/login/login_module.e +++ b/modules/login/login_module.e @@ -39,6 +39,7 @@ inherit CMS_REQUEST_UTIL + create make @@ -100,7 +101,7 @@ feature {CMS_API} -- Module management if attached {CMS_STORAGE_SQL_I} api.storage as l_sql_storage then if not l_sql_storage.sql_table_exists ("oauth2_gmail") then --| Schema - l_sql_storage.sql_execute_file_script (l_setup.environment.path.extended ("scripts").extended ("core.sql")) + l_sql_storage.sql_execute_file_script (l_setup.environment.path.extended ("scripts").extended ("oauth2_gmail.sql")) if l_sql_storage.has_error then api.logger.put_error ("Could not initialize database for blog module", generating_type) @@ -156,16 +157,15 @@ feature -- Router configure_web (a_api: CMS_API; a_user_oauth_api: CMS_USER_OAUTH_API; a_router: WSF_ROUTER) do - a_router.handle_with_request_methods ("/roc-login", create {WSF_URI_AGENT_HANDLER}.make (agent handle_login (a_api, ?, ?)), a_router.methods_head_get) - a_router.handle_with_request_methods ("/roc-register", create {WSF_URI_AGENT_HANDLER}.make (agent handle_register (a_api, ?, ?)), a_router.methods_get_post) - a_router.handle_with_request_methods ("/activate/{token}", create {WSF_URI_TEMPLATE_AGENT_HANDLER}.make (agent handle_activation (a_api, ?, ?)), a_router.methods_head_get) - a_router.handle_with_request_methods ("/reactivate", create {WSF_URI_AGENT_HANDLER}.make (agent handle_reactivation (a_api, ?, ?)), a_router.methods_get_post) - a_router.handle_with_request_methods ("/new-password", create {WSF_URI_AGENT_HANDLER}.make (agent handle_new_password (a_api, ?, ?)), a_router.methods_get_post) - a_router.handle_with_request_methods ("/reset-password", create {WSF_URI_AGENT_HANDLER}.make (agent handle_reset_password (a_api, ?, ?)), a_router.methods_get_post) - a_router.handle_with_request_methods ("/roc-logout", create {WSF_URI_AGENT_HANDLER}.make (agent handle_logout (a_api, ?, ?)), a_router.methods_get_post) - a_router.handle_with_request_methods ("/login-with-google", create {WSF_URI_AGENT_HANDLER}.make (agent handle_login_with_google (a_api, ?, ?)), a_router.methods_get_post) - a_router.handle_with_request_methods ("/oauthgmail", create {WSF_URI_AGENT_HANDLER}.make (agent handle_callback_gmail (a_api, a_user_oauth_api, ?, ?)), a_router.methods_get_post) - + a_router.handle_with_request_methods ("/account/roc-login", create {WSF_URI_AGENT_HANDLER}.make (agent handle_login (a_api, ?, ?)), a_router.methods_head_get) + a_router.handle_with_request_methods ("/account/roc-register", create {WSF_URI_AGENT_HANDLER}.make (agent handle_register (a_api, ?, ?)), a_router.methods_get_post) + a_router.handle_with_request_methods ("/account/activate/{token}", create {WSF_URI_TEMPLATE_AGENT_HANDLER}.make (agent handle_activation (a_api, ?, ?)), a_router.methods_head_get) + a_router.handle_with_request_methods ("/account/reactivate", create {WSF_URI_AGENT_HANDLER}.make (agent handle_reactivation (a_api, ?, ?)), a_router.methods_get_post) + a_router.handle_with_request_methods ("/account/new-password", create {WSF_URI_AGENT_HANDLER}.make (agent handle_new_password (a_api, ?, ?)), a_router.methods_get_post) + a_router.handle_with_request_methods ("/account/reset-password", create {WSF_URI_AGENT_HANDLER}.make (agent handle_reset_password (a_api, ?, ?)), a_router.methods_get_post) + a_router.handle_with_request_methods ("/account/roc-logout", create {WSF_URI_AGENT_HANDLER}.make (agent handle_logout (a_api, ?, ?)), a_router.methods_get_post) + a_router.handle_with_request_methods ("/account/login-with-google", create {WSF_URI_AGENT_HANDLER}.make (agent handle_login_with_google (a_api, ?, ?)), a_router.methods_get_post) + a_router.handle_with_request_methods ("/account/oauthgmail", create {WSF_URI_AGENT_HANDLER}.make (agent handle_callback_gmail (a_api, a_user_oauth_api, ?, ?)), a_router.methods_get_post) end @@ -196,9 +196,9 @@ feature -- Hooks lnk: CMS_LOCAL_LINK do if attached a_response.current_user (a_response.request) as u then - create lnk.make (u.name + " (Logout)", "roc-logout" ) + create lnk.make (u.name + " (Logout)", "account/roc-logout" ) else - create lnk.make ("Login", "roc-login") + create lnk.make ("Login", "account/roc-login") end a_menu_system.primary_menu.extend (lnk) lnk.set_weight (98) @@ -223,27 +223,27 @@ feature -- Hooks do if a_block_id.is_case_insensitive_equal_general ("login") and then - a_response.request.path_info.starts_with ("/roc-login") + a_response.request.path_info.starts_with ("/account/roc-login") then get_block_view_login (a_block_id, a_response) elseif a_block_id.is_case_insensitive_equal_general ("register") and then - a_response.request.path_info.starts_with ("/roc-register") + a_response.request.path_info.starts_with ("/account/roc-register") then get_block_view_register (a_block_id, a_response) elseif a_block_id.is_case_insensitive_equal_general ("reactivate") and then - a_response.request.path_info.starts_with ("/reactivate") + a_response.request.path_info.starts_with ("/account/reactivate") then get_block_view_reactivate (a_block_id, a_response) elseif a_block_id.is_case_insensitive_equal_general ("new_password") and then - a_response.request.path_info.starts_with ("/new-password") + a_response.request.path_info.starts_with ("/account/new-password") then get_block_view_new_password (a_block_id, a_response) elseif a_block_id.is_case_insensitive_equal_general ("reset_password") and then - a_response.request.path_info.starts_with ("/reset-password") + a_response.request.path_info.starts_with ("/account/reset-password") then get_block_view_reset_password (a_block_id, a_response) end @@ -259,6 +259,15 @@ feature -- Hooks r.execute end + handle_workaround_filter (api: CMS_API; req: WSF_REQUEST; res: WSF_RESPONSE) + local + r: CMS_RESPONSE + br: BAD_REQUEST_ERROR_CMS_RESPONSE + do + create {GENERIC_VIEW_CMS_RESPONSE} r.make (req, res, api) + r.execute + end + handle_logout (api: CMS_API; req: WSF_REQUEST; res: WSF_RESPONSE) local @@ -268,13 +277,14 @@ feature -- Hooks l_cookie: WSF_COOKIE do if - attached {WSF_STRING} req.cookie ("EWF_ROC_OAUTH_GMAIL_SESSION_") as l_cookie_token and then + attached {WSF_STRING} req.cookie ({LOGIN_CONSTANTS}.oauth_gmail_session) as l_cookie_token and then attached {CMS_USER} current_user (req) as l_user then -- Logout gmail create l_oauth_gmail.make (api, req.absolute_script_url ("")) l_oauth_gmail.sign_out (l_cookie_token.value) - create l_cookie.make ("EWF_ROC_OAUTH_GMAIL_SESSION_", l_cookie_token.value) + create l_cookie.make ({LOGIN_CONSTANTS}.oauth_gmail_session, l_cookie_token.value) + l_cookie.set_path ("/") l_cookie.set_max_age (-1) res.add_cookie (l_cookie) unset_current_user (req) @@ -340,16 +350,14 @@ feature -- Hooks l_token := new_token l_user_api.new_activation (l_token, u.id) create l_link.make_from_string (req.server_url) - l_link.append ("/activate/") + l_link.append ("/account/activate/") l_link.append (l_token) - create l_message.make_from_string (account_activation) - l_message.replace_substring_all ("$link", l_link) -- Send Email create es.make (create {LOGIN_EMAIL_SERVICE_PARAMETERS}.make (api)) write_debug_log (generator + ".handle register: send_contact_email") - es.send_contact_email (l_email.value, l_message) + es.send_contact_email (l_email.value, l_link) else r.values.force (l_name.value, "name") @@ -385,7 +393,7 @@ feature -- Hooks -- the token does not exist, or it was already used. r.set_status_code ({HTTP_CONSTANTS}.bad_request) r.set_value ("Account not activated", "optional_content_type") - r.set_main_content ("

The token "+ l_token.value +" is not valid Reactivate Account

" ) + r.set_main_content ("

The token "+ l_token.value +" is not valid Reactivate Account

" ) end r.execute @@ -421,16 +429,13 @@ feature -- Hooks l_token := new_token l_user_api.new_activation (l_token, l_user.id) create l_link.make_from_string (req.server_url) - l_link.append ("/activate/") + l_link.append ("/account/activate/") l_link.append (l_token) - create l_message.make_from_string (account_activation) - l_message.replace_substring_all ("$link", l_link) - -- Send Email create es.make (create {LOGIN_EMAIL_SERVICE_PARAMETERS}.make (api)) - write_debug_log (generator + ".handle register: send_contact_email") - es.send_contact_email (l_email.value, l_message) + write_debug_log (generator + ".handle register: send_contact_activation_email") + es.send_contact_activation_email (l_email.value, l_link) end else r.values.force ("The email does not exist or !", "error_email") @@ -462,16 +467,13 @@ feature -- Hooks l_token := new_token l_user_api.new_password (l_token, l_user.id) create l_link.make_from_string (req.server_url) - l_link.append ("/reset-password?token=") + l_link.append ("/account/reset-password?token=") l_link.append (l_token) - create l_message.make_from_string (account_new_password) - l_message.replace_substring_all ("$link", l_link) - -- Send Email create es.make (create {LOGIN_EMAIL_SERVICE_PARAMETERS}.make (api)) - write_debug_log (generator + ".handle register: send_contact_email") - es.send_contact_email (l_email.value, l_message) + write_debug_log (generator + ".handle register: send_contact_password_email") + es.send_contact_password_email (l_email.value, l_link) else r.values.force ("The email does not exist !", "error_email") r.values.force (l_email.value, "email") @@ -497,7 +499,7 @@ feature -- Hooks if attached {WSF_STRING} req.query_parameter ("token") as l_token then r.values.force (l_token.value, "token") if l_user_api.user_by_password_token (l_token.value) = Void then - r.values.force ("The token " + l_token.value + " is not valid, click here to generate a new token.", "error_token") + r.values.force ("The token " + l_token.value + " is not valid, click here to generate a new token.", "error_token") r.set_status_code ({HTTP_CONSTANTS}.bad_request) end end @@ -743,6 +745,7 @@ feature -- OAuth2 Login with google. l_user: CMS_USER l_roles: LIST [CMS_USER_ROLE] l_cookie: WSF_COOKIE + es: LOGIN_EMAIL_SERVICE do if attached {WSF_STRING} req.query_parameter ("code") as l_code then create l_auth_gmail.make (api, req.server_url) @@ -768,8 +771,9 @@ feature -- OAuth2 Login with google. -- create a oauth entry a_user_oauth_api.new_user_oauth2_gmail (l_access_token.token, l_user_profile, p_user ) end - create l_cookie.make ("EWF_ROC_OAUTH_GMAIL_SESSION_", l_access_token.token) + create l_cookie.make ({LOGIN_CONSTANTS}.oauth_gmail_session, l_access_token.token) l_cookie.set_max_age (l_access_token.expires_in) + l_cookie.set_path ("/") res.add_cookie (l_cookie) else @@ -786,13 +790,19 @@ feature -- OAuth2 Login with google. -- Add oauth entry a_user_oauth_api.new_user_oauth2_gmail (l_access_token.token, l_user_profile, l_user ) - create l_cookie.make ("EWF_ROC_OAUTH_GMAIL_SESSION_", l_access_token.token) + create l_cookie.make ({LOGIN_CONSTANTS}.oauth_gmail_session, l_access_token.token) l_cookie.set_max_age (l_access_token.expires_in) + l_cookie.set_path ("/") res.add_cookie (l_cookie) + set_current_user (req, l_user) + + + -- Send Email + create es.make (create {LOGIN_EMAIL_SERVICE_PARAMETERS}.make (api)) + write_debug_log (generator + ".handle register: send_contact_welcome_email") + es.send_contact_welcome_email (l_email, "") end else - - end r.set_redirection (req.absolute_script_url ("")) r.execute @@ -823,48 +833,7 @@ feature {NONE} -- Token Generation Result := l_token end -feature --{NONE} -- Message email - account_activation: STRING= "[ - - - - - Eiffel.org Activation - - - - - -

Thank you for registering at Eiffel.org

- -

To complete your registration, please click on this link to activate your account:

- -

$link

-

Thank you for joining us.

- - - ]" - - account_new_password: STRING= "[ - - - - - Eiffel.org New Password - - - - - -

You have required a new password at Eiffel.org

- -

To complete your request, please click on this link to genereate a new password:

- -

$link

- - - ]" feature {NONE} -- Implementation: date and time diff --git a/modules/login/oauth_login_gmail.e b/modules/login/oauth_login_gmail.e index 1c484c9..f84c622 100644 --- a/modules/login/oauth_login_gmail.e +++ b/modules/login/oauth_login_gmail.e @@ -21,7 +21,7 @@ feature {NONE} -- Initialization cms_api := a_cms_api initilize create config.make_default (api_key, api_secret) - config.set_callback (a_host + "/oauthgmail") + config.set_callback (a_host + "/account/oauthgmail") config.set_scope (scope) create goauth api_service := goauth.create_service (config)