Browse Source

fix approval token errors

tags/v0.1.8
Jonathan Cobb 5 years ago
parent
commit
01e31e9bc2
9 changed files with 33 additions and 9 deletions
  1. +2
    -1
      bubble-server/src/main/java/bubble/dao/bill/AccountPlanDAO.java
  2. +1
    -1
      bubble-server/src/main/java/bubble/model/bill/AccountPlan.java
  3. +19
    -0
      bubble-server/src/main/java/bubble/resources/DebugResource.java
  4. +3
    -3
      bubble-server/src/main/java/bubble/service/account/StandardAccountMessageService.java
  5. +4
    -0
      bubble-server/src/main/resources/message_templates/en_US/server/post_auth/ResourceMessages.properties
  6. +1
    -1
      bubble-server/src/test/resources/models/tests/auth/account_crud.json
  7. +1
    -1
      bubble-web
  8. +1
    -1
      utils/cobbzilla-utils
  9. +1
    -1
      utils/cobbzilla-wizard

+ 2
- 1
bubble-server/src/main/java/bubble/dao/bill/AccountPlanDAO.java View File

@@ -97,9 +97,10 @@ public class AccountPlanDAO extends AccountOwnedEntityDAO<AccountPlan> {
} }
accountPlan.setPaymentMethod(accountPlan.getPaymentMethodObject().getUuid()); accountPlan.setPaymentMethod(accountPlan.getPaymentMethodObject().getUuid());
accountPlan.setNextBill(0L); // bill and payment occurs in postCreate, will update this accountPlan.setNextBill(0L); // bill and payment occurs in postCreate, will update this
accountPlan.setNextBillDate();
accountPlan.setNextBillDate("msg.nextBillDate.pending");
} else { } else {
accountPlan.setNextBill(Long.MAX_VALUE); accountPlan.setNextBill(Long.MAX_VALUE);
accountPlan.setNextBillDate("msg.nextBillDate.paymentsNotEnabled");
} }
return super.preCreate(accountPlan); return super.preCreate(accountPlan);
} }


+ 1
- 1
bubble-server/src/main/java/bubble/model/bill/AccountPlan.java View File

@@ -97,7 +97,7 @@ public class AccountPlan extends IdentifiableBase implements HasAccount {
@ECIndex @Getter @Setter private Long nextBill; @ECIndex @Getter @Setter private Long nextBill;


@ECSearchable @ECField(index=100) @ECSearchable @ECField(index=100)
@Column(nullable=false, length=20)
@Column(nullable=false, length=50)
@Getter @Setter private String nextBillDate; @Getter @Setter private String nextBillDate;
public AccountPlan setNextBillDate() { return setNextBillDate(BILL_START_END_FORMAT.print(getNextBill())); } public AccountPlan setNextBillDate() { return setNextBillDate(BILL_START_END_FORMAT.print(getNextBill())); }




+ 19
- 0
bubble-server/src/main/java/bubble/resources/DebugResource.java View File

@@ -23,7 +23,11 @@ import java.util.function.Predicate;


import static bubble.ApiConstants.DEBUG_ENDPOINT; import static bubble.ApiConstants.DEBUG_ENDPOINT;
import static bubble.cloud.auth.RenderedMessage.filteredInbox; import static bubble.cloud.auth.RenderedMessage.filteredInbox;
import static org.cobbzilla.util.daemon.ZillaRuntime.die;
import static org.cobbzilla.util.daemon.ZillaRuntime.empty;
import static org.cobbzilla.util.http.HttpContentTypes.APPLICATION_JSON; import static org.cobbzilla.util.http.HttpContentTypes.APPLICATION_JSON;
import static org.cobbzilla.util.reflect.ReflectionUtil.forName;
import static org.cobbzilla.util.reflect.ReflectionUtil.instantiate;
import static org.cobbzilla.wizard.resources.ResourceUtil.*; import static org.cobbzilla.wizard.resources.ResourceUtil.*;


@Consumes(APPLICATION_JSON) @Consumes(APPLICATION_JSON)
@@ -74,4 +78,19 @@ public class DebugResource {
); );
} }


