public ActionResult Register(RegisterLogOnViewModel viewModel) { ValidateModel(viewModel.RegisterViewModel); if (ModelState.IsValid) { var user = new User(AuthenticationType.Custom); Mapper.Map(viewModel.RegisterViewModel, user); _userRepository.Add(user); _unitOfWork.Commit(); //TODO: Send confirmation e-mail } return View("RegisterLogOn", viewModel); }
public ActionResult RegisterLogOn(RegisterLogOnViewModel viewModel, string returnUrl) { if (FacebookWebContext.Current.IsAuthenticated()) { var client = new FacebookWebClient(); dynamic me = client.Get("me"); if (!_userRepository.UserExist(me.username)) { var user = new User(AuthenticationType.Facebook) { Username = me.username }; _userRepository.Add(user); _unitOfWork.Commit(); } FormsAuthentication.SetAuthCookie((string)me.username, false); if (Url.IsLocalUrl(returnUrl) && returnUrl.Length > 1 && returnUrl.StartsWith("/") && !returnUrl.StartsWith("//") && !returnUrl.StartsWith("/\\")) return Redirect(returnUrl); return RedirectToAction("Index", "Home"); } return View("RegisterLogOn", viewModel); }