pyc-website
main website for pyc inc.
git clone https://9o.is/git/pyc-website.git
commit fa58a13ec66802d8d4cecc5d6e134185adee044e parent 7530b49fb6db9ac3eea7702862e465f4a45d8648 Author: Jul <jul@9o.is> Date: Mon, 1 Sep 2014 13:10:28 -0400 Phone verification in UserSnippet does not use phoneverified anymore, instead it doesn't save phone number to the model until it is verified. Diffstat:
| M | src/main/scala/inc/pyc/snippet/UserSnip.scala | | | 23 | ++++++++++++----------- |
1 file changed, 12 insertions(+), 11 deletions(-)
diff --git a/src/main/scala/inc/pyc/snippet/UserSnip.scala b/src/main/scala/inc/pyc/snippet/UserSnip.scala @@ -338,9 +338,10 @@ class VerificationSteps extends CurrentUser { } -class PhoneVerification extends AngularCurrentUser { +class PhoneVerification extends AngularCurrentUser with Logger { lazy val smscode = (100000 + new scala.util.Random().nextInt(900000)).toString + var phone = "" def roundTrips: List[RoundTripInfo] = List( "sendsms" -> sendsms _, @@ -351,15 +352,15 @@ class PhoneVerification extends AngularCurrentUser { def sendsms(model: JValue): JValue = serve { user => for { - JString(phone) <- model \ "phone" + JString(newPhone) <- model \ "phone" } yield { val msg = S ? "sms_code_msg" format (user.fname.get, smscode) - if(Twilio.sms(phone, msg)) { - validateAndUpdate { () => - user.phone(phone) - user.phoneverified(false) - } + if (phone == newPhone) { + NgAlert.success + } else if (Twilio.sms(newPhone, msg)) { + phone = newPhone + NgAlert.success } else { NgAlert.danger( Text(S ? "technical_difficulties"), Nil) @@ -375,10 +376,10 @@ class PhoneVerification extends AngularCurrentUser { } yield if(this.smscode == smscode) { - validateAndUpdate { () => - user.purchaseLimit(USAPurchaseLimit.D3k) - user.phoneverified(true) - } + user. + purchaseLimit(USAPurchaseLimit.D3k). + phone(phone) + validateAndUpdate(() => {}) NgAlert.success(("purchaseLimit" -> user.purchaseLimit.get.toString)) } else {