@GET @Path("/error")
public Response testError(@Context ContainerRequest ctx,
@QueryParam("type") String type,
@QueryParam("message") String message) {
if (!empty(type)) {
if (!empty(message)) {
return die((Exception) instantiate(forName(type), message));
} else {
return die((Exception) instantiate(type));
}
} else {
return die("testing error catcher");
}
}

} }

+ 3
- 3
bubble-server/src/main/java/bubble/service/account/StandardAccountMessageService.java View File

@@ -211,7 +211,7 @@ public class StandardAccountMessageService implements AccountMessageService {
String json = tokens.get(token); String json = tokens.get(token);
if (json == null) { if (json == null) {
log.warn("captureResponse("+type+"): regular token not found: "+token); log.warn("captureResponse("+type+"): regular token not found: "+token);
throw invalidEx("err.totpToken.invalid");
throw invalidEx("err.approvalToken.invalid");
} }


if (NUMERIC_PATTERN.matcher(json).matches()) { if (NUMERIC_PATTERN.matcher(json).matches()) {
@@ -220,7 +220,7 @@ public class StandardAccountMessageService implements AccountMessageService {
json = tokens.get(numericToken); json = tokens.get(numericToken);
if (json == null) { if (json == null) {
log.warn("captureResponse("+type+"): numeric token not found: "+numericToken+" (token="+token+")"); log.warn("captureResponse("+type+"): numeric token not found: "+numericToken+" (token="+token+")");
throw invalidEx("err.totpToken.invalid");
throw invalidEx("err.approvalToken.invalid");
} }
} }


@@ -238,7 +238,7 @@ public class StandardAccountMessageService implements AccountMessageService {
.setTarget(amc.getMessage().getTarget()); .setTarget(amc.getMessage().getTarget());


if (data != null && !getCompletionHandler(toCreate).validate(toCreate, data)) { if (data != null && !getCompletionHandler(toCreate).validate(toCreate, data)) {
throw invalidEx("err.totpToken.invalid", type+" request was invalid", json(data));
throw invalidEx("err.approvalToken.invalid", type+" request was invalid", json(data));
} }


final AccountMessage message = messageDAO.create(toCreate); final AccountMessage message = messageDAO.create(toCreate);


+ 4
- 0
bubble-server/src/main/resources/message_templates/en_US/server/post_auth/ResourceMessages.properties View File

@@ -575,3 +575,7 @@ err.entity.classInFilename.invalid=Type of object could not be determined from f
err.entity.filenameExtension.invalid=The object file must be a JSON file containing one or more objects, or a Model Archive File (ending in .zip, .tar.gz, or .tgz) containing a manifest and corresponding object files. err.entity.filenameExtension.invalid=The object file must be a JSON file containing one or more objects, or a Model Archive File (ending in .zip, .tar.gz, or .tgz) containing a manifest and corresponding object files.
err.entity.fileZipFormat.invalid=The Model Archive File was not in a readable format err.entity.fileZipFormat.invalid=The Model Archive File was not in a readable format
err.entity.manifest.required=No manifest.json file was found within the Model Archive File err.entity.manifest.required=No manifest.json file was found within the Model Archive File

# special values
msg.nextBillDate.pending=Pending
msg.nextBillDate.paymentsNotEnabled=Payments are not enabled on this system

+ 1
- 1
bubble-server/src/test/resources/models/tests/auth/account_crud.json View File

@@ -140,7 +140,7 @@
}, },
"response": { "response": {
"status": 422, "status": 422,
"check": [ {"condition": "json.has('err.totpToken.invalid')"} ]
"check": [ {"condition": "json.has('err.approvalToken.invalid')"} ]
} }
}, },




+ 1
- 1
bubble-web

@@ -1 +1 @@
Subproject commit 8f2ae033f1c2e0806e19a166bb9d8f20380de5a7
Subproject commit 47415374e2045fce1a62989ac788283585e07f68

+ 1
- 1
utils/cobbzilla-utils

@@ -1 +1 @@
Subproject commit 8c85b0660aaa08e157414cfd2488deaceb1cf3aa
Subproject commit e87008259f29c7fe49d639dca83ca14b354ae268

+ 1
- 1
utils/cobbzilla-wizard

@@ -1 +1 @@
Subproject commit b33512aee3640490a76be3b39bdc2c6c369a9d0f
Subproject commit 8219cbc631ae441036f0621b29272f5adc19651e

Loading…
Cancel
Save