public async Task<ActionResult> GoogleLoginCallback(string returnUrl) {
            ExternalLoginInfo loginInfo = await AuthManager.GetExternalLoginInfoAsync();
            AppUser user = await UserManager.FindAsync(loginInfo.Login);
            if (user == null) {
                user = new AppUser {
                    Email = loginInfo.Email,
                    UserName = loginInfo.DefaultUserName,
                    City = Cities.LONDON, Country = Countries.UK
                };
                IdentityResult result = await UserManager.CreateAsync(user);
                if (!result.Succeeded) {
                    return View("Error", result.Errors);
                } else {
                    result = await UserManager.AddLoginAsync(user.Id, loginInfo.Login);
                    if (!result.Succeeded) {
                        return View("Error", result.Errors);
                    }
                }
            }

            ClaimsIdentity ident = await UserManager.CreateIdentityAsync(user,
                DefaultAuthenticationTypes.ApplicationCookie);
            ident.AddClaims(loginInfo.ExternalIdentity.Claims);
            AuthManager.SignIn(new AuthenticationProperties {
                IsPersistent = false
            }, ident);

            return Redirect(returnUrl ?? "/");
        }
 public async Task<ActionResult> Create(CreateModel model) {
     if (ModelState.IsValid) {
         AppUser user = new AppUser { UserName = model.Name, Email = model.Email };
         IdentityResult result = await UserManager.CreateAsync(user,
             model.Password);
         if (result.Succeeded) {
             return RedirectToAction("Index");
         } else {
             AddErrorsFromResult(result);
         }
     }
     return View(model);
 }