Kaynağa Gözat

verifications templates working properly

tags/v0.1.6
Jonathan Cobb 5 yıl önce
ebeveyn
işleme
4ece6eff64
10 değiştirilmiş dosya ile 33 ekleme ve 14 silme
  1. +2
    -0
      bubble-server/src/main/java/bubble/cloud/sms/SmsServiceDriverBase.java
  2. +3
    -0
      bubble-server/src/main/java/bubble/model/account/AccountPolicy.java
  3. +2
    -0
      bubble-server/src/main/java/bubble/model/account/message/AccountMessage.java
  4. +6
    -4
      bubble-server/src/main/java/bubble/model/account/message/handlers/AccountVerifyHandler.java
  5. +10
    -0
      bubble-server/src/main/java/bubble/service/account/StandardAccountMessageService.java
  6. +2
    -2
      bubble-server/src/main/resources/message_templates/email/en_US/request/login/account/message.hbs
  7. +3
    -3
      bubble-server/src/main/resources/message_templates/email/en_US/request/verify/account/message.hbs
  8. +3
    -2
      bubble-server/src/main/resources/message_templates/sms/en_US/request/login/account/message.hbs
  9. +1
    -2
      bubble-server/src/main/resources/message_templates/sms/en_US/request/verify/account/message.hbs
  10. +1
    -1
      bubble-web

+ 2
- 0
bubble-server/src/main/java/bubble/cloud/sms/SmsServiceDriverBase.java Dosyayı Görüntüle

@@ -8,6 +8,7 @@ import bubble.model.cloud.CloudService;
import com.fasterxml.jackson.databind.JsonNode;
import lombok.Getter;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import org.cobbzilla.util.string.LocaleUtil;

import java.util.Map;
@@ -17,6 +18,7 @@ import static org.cobbzilla.util.daemon.ZillaRuntime.die;
import static org.cobbzilla.util.json.JsonUtil.json;
import static org.cobbzilla.util.reflect.ReflectionUtil.getFirstTypeParam;

@Slf4j
public abstract class SmsServiceDriverBase<T extends SmsConfig> implements SmsServiceDriver {

protected T config;


+ 3
- 0
bubble-server/src/main/java/bubble/model/account/AccountPolicy.java Dosyayı Görüntüle

@@ -165,6 +165,9 @@ public class AccountPolicy extends IdentifiableBase implements HasAccount {
public AccountContact findContact(AccountContact contact) {
return findContact(contact, getAccountContacts());
}
public AccountContact findContactByUuid(String uuid) {
return findContact(new AccountContact().setUuid(uuid), getAccountContacts());
}

protected static AccountContact findContact(AccountContact contact, AccountContact[] accountContacts) {
if (accountContacts == null || accountContacts.length == 0) return null;


+ 2
- 0
bubble-server/src/main/java/bubble/model/account/message/AccountMessage.java Dosyayı Görüntüle

@@ -1,6 +1,7 @@
package bubble.model.account.message;

import bubble.model.account.Account;
import bubble.model.account.AccountContact;
import bubble.model.account.AccountPolicy;
import bubble.model.account.HasAccount;
import lombok.Getter;
@@ -72,6 +73,7 @@ public class AccountMessage extends IdentifiableBase implements HasAccount {
@Getter @Setter private String data;

@Transient @Getter @Setter private transient AccountMessage request;
@Transient @Getter @Setter private transient AccountContact requestContact;

public String templateName(String basename) { return getMessageType()+"/"+ getAction()+"/"+getTarget()+"/"+basename+".hbs"; }



+ 6
- 4
bubble-server/src/main/java/bubble/model/account/message/handlers/AccountVerifyHandler.java Dosyayı Görüntüle

@@ -16,14 +16,16 @@ public class AccountVerifyHandler implements AccountMessageCompletionHandler {

@Override public void confirm(AccountMessage message, NameAndValue[] data) {
final AccountPolicy policy = policyDAO.findSingleByAccount(message.getAccount());
log.info("confirm: verifying contact "+message.getContact()+" from account "+message.getAccount());
policyDAO.update(policy.verifyContact(message.getContact()));
final String contact = message.getRequest().getContact();
log.info("confirm: verifying contact "+ contact +" from account "+message.getAccount());
policyDAO.update(policy.verifyContact(contact));
}

@Override public void deny(AccountMessage message) {
final AccountPolicy policy = policyDAO.findSingleByAccount(message.getAccount());
log.info("deny: removing contact "+message.getContact()+" from account "+message.getAccount());
policy.removeContact(new AccountContact().setUuid(message.getContact()));
final String contact = message.getRequest().getContact();
log.info("deny: removing contact "+ contact +" from account "+message.getAccount());
policy.removeContact(new AccountContact().setUuid(contact));
policyDAO.update(policy);
}



+ 10
- 0
bubble-server/src/main/java/bubble/service/account/StandardAccountMessageService.java Dosyayı Görüntüle

@@ -71,11 +71,15 @@ public class StandardAccountMessageService implements AccountMessageService {
log.error(prefix+"no clouds of type " + contact.getType() + " found");
return false;
}
final AccountPolicy policy = policyDAO.findSingleByAccount(account.getUuid());
for (CloudService cloud : priorityDesc(clouds)) {
final AuthenticationDriver driver = cloud.getAuthenticationDriver(configuration);
if (shouldSend(message, contact)) {
if (message.getMessageType().hasRequest()) {
message.setRequest(messageDAO.findOperationRequest(message));
message.setRequestContact(policy.findContactByUuid(message.getRequest().getContact()));
} else {
message.setRequestContact(policy.findContactByUuid(message.getContact()));
}
if (driver.send(account, message, contact)) {
log.info(prefix + "send succeeded with cloud: " + cloud.getName());
@@ -125,7 +129,10 @@ public class StandardAccountMessageService implements AccountMessageService {
}
final AccountMessageApprovalStatus approvalStatus = messageDAO.requestApproved(account, approval);
if (approvalStatus == AccountMessageApprovalStatus.ok_confirmed) {
final AccountPolicy policy = policyDAO.findSingleByAccount(account.getUuid());
final AccountMessage confirm = messageDAO.create(new AccountMessage(approval).setMessageType(AccountMessageType.confirmation));
approval.setRequest(messageDAO.findOperationRequest(approval));
approval.setRequestContact(policy.findContactByUuid(approval.getRequest().getContact()));
getCompletionHandler(approval).confirm(approval, data);
return confirm;
} else if (approvalStatus.ok()) {
@@ -173,7 +180,10 @@ public class StandardAccountMessageService implements AccountMessageService {
// has it already been denied?
final List<AccountMessage> denials = messageDAO.findOperationDenials(denial);
if (!denials.isEmpty()) {
final AccountPolicy policy = policyDAO.findSingleByAccount(account.getUuid());
if (denials.size() == 1 && denials.get(0).getUuid().equals(denial.getUuid())) {
denial.setRequest(messageDAO.findOperationRequest(denial));
denial.setRequestContact(policy.findContactByUuid(denial.getRequest().getContact()));
getCompletionHandler(denial).deny(denial);
}
return denials.get(0);


+ 2
- 2
bubble-server/src/main/resources/message_templates/email/en_US/request/login/account/message.hbs Dosyayı Görüntüle

@@ -9,14 +9,14 @@ The login request was made on {{format_epoch message.ctime 'MMM dd, YYYY' networ

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}}/deny?t={{confirmationToken}}

----------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------

If you DID make this request and are ready to approve this login, click the link below.

{{configuration.publicUriBase}}/me/approve?t={{confirmationToken}}
{{configuration.publicUriBase}}/approve?t={{confirmationToken}}

----------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------


+ 3
- 3
bubble-server/src/main/resources/message_templates/email/en_US/request/verify/account/message.hbs Dosyayı Görüntüle

@@ -2,7 +2,7 @@ Hello {{account.name}},

Contact information has been added to your account named '{{account.name}}' on {{network.networkDomain}}

{{contact.type}} - {{contact.info}} {{#if contact.nick}}({{contact.nick}}){{/if}}
{{#string_compare contact.uuid '==' message.contact}}{{contact.type}} - {{contact.info}}{{else}}{{message.requestContact.type}}{{#if message.requestContact.isSms}}{{message.requestContact.info}}{{/if}}{{/string_compare}} {{#if message.requestContact.nick}}({{message.requestContact.nick}}){{/if}}

----------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------
@@ -13,13 +13,13 @@ If you did not make this request or would like to cancel this request, please cl

----------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------
{{#if contact.isEmail}}
{{#string_compare contact.uuid '==' message.contact}}
If you DID make this request and are ready to verify this contact information, click the link below.

{{configuration.publicUriBase}}/me/action?approve={{confirmationToken}}

----------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------
{{/if}}
{{/string_compare}}

Thank you for using Bubble!

+ 3
- 2
bubble-server/src/main/resources/message_templates/sms/en_US/request/login/account/message.hbs Dosyayı Görüntüle

@@ -1,2 +1,3 @@
{{network.networkDomain}}: Account login requested by {{contact.type}}/{{contact.info}} {{#if contact.nick}}({{contact.nick}}){{/if}}
Use login code {{confirmationToken}}
{{network.networkDomain}}: Login requested by {{contact.type}}/{{contact.info}} {{#if contact.nick}}({{contact.nick}}){{/if}}
Approve: {{configuration.publicUriBase}}/action?approve={{confirmationToken}}
Deny: {{configuration.publicUriBase}}/action?deny={{confirmationToken}}

+ 1
- 2
bubble-server/src/main/resources/message_templates/sms/en_US/request/verify/account/message.hbs Dosyayı Görüntüle

@@ -1,2 +1 @@
{{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}}
{{network.networkDomain}}: {{#string_compare contact.uuid '==' message.contact}}SMS Phone added: {{contact.info}} - Approve: {{configuration.publicUriBase}}/me/action?approve={{confirmationToken}} - Deny: {{configuration.publicUriBase}}/me/action?deny={{confirmationToken}}{{else}}{{#if message.requestContact.isEmail}}Email added: {{message.requestContact.info}}{{else}}Auth added: {{message.requestContact.type}}{{/if}} - Deny: {{configuration.publicUriBase}}/me/action?deny={{confirmationToken}}{{/string_compare}}

+ 1
- 1
bubble-web

@@ -1 +1 @@
Subproject commit cef8b32a48f3b7a94e5f6a2c34bc0f66f1733cdb
Subproject commit 47b55a7dc73c3018cf7fbda9e03efc3ab3110b71

Yükleniyor…
İptal
Kaydet