コード例 #1
0
 public CustomerController()
 {
     Repo = RepoFactory.GetCustomerRepo();
     Security = new Security();
     StatusRepo = RepoFactory.GetChallengeStatusRepo();
     ChalRepo = RepoFactory.GetChallengeRepo();
     TokenRepo = RepoFactory.GetPushServiceTokenRepo();
 }
コード例 #2
0
 public ChallengeController()
 {
     ChalRepo = RepoFactory.GetChallengeRepo();
     BidRepo = RepoFactory.GetChallengeBidRepo();
     StatusRepo = RepoFactory.GetChallengeStatusRepo();
     CustRepo = RepoFactory.GetCustomerRepo();
     Security = new Security();
 }
コード例 #3
0
ファイル: OnboardManager.cs プロジェクト: mchambers/Daremeto
        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;
        }
コード例 #4
0
ファイル: LoginController.cs プロジェクト: mchambers/Daremeto
        // 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;
        }
コード例 #5
0
 public ChallengeStatusController()
 {
     StatusRepo = RepoFactory.GetChallengeStatusRepo();
     ChalRepo = RepoFactory.GetChallengeRepo();
     Security = new Security();
     BidRepo = RepoFactory.GetChallengeBidRepo();
     VoteRepo = RepoFactory.GetChallengeStatusVoteRepo();
     CustRepo = RepoFactory.GetCustomerRepo();
     FriendRepo = RepoFactory.GetFriendshipRepo();
 }
コード例 #6
0
        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);
            }
        }
コード例 #7
0
        private Customer FilterForAudience(Customer c, Security.Audience Audience)
        {
            Customer filtered = new Customer();

            switch (Audience)
            {
                case Security.Audience.Anybody:
                    filtered.FirstName = c.FirstName;
                    filtered.LastName = c.LastName;
                    filtered.AvatarURL = c.AvatarURL;
                    filtered.ID = c.ID;
                    break;
                case Security.Audience.Friends:
                    filtered.FirstName = c.FirstName;
                    filtered.LastName = c.LastName;
                    filtered.AvatarURL = c.AvatarURL;
                    filtered.ID = c.ID;
                    break;
                case Security.Audience.Owner:
                    filtered = c;
                    filtered.Password = null;
                    break;
                case Security.Audience.Users:
                    filtered.FirstName = c.FirstName;
                    filtered.LastName = c.LastName;
                    filtered.AvatarURL = c.AvatarURL;
                    filtered.ID = c.ID;
                    break;
            }

            return filtered;
        }