コード例 #1
0
        public Authorization AuthorizeCustomer(Login l)
        {
            ICustomerRepository repo = Models.RepoFactory.GetCustomerRepo();

            Customer c=null;

            if (!l.EmailAddress.Equals(""))
            {
                c = repo.GetWithEmailAddress(l.EmailAddress);
                if (c == null)
                    return null;

                if (!l.Password.ToUpper().Equals(c.Password.ToUpper()))
                    return null;
            }
            else
            {
                Facebook.FacebookClient fb = new Facebook.FacebookClient();

                c = repo.GetWithFacebookID(l.FacebookID);
                if (c == null)
                    return null;

                fb.AccessToken = l.FacebookToken;

                try
                {
                    dynamic me = fb.Get("me");

                    if (me == null || me.first_name.Equals(""))
                        return null;
                }
                catch (Exception e)
                {
                    return null;
                }

                c.FacebookAccessToken = l.FacebookToken;
                repo.Update(c); // store the newest Facebook access token since it may have changed
            }

            Authorization a = new Authorization("test" + System.DateTime.Now.Ticks.ToString());
            a.CustomerID = c.ID;
            a.EmailAddress = c.EmailAddress;
            a.Type = c.Type;

            IAuthorizationRepository authRepo = new AuthorizationRepository();
            authRepo.Add(a); // store the auth token in the repo

            return a;
        }
コード例 #2
0
        //[HttpPost]
        //public void Claim(
        /*
        private void CoreHandleFacebookSignup(Customer newCustomer)
        {
            Customer tryFB = Repo.GetWithFacebookID(newCustomer.FacebookUserID);

            // if we have an unclaimed FB user, claim them now
            // rather than making a new account.
            if (tryFB != null && tryFB.FacebookUserID == newCustomer.FacebookUserID)
            {
                tryFB.Type = (int)Customer.TypeCodes.Default;
                tryFB.FacebookAccessToken = newCustomer.FacebookAccessToken;
                tryFB.FacebookExpires = newCustomer.FacebookExpires;

                Repo.Update(tryFB);
            }
            else
            {
                Repo.Add(newCustomer);
            }

        }*/
        private void CoreCreateSendVerificationEmail(Customer newCustomer)
        {
            AuthorizationRepository authRepo = new AuthorizationRepository();

            Authorization a = new Authorization("verify-" + Guid.NewGuid().ToString());
            a.Valid = false;
            a.EmailAddress = newCustomer.EmailAddress;
            a.CustomerID = newCustomer.ID;

            authRepo.Add(a);

            String authUrl = "http://dareme.to/verify/" + a.Token;
        }