浏览代码

add terms to account

tags/v0.8.0
Jonathan Cobb 4 年前
父节点
当前提交
b13673c26e
共有 23 个文件被更改,包括 72 次插入11 次删除
  1. +13
    -6
      bubble-server/src/main/java/bubble/model/account/Account.java
  2. +3
    -0
      bubble-server/src/main/java/bubble/model/account/AccountRegistration.java
  3. +5
    -0
      bubble-server/src/main/java/bubble/resources/account/AccountsResource.java
  4. +6
    -0
      bubble-server/src/main/java/bubble/resources/account/AuthResource.java
  5. +1
    -1
      bubble-server/src/main/resources/META-INF/bubble/bubble.properties
  6. +2
    -0
      bubble-server/src/main/resources/message_templates/en_US/server/pre_auth/ResourceMessages.properties
  7. +1
    -0
      bubble-server/src/test/resources/models/include/new_account.json
  8. +1
    -0
      bubble-server/src/test/resources/models/include/new_bubble.json
  9. +1
    -0
      bubble-server/src/test/resources/models/include/referral_signup.json
  10. +24
    -3
      bubble-server/src/test/resources/models/tests/auth/account_registration.json
  11. +1
    -0
      bubble-server/src/test/resources/models/tests/live/backup_and_restore.json
  12. +2
    -0
      bubble-server/src/test/resources/models/tests/network/simple_network.json
  13. +1
    -0
      bubble-server/src/test/resources/models/tests/payment/pay_code.json
  14. +1
    -0
      bubble-server/src/test/resources/models/tests/payment/pay_credit.json
  15. +1
    -0
      bubble-server/src/test/resources/models/tests/payment/pay_credit_refund_and_restart.json
  16. +1
    -0
      bubble-server/src/test/resources/models/tests/payment/pay_free.json
  17. +1
    -0
      bubble-server/src/test/resources/models/tests/payment/plan_apps.json
  18. +1
    -0
      bubble-server/src/test/resources/models/tests/payment/recurring_billing.json
  19. +1
    -0
      bubble-server/src/test/resources/models/tests/promo/account_credit.json
  20. +1
    -0
      bubble-server/src/test/resources/models/tests/promo/first_month_free.json
  21. +1
    -0
      bubble-server/src/test/resources/models/tests/promo/multi_promo.json
  22. +2
    -0
      bubble-server/src/test/resources/models/tests/promo/referral_month_free.json
  23. +1
    -1
      bubble-web

+ 13
- 6
bubble-server/src/main/java/bubble/model/account/Account.java 查看文件

@@ -23,8 +23,6 @@ import org.cobbzilla.util.collection.ArrayUtil;
import org.cobbzilla.wizard.filters.auth.TokenPrincipal;
import org.cobbzilla.wizard.model.HashedPassword;
import org.cobbzilla.wizard.model.Identifiable;
import org.cobbzilla.wizard.model.entityconfig.EntityFieldMode;
import org.cobbzilla.wizard.model.entityconfig.EntityFieldType;
import org.cobbzilla.wizard.model.entityconfig.IdentifiableBaseParentEntity;
import org.cobbzilla.wizard.model.entityconfig.annotations.*;
import org.cobbzilla.wizard.model.search.SqlViewSearchResult;
@@ -52,6 +50,8 @@ import static org.cobbzilla.util.system.Sleep.sleep;
import static org.cobbzilla.util.time.TimeUtil.formatDuration;
import static org.cobbzilla.wizard.model.crypto.EncryptedTypes.ENCRYPTED_STRING;
import static org.cobbzilla.wizard.model.crypto.EncryptedTypes.ENC_PAD;
import static org.cobbzilla.wizard.model.entityconfig.EntityFieldMode.readOnly;
import static org.cobbzilla.wizard.model.entityconfig.EntityFieldType.epoch_time;
import static org.cobbzilla.wizard.model.entityconfig.annotations.ECForeignKeySearchDepth.none;
import static org.cobbzilla.wizard.resources.ResourceUtil.invalidEx;

@@ -82,7 +82,7 @@ public class Account extends IdentifiableBaseParentEntity implements TokenPrinci

public static final String[] UPDATE_FIELDS = {"url", "description", "autoUpdatePolicy"};
public static final String[] ADMIN_UPDATE_FIELDS = ArrayUtil.append(UPDATE_FIELDS, "suspended", "admin");
public static final String[] CREATE_FIELDS = ArrayUtil.append(ADMIN_UPDATE_FIELDS, "name", "referralCode");
public static final String[] CREATE_FIELDS = ArrayUtil.append(ADMIN_UPDATE_FIELDS, "name", "referralCode", "termsAgreed");

public static final String ROOT_USERNAME = "root";
public static final int NAME_MIN_LENGTH = 4;
@@ -115,7 +115,7 @@ public class Account extends IdentifiableBaseParentEntity implements TokenPrinci

// make this updatable if we ever want accounts to be able to change parents
// there might be a lot more involved in that action though (read-only parent objects that will no longer be visible, must be copied in?)
@ECForeignKey(entity=Account.class) @ECField(index=20, mode=EntityFieldMode.readOnly)
@ECForeignKey(entity=Account.class) @ECField(index=20, mode=readOnly)
@Column(length=UUID_MAXLEN, updatable=false)
@Getter @Setter private String parent;
public boolean hasParent () { return parent != null; }
@@ -148,15 +148,20 @@ public class Account extends IdentifiableBaseParentEntity implements TokenPrinci
@Getter @Setter private Boolean locked = false;
public boolean locked () { return bool(locked); }

@ECIndex @ECSearchable @ECField(index=90, type=EntityFieldType.epoch_time, mode=EntityFieldMode.readOnly)
@ECIndex @ECSearchable @ECField(index=90, type=epoch_time, mode=readOnly)
@Getter @Setter private Long deleted;
public boolean deleted () { return deleted != null; }
public Account setDeleted() { return setDeleted(now()); }

@ECIndex @ECSearchable @ECField(index=100, type=EntityFieldType.epoch_time, mode=EntityFieldMode.readOnly)
@ECIndex @ECSearchable @ECField(index=100, type=epoch_time, mode=readOnly)
@Getter @Setter private Long lastLogin;
public Account setLastLogin() { return setLastLogin(now()); }

@ECIndex @ECSearchable @ECField(index=110, type=epoch_time, mode=readOnly)
@Column(nullable=false)
@Getter @Setter private Long termsAgreed;
public Account setTermsAgreed() { return setTermsAgreed(now()); }

@JsonIgnore @Embedded @Getter @Setter private HashedPassword hashedPassword;

public static final int MIN_PASSWORD_LENGTH = 8;
@@ -221,11 +226,13 @@ public class Account extends IdentifiableBaseParentEntity implements TokenPrinci
setAdmin(true);
setDescription(request.hasDescription() ? request.getDescription() : "root user");
setLocale(getDEFAULT_LOCALE());
setTermsAgreed(now());
}

public Account(AccountRegistration request) {
setName(request.getName());
setHashedPassword(new HashedPassword(request.getPassword()));
setTermsAgreed(request.getTermsAgreed());
}

@Override public Identifiable update(Identifiable other) {


+ 3
- 0
bubble-server/src/main/java/bubble/model/account/AccountRegistration.java 查看文件

@@ -15,4 +15,7 @@ public class AccountRegistration extends Account {
@Getter @Setter private AccountContact contact;
public boolean hasContact () { return contact != null; }

@Getter @Setter private Boolean agreeToTerms = null;
public boolean agreeToTerms () { return agreeToTerms != null && agreeToTerms; }

}

+ 5
- 0
bubble-server/src/main/java/bubble/resources/account/AccountsResource.java 查看文件

@@ -100,6 +100,11 @@ public class AccountsResource {
} else {
request.getContact().validate(errors);
}
if (!request.agreeToTerms()) {
errors.addViolation("err.terms.required", "You must agree to the legal terms to use this service");
} else {
request.setTermsAgreed();
}
if (errors.isInvalid()) return invalid(errors);

final String parentUuid;


+ 6
- 0
bubble-server/src/main/java/bubble/resources/account/AuthResource.java 查看文件

@@ -206,6 +206,12 @@ public class AuthResource {
request.getContact().validate(errors);
}

if (!request.agreeToTerms()) {
errors.addViolation("err.terms.required", "You must agree to the legal terms to use this service");
} else {
request.setTermsAgreed();
}

String currency = null;
if (configuration.paymentsEnabled()) {
currency = currencyForLocale(request.getLocale(), getDEFAULT_LOCALE());


+ 1
- 1
bubble-server/src/main/resources/META-INF/bubble/bubble.properties 查看文件

@@ -1 +1 @@
bubble.version=0.7.2
bubble.version=0.8.0

+ 2
- 0
bubble-server/src/main/resources/message_templates/en_US/server/pre_auth/ResourceMessages.properties 查看文件

@@ -178,6 +178,7 @@ err.email.invalid=Email is invalid
err.phone.required=SMS Phone is required
err.phone.invalid=SMS Phone is invalid
err.phone.length=SMS Phone is too long
err.terms.required=You must agree to the legal terms to use this service
err.country.invalid=Country is invalid
err.parent.notFound=Parent account does not exist
err.accountInit.timeout=Timeout initializing new account
@@ -241,6 +242,7 @@ field_label_contactType=Contact Type
field_label_email=Email
field_label_promoCode=Promo Code
field_label_sms=SMS Phone
field_label_agreeToTerms=By checking this box, you agree to our <a target="_blank" rel="noopener" href="https://bubblev.com/pages/privacy">Privacy Policy</a> and <a target="_blank" rel="noopener" href="https://bubblev.com/pages/terms">Terms of Service</a>.
field_label_receiveInformationalMessages=Receive informational messages about your Bubble
field_label_receivePromotionalMessages=Receive news about Bubble, including new releases and new features
button_label_login=Login


+ 1
- 0
bubble-server/src/test/resources/models/include/new_account.json 查看文件

@@ -24,6 +24,7 @@
"name": "<<username>>",
"password": "<<password>>",
"admin": "<<admin>>",
"agreeToTerms": true,
"contact": {"type": "email", "info": "<<email>>"}
}
},


+ 1
- 0
bubble-server/src/test/resources/models/include/new_bubble.json 查看文件

@@ -67,6 +67,7 @@
"entity": {
"name": "<<username>>",
"password": "<<password>>",
"agreeToTerms": true,
"contact": {"type": "email", "info": "<<email>>"}
}
},


+ 1
- 0
bubble-server/src/test/resources/models/include/referral_signup.json 查看文件

@@ -21,6 +21,7 @@
"entity": {
"name": "<<referredName>>",
"password": "password1!",
"agreeToTerms": true,
"contact": {"type": "email", "info": "<<referredName>>@example.com"},
"promoCode": "<<referralCode>>"
}


+ 24
- 3
bubble-server/src/test/resources/models/tests/auth/account_registration.json 查看文件

@@ -9,7 +9,7 @@
},

{
"comment": "new session, register a user account",
"comment": "new session, register a user account, do not agree to terms, fails",
"request": {
"session": "new",
"uri": "auth/register",
@@ -19,6 +19,24 @@
"contact": { "type": "email", "info": "user-{{rand 5}}@example.com" }
}
},
"response": {
"status": 422,
"check": [ {"condition": "json.has('err.terms.required')"} ]
}
},

{
"comment": "new session, register a user account, agree to terms, succeeds",
"request": {
"session": "new",
"uri": "auth/register",
"entity": {
"name": "foobar1",
"password": "password1!",
"agreeToTerms": true,
"contact": { "type": "email", "info": "user-{{rand 5}}@example.com" }
}
},
"response": {
"sessionName": "user1session",
"session": "token"
@@ -141,7 +159,8 @@
"uri": "auth/register",
"entity": {
"name": "foobar1",
"password": "password1!"
"password": "password1!",
"agreeToTerms": true
}
},
"response": {
@@ -184,7 +203,8 @@
"uri": "auth/register",
"entity": {
"name": "foobar1",
"password": "password1!"
"password": "password1!",
"agreeToTerms": true
}
},
"response": {
@@ -201,6 +221,7 @@
"entity": {
"name": "foobar2",
"password": "password2!",
"agreeToTerms": true,
"contact": { "type": "email", "info": "user2-{{rand 5}}@example.com" }
}
},


+ 1
- 0
bubble-server/src/test/resources/models/tests/live/backup_and_restore.json 查看文件

@@ -101,6 +101,7 @@
"entity": {
"name": "user1",
"password": "password1!",
"agreeToTerms": true,
"contact": {"type": "email", "info": "user-{{rand 5}}@example.com"}
}
},


+ 2
- 0
bubble-server/src/test/resources/models/tests/network/simple_network.json 查看文件

@@ -15,6 +15,7 @@
"entity": {
"name": "test_user_simple_net",
"password": "password1!",
"agreeToTerms": true,
"contact": {"type": "email", "info": "test-user@example.com"}
}
},
@@ -342,6 +343,7 @@
"entity": {
"name": "bubble_user",
"password": "password1!",
"agreeToTerms": true,
"contact": {"type": "email", "info": "bubble-user@example.com"}
}
}


+ 1
- 0
bubble-server/src/test/resources/models/tests/payment/pay_code.json 查看文件

@@ -7,6 +7,7 @@
"entity": {
"name": "test_user_code",
"password": "password1!",
"agreeToTerms": true,
"contact": {"type": "email", "info": "test-user@example.com"}
}
}


+ 1
- 0
bubble-server/src/test/resources/models/tests/payment/pay_credit.json 查看文件

@@ -7,6 +7,7 @@
"entity": {
"name": "test_user_credit",
"password": "password1!",
"agreeToTerms": true,
"contact": {"type": "email", "info": "test-user@example.com"}
}
}


+ 1
- 0
bubble-server/src/test/resources/models/tests/payment/pay_credit_refund_and_restart.json 查看文件

@@ -7,6 +7,7 @@
"entity": {
"name": "test_user_credit_refund_restart",
"password": "password1!",
"agreeToTerms": true,
"contact": {"type": "email", "info": "test-user@example.com"}
}
}


+ 1
- 0
bubble-server/src/test/resources/models/tests/payment/pay_free.json 查看文件

@@ -7,6 +7,7 @@
"entity": {
"name": "test_user_free",
"password": "password1!",
"agreeToTerms": true,
"contact": {"type": "email", "info": "test-user@example.com"}
}
}


+ 1
- 0
bubble-server/src/test/resources/models/tests/payment/plan_apps.json 查看文件

@@ -7,6 +7,7 @@
"entity": {
"name": "test_plan_apps_user",
"password": "password1!",
"agreeToTerms": true,
"contact": {"type": "email", "info": "test-user@example.com"}
}
}


+ 1
- 0
bubble-server/src/test/resources/models/tests/payment/recurring_billing.json 查看文件

@@ -7,6 +7,7 @@
"entity": {
"name": "test_user_recurring",
"password": "password1!",
"agreeToTerms": true,
"contact": {"type": "email", "info": "test-user@example.com"}
}
}


+ 1
- 0
bubble-server/src/test/resources/models/tests/promo/account_credit.json 查看文件

@@ -7,6 +7,7 @@
"entity": {
"name": "test_user_small_promo",
"password": "password1!",
"agreeToTerms": true,
"contact": {"type": "email", "info": "test_user_small_promo@example.com"}
}
},


+ 1
- 0
bubble-server/src/test/resources/models/tests/promo/first_month_free.json 查看文件

@@ -7,6 +7,7 @@
"entity": {
"name": "test_user_1mo_free",
"password": "password1!",
"agreeToTerms": true,
"contact": {"type": "email", "info": "test_user_1mo_free@example.com"}
}
},


+ 1
- 0
bubble-server/src/test/resources/models/tests/promo/multi_promo.json 查看文件

@@ -7,6 +7,7 @@
"entity": {
"name": "test_user_referring_multi",
"password": "password1!",
"agreeToTerms": true,
"contact": {"type": "email", "info": "test_user_referring_multi@example.com"}
}
},


+ 2
- 0
bubble-server/src/test/resources/models/tests/promo/referral_month_free.json 查看文件

@@ -7,6 +7,7 @@
"entity": {
"name": "test_user_referring_free",
"password": "password1!",
"agreeToTerms": true,
"contact": {"type": "email", "info": "test_user_referring_free@example.com"}
}
}
@@ -103,6 +104,7 @@
"entity": {
"name": "test_user_referred_free",
"password": "password1!",
"agreeToTerms": true,
"contact": {"type": "email", "info": "test_user_referred_free@example.com"},
"promoCode": "{{referralCodes.[0].name}}"
}


+ 1
- 1
bubble-web

@@ -1 +1 @@
Subproject commit 3713e3ef8cc63e1d311ec42ba84083afe4366cd8
Subproject commit ace5fcc0889d4b89af2686c88f783050ff913aad

正在加载...
取消
保存