Example #1
0
        public ActionResult Authorize()
        {
            var result = OAuthWebSecurity.VerifyAuthentication();

            if (result.IsSuccessful)
            {
                //TODO: grab email and name from results.ExtraData : based on provider
                string name = string.Empty, email = string.Empty;
                IDictionary<string, string> extraData = result.ExtraData;

                switch (result.Provider.ToLower())
                {
                    case "facebook":
                        name = result.UserName;

                        break;
                    case "twitter":
                        name = extraData["name"];

                        break;
                    case "yahoo":
                        email = extraData["email"];
                        name = extraData["fullName"];

                        break;
                    case "google":
                        email = result.UserName;

                        break;
                }

                ExtraData extraUserData = new ExtraData()
                {
                    Id = string.Format("{0}/{1}", result.Provider, result.UserName),
                    Email = email,
                    Name = name
                };

                //create forms authentication ticket
                Response.SetAuthCookie<ExtraData>(string.Format("{0}/{1}", result.Provider, result.UserName), false, extraUserData);

                return RedirectToAction("Index");
            }
            else
            {
                //provide error message

                //take user back to login page
                return RedirectToAction("Login", "Account");
            }
        }
Example #2
0
 public void TearDown()
 {
     polls = null;
     ed = null;
 }
Example #3
0
        public void Setup()
        {
            polls = new List<Poll>()
            {
                {new Poll(){
                    PollNumber = "weruhwe",
                    HashTag = "TestTag",
                    StartDate = DateTime.Today,
                    EndDate = DateTime.Today.AddDays(3),
                     CreatedBy = "facebook/gyochum",
                     CreatedDate = DateTime.Today,
                     IsActive = true,
                     Description = "test poll 1",
                     ImageProvider = ImageProviderTypes.Facebook
                }},
                {new Poll(){
                    PollNumber = "dfdydy",
                    HashTag = "TestTag1",
                    StartDate = DateTime.Today,
                    EndDate = DateTime.Today.AddDays(3),
                     CreatedBy = "twitter/gyochum",
                     CreatedDate = DateTime.Today,
                     IsActive = true,
                     Description = "test poll 2",
                     ImageProvider = ImageProviderTypes.Flickr
                }}
            };

            ed = new ExtraData()
            {
                Id = "gyochum",
                Email = "*****@*****.**",
                Name = "Gary Yochum"
            };
        }
Example #4
0
        public ActionResult Index(ExtraData user)
        {
            PollViewModel model = new PollViewModel();

            if (user != null)
            {
                model.Polls = repository.GetUserPolls(user.Id);
            }

            return View(model);
        }
Example #5
0
        public ActionResult Create(PollViewModel model, ExtraData user)
        {
            if (ModelState.IsValid)
            {
                Poll poll = new Poll();

                poll.CreatedBy = user.Id;
                poll.PollNumber = KeyGenerator.GetUniqueKey();
                poll.CreatedDate = DateTime.Today;

                poll.HashTag = model.Poll.HashTag;
                poll.StartDate = model.Poll.StartDate;
                poll.EndDate = model.Poll.EndDate;
                poll.Description = model.Poll.Description;
                poll.IsActive = model.Poll.IsActive;

                repository.Save(poll);

                if (model.PollHasOptions)
                {
                    return RedirectToAction("Pics", new { id = poll.PollNumber });
                }
                else
                {
                    return RedirectToAction("finish", new { id = poll.PollNumber });
                }
            }

            return View(model);
        }