public bool Complete(OnboardToken t) { ICustomerRepository custRepo = RepoFactory.GetCustomerRepo(); Customer c = custRepo.GetWithID(t.CustomerID); Customer custCheck = custRepo.GetWithEmailAddress(t.EmailAddress.ToLower().Trim()); c.Type = (int)Customer.TypeCodes.Default; // check for email address in use if (custCheck != null && custCheck.Type != (int)Customer.TypeCodes.Unclaimed) { Security s = new Security(); Authorization a = s.AuthorizeCustomer(new Login { EmailAddress = t.EmailAddress, Password = t.Password }); if (a != null && a.Valid) { System.Diagnostics.Trace.WriteLine("Moving challenges from " + c.ID.ToString() + " to " + a.CustomerID.ToString()); // zomg u're real custRepo.AddForeignNetworkForCustomer(a.CustomerID, t.ForeignUserID, (Customer.ForeignUserTypes)t.AccountType); // we need to collapse the unclaimed account into the one we just found. RepoFactory.GetChallengeRepo().MoveChallengesToCustomer(c.ID, a.CustomerID); RepoFactory.GetChallengeStatusRepo().MoveStatusesToNewCustomer(c.ID, a.CustomerID); // now that we've moved the challenges, delete the original customer custRepo.Remove(c.ID); return true; } else return false; } else if (custCheck != null && custCheck.Type == (int)Customer.TypeCodes.Unclaimed) { c = custCheck; c.Type = (int)Customer.TypeCodes.IncompleteOnboard; } c.EmailAddress = t.EmailAddress.ToLower().Trim(); c.FirstName = t.FirstName; c.LastName = t.LastName; c.Password = t.Password; custRepo.Update(c); custRepo.AddForeignNetworkForCustomer(c.ID, t.ForeignUserID, (Customer.ForeignUserTypes)t.AccountType); if (t.ChallengeID != 0) { DareManager dmgr = new DareManager(); dmgr.Accept(t.ChallengeID, c.ID); } return true; }
// POST /api/<controller> public Authorization Post(Login value) { Security s=new Security(); Authorization a = s.AuthorizeCustomer(value); if (a == null) throw new HttpResponseException("Invalid credentials", System.Net.HttpStatusCode.Forbidden); return a; }
public ActionResult BillingOnboard(OnboardToken token) { OnboardToken retrievedToken = RepoFactory.GetOnboardTokenRepo().Get(token.VerificationString); Customer cust = RepoFactory.GetCustomerRepo().GetWithID(retrievedToken.CustomerID); // hardcode stripe for now, sucka StripeClient client = new StripeClient("LB3kUwdhiUlPlNl1UYW52NLn4q88QsFT"); Stripe.CreditCardToken ccToken = new Stripe.CreditCardToken(token.BillingID); var stripeCustomer = client.CreateCustomer(ccToken, email: cust.EmailAddress); cust.BillingType = (int)BillingSystem.BillingProcessorFactory.SupportedBillingProcessor.Stripe; cust.BillingID = stripeCustomer.GetProperty("ID").ToString(); RepoFactory.GetCustomerRepo().Update(cust); CustomerController.CustomerSignupResult result = new CustomerController.CustomerSignupResult(); result.Result = CustomerController.CustomerSignupResult.ResultCode.Success; result.Customer = cust; if (retrievedToken.ChallengeID != 0) { Security s = new Security(); Authorization a=s.AuthorizeCustomer(new Login { EmailAddress = cust.EmailAddress, Password = cust.Password }); return Redirect("http://dareme.to/authorize?id="+a.CustomerID.ToString()+"&session_token="+a.Token+"&dare=" + retrievedToken.ChallengeID.ToString()); } else { return View("SignupComplete", result); } }