From 008f0967d36590606dcdf253d56185f46596e866 Mon Sep 17 00:00:00 2001 From: Jonathan Cobb Date: Thu, 19 Dec 2019 11:24:00 -0500 Subject: [PATCH] email verification working --- .../bubble/model/account/AccountContact.java | 2 ++ .../bubble/resources/account/AuthResource.java | 6 +++--- .../account/StandardAccountMessageService.java | 8 ++++---- .../en_US/request/verify/account/message.hbs | 7 ++++--- .../post_auth/ResourceMessages.properties | 18 ++++++++++++++++-- .../en_US/request/verify/account/message.hbs | 3 ++- bubble-web | 2 +- 7 files changed, 32 insertions(+), 14 deletions(-) diff --git a/bubble-server/src/main/java/bubble/model/account/AccountContact.java b/bubble-server/src/main/java/bubble/model/account/AccountContact.java index 83f50444..fe2e1c08 100644 --- a/bubble-server/src/main/java/bubble/model/account/AccountContact.java +++ b/bubble-server/src/main/java/bubble/model/account/AccountContact.java @@ -54,6 +54,8 @@ public class AccountContact implements Serializable { @HasValue(message="err.cloudServiceType.required") @Getter @Setter private CloudServiceType type; @JsonIgnore public boolean isAuthenticator () { return type == CloudServiceType.authenticator; } + @JsonIgnore public boolean getIsEmail () { return type == CloudServiceType.email; } + @JsonIgnore public boolean getIsSms () { return type == CloudServiceType.sms; } @Getter @Setter private Boolean verified = null; public boolean verified () { return bool(verified); } diff --git a/bubble-server/src/main/java/bubble/resources/account/AuthResource.java b/bubble-server/src/main/java/bubble/resources/account/AuthResource.java index b4cec99f..5403ad63 100644 --- a/bubble-server/src/main/java/bubble/resources/account/AuthResource.java +++ b/bubble-server/src/main/java/bubble/resources/account/AuthResource.java @@ -259,15 +259,15 @@ public class AuthResource { final Account caller = optionalUserPrincipal(ctx); final AccountMessage approval = messageService.approve(caller, getRemoteHost(req), token, data); - if (approval == null) return notFound(token); + if (approval == null) return invalid("err.token.invalid"); final Account account = validateCallerForApproveOrDeny(caller, approval, token); if (approval.getMessageType() == AccountMessageType.confirmation) { - if (account == null) return notFound(approval.getAccount()); + if (account == null) return invalid("err.token.invalid"); if (approval.getAction() == AccountAction.login) { return ok(account.setToken(sessionDAO.create(account))); } else { - return ok(); + return ok_empty(); } } diff --git a/bubble-server/src/main/java/bubble/service/account/StandardAccountMessageService.java b/bubble-server/src/main/java/bubble/service/account/StandardAccountMessageService.java index a1953f03..366d5194 100644 --- a/bubble-server/src/main/java/bubble/service/account/StandardAccountMessageService.java +++ b/bubble-server/src/main/java/bubble/service/account/StandardAccountMessageService.java @@ -2,8 +2,8 @@ package bubble.service.account; import bubble.cloud.auth.AuthenticationDriver; import bubble.dao.account.AccountDAO; -import bubble.dao.account.message.AccountMessageDAO; import bubble.dao.account.AccountPolicyDAO; +import bubble.dao.account.message.AccountMessageDAO; import bubble.dao.cloud.CloudServiceDAO; import bubble.model.account.Account; import bubble.model.account.AccountContact; @@ -202,7 +202,7 @@ public class StandardAccountMessageService implements AccountMessageService { String json = tokens.get(token); if (json == null) { log.warn("captureResponse("+type+"): regular token not found: "+token); - return null; + throw invalidEx("err.token.invalid"); } if (NUMERIC_PATTERN.matcher(json).matches()) { @@ -211,7 +211,7 @@ public class StandardAccountMessageService implements AccountMessageService { json = tokens.get(numericToken); if (json == null) { log.warn("captureResponse("+type+"): numeric token not found: "+numericToken+" (token="+token+")"); - return null; + throw invalidEx("err.token.invalid"); } } @@ -229,7 +229,7 @@ public class StandardAccountMessageService implements AccountMessageService { .setTarget(amc.getMessage().getTarget()); if (data != null && !getCompletionHandler(toCreate).validate(toCreate, data)) { - throw invalidEx("err.request.invalid", type+" request was invalid", json(data)); + throw invalidEx("err.token.invalid", type+" request was invalid", json(data)); } final AccountMessage message = messageDAO.create(toCreate); diff --git a/bubble-server/src/main/resources/message_templates/email/en_US/request/verify/account/message.hbs b/bubble-server/src/main/resources/message_templates/email/en_US/request/verify/account/message.hbs index 9b1a39ca..1f294e24 100644 --- a/bubble-server/src/main/resources/message_templates/email/en_US/request/verify/account/message.hbs +++ b/bubble-server/src/main/resources/message_templates/email/en_US/request/verify/account/message.hbs @@ -9,16 +9,17 @@ Contact information has been added to your account named '{{account.name}}' on { If you did not make this request or would like to cancel this request, please click this link: -{{configuration.publicUriBase}}/me/deny?t={{confirmationToken}} +{{configuration.publicUriBase}}/me/action?deny={{confirmationToken}} ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- - +{{#if contact.isEmail}} If you DID make this request and are ready to verify this contact information, click the link below. -{{configuration.publicUriBase}}/me/approve?t={{confirmationToken}} +{{configuration.publicUriBase}}/me/action?approve={{confirmationToken}} ---------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------- +{{/if}} Thank you for using Bubble! diff --git a/bubble-server/src/main/resources/message_templates/server/en_US/post_auth/ResourceMessages.properties b/bubble-server/src/main/resources/message_templates/server/en_US/post_auth/ResourceMessages.properties index 32c3878e..8bb95ff9 100644 --- a/bubble-server/src/main/resources/message_templates/server/en_US/post_auth/ResourceMessages.properties +++ b/bubble-server/src/main/resources/message_templates/server/en_US/post_auth/ResourceMessages.properties @@ -37,6 +37,7 @@ field_label_auto_update_new_drivers_and_apps=Automatic Updates for New Drivers a button_label_update_profile=Update link_label_change_password=Change Password link_label_account_policy=Account Policy and Contact Info +message_profile_update_success=Profile update was successful # Time duration fields time_duration_options=minutes,hours,days @@ -73,6 +74,11 @@ field_label_policy_contact_type_sms=SMS field_label_policy_contact_type_sms_field=SMS-Enabled Phone Number field_label_policy_contact_type_authenticator=Authentication App field_label_policy_contact_verified=Verified +field_label_policy_contact_verify_code=Enter Verification Code +button_label_submit_verify_code=Verify +message_verify_authenticator_preamble=Install the Google Authenticator app on your device, then scan the QR code shown here and enter the code it displays. +message_verify_authenticator_backupCodes=Backup Codes +message_verify_authenticator_backupCodes_description=If you lose your device or don't have access to it, you can use one of these backup codes. Write them down in a safe place. field_label_policy_contact_requiredForNetworkUnlock=Required to unlock a new Bubble field_label_policy_contact_requiredForNetworkUnlock_icon=fa fa-unlock field_label_policy_contact_requiredForNodeOperations=Required for operations on your Bubble @@ -93,7 +99,7 @@ field_label_policy_contact_authFactors=not_required,required,sufficient field_label_policy_contact_authFactor=Authentication Factor field_label_policy_contact_authFactor_icon=fa fa-passport field_label_policy_contact_authFactor_name_not_required=Not Required -field_label_policy_contact_authFactor_name_not_required_icon=fa fa-circle +field_label_policy_contact_authFactor_name_not_required_icon=fa fa-minus field_label_policy_contact_authFactor_description_not_required=Not a required Auth Factor to approve any operation field_label_policy_contact_authFactor_name_required=Required field_label_policy_contact_authFactor_name_required_icon=fa fa-check-double @@ -103,7 +109,7 @@ field_label_policy_contact_authFactor_name_sufficient_icon=fa fa-check field_label_policy_contact_authFactor_description_sufficient=If an operation is approved via this method (in addition to approval by all Required Auth Factors, if any), then the operation will be allowed field_label_policy_contact_value_enabled_icon=fa fa-check field_label_policy_contact_value_enabled_name=Enabled -field_label_policy_contact_value_disabled_icon=fa fa-circle +field_label_policy_contact_value_disabled_icon=fa fa-minus field_label_policy_contact_value_disabled_name=Disabled field_label_policy_contact_value_not_applicable_icon=fa fa-times-circle field_label_policy_contact_value_not_applicable_name=N/A @@ -115,6 +121,13 @@ button_label_remove_contact_icon=fa fa-trash-alt form_label_title_account_add_contact=Add New Contact/Authorization button_label_add_contact=Add +# Inbound approve/deny via ActionPage -> PolicyPage +message_action_processing=Processing +message_inbound_approve=Approval +message_inbound_deny=Denial +message_inbound_invalid=Invalid request +message_inbound_success=was successful +message_inbound_failure=failed # Networks table loading_networks=Loading bubbles... @@ -361,6 +374,7 @@ err.tgzB64.required=tgzB64 is required err.timezone.unknown=An error ocurred trying to determine the time zone err.timezone.length=Time zone is too long err.timezone.required=Time zone is requird +err.token.invalid=Code is incorrect err.totpKey.length=TOTP key is required err.type.notVerifiable=Type is not verifiable err.type.invalid=Type is invalid diff --git a/bubble-server/src/main/resources/message_templates/sms/en_US/request/verify/account/message.hbs b/bubble-server/src/main/resources/message_templates/sms/en_US/request/verify/account/message.hbs index 1ae1c417..5db27d1b 100644 --- a/bubble-server/src/main/resources/message_templates/sms/en_US/request/verify/account/message.hbs +++ b/bubble-server/src/main/resources/message_templates/sms/en_US/request/verify/account/message.hbs @@ -1 +1,2 @@ -{{network.networkDomain}}: Verification code: {{confirmationToken}} \ No newline at end of file +{{network.networkDomain}}: {{#if contact.isSms}}Verification code: {{confirmationToken}}{{else}}{{#if contact.isEmail}}Email added: {{contact.info}}.{{else}}Auth added: {{contact.type}}{{/if}} +Deny with code: {{confirmationToken}}{{/if}} \ No newline at end of file diff --git a/bubble-web b/bubble-web index 614895af..cef8b32a 160000 --- a/bubble-web +++ b/bubble-web @@ -1 +1 @@ -Subproject commit 614895af758da790d8b80666fbc9ca969172760a +Subproject commit cef8b32a48f3b7a94e5f6a2c34bc0f66f1733cdb