private void CreateAndLoginUser()
 {
     if (!IsValid)
     {
         return;
     }
     var user = new User(userName.Text);
     IAuthenticationManager manager = new AuthenticationIdentityManager(new IdentityStore()).Authentication;
     IdentityResult result = manager.CreateAndSignInExternalUser(Context.GetOwinContext().Authentication, user);
     if (result.Success)
     {
         OpenAuthProviders.RedirectToReturnUrl(Request.QueryString["ReturnUrl"], Response);
     }
     else
     {
         AddErrors(result);
         return;
     }
 }
        private void CreateAndLoginUser()
        {
            if (!IsValid)
            {
                return;
            }
            var user = new User(userName.Text);
            IAuthenticationManager manager = new AuthenticationIdentityManager(new IdentityStore()).Authentication;
            IdentityResult         result  = manager.CreateAndSignInExternalUser(Context.GetOwinContext().Authentication, user);

            if (result.Success)
            {
                OpenAuthProviders.RedirectToReturnUrl(Request.QueryString["ReturnUrl"], Response);
            }
            else
            {
                AddErrors(result);
                return;
            }
        }
        private void CreateAndLoginUser()
        {
            if (!this.IsValid)
            {
                return;
            }
            var user = new User(this.userName.Text);
            IAuthenticationManager manager = new AuthenticationIdentityManager(new IdentityStore(new BooksLibrarySystemContext())).Authentication;
            IdentityResult         result  = manager.CreateAndSignInExternalUser(this.Context.GetOwinContext().Authentication, user);

            if (result.Success)
            {
                BooksLibrarySystem.Web.Account.OpenAuthProviders.RedirectToReturnUrl(this.Request.QueryString["ReturnUrl"], this.Response);
            }
            else
            {
                this.AddErrors(result);
                return;
            }
        }
 private void CreateAndLoginUser()
 {
     if (!IsValid)
     {
         return;
     }
     ApplicationUser user = new ApplicationUser();
     user.UserName = userName.Text;
     var filename = user.UserName + ".jpg";
     user.Avatar = filename;
     IAuthenticationManager manager = new AuthenticationIdentityManager(new IdentityStore(new ApplicationDbContext())).Authentication;
     IdentityResult result = manager.CreateAndSignInExternalUser(Context.GetOwinContext().Authentication, user);
     if (result.Success)
     {
         string urlToDownload = "http://graph.facebook.com/" + user.UserName + "/picture";
         string pathToSave = Server.MapPath("~/Avatar_Files/") + filename;
         WebClient client = new WebClient();
         client.DownloadFile(urlToDownload, pathToSave);
         OpenAuthProviders.RedirectToReturnUrl(Request.QueryString["ReturnUrl"], Response);
     }
     else
     {
         AddErrors(result);
         return;
     }
 }
 private void CreateAndLoginUser()
 {
     if (!this.IsValid)
     {
         return;
     }
     var user = new User(this.userName.Text);
     IAuthenticationManager manager = new AuthenticationIdentityManager(new IdentityStore(new BooksLibrarySystemContext())).Authentication;
     IdentityResult result = manager.CreateAndSignInExternalUser(this.Context.GetOwinContext().Authentication, user);
     if (result.Success)
     {
         BooksLibrarySystem.Web.Account.OpenAuthProviders.RedirectToReturnUrl(this.Request.QueryString["ReturnUrl"], this.Response);
     }
     else
     {
         this.AddErrors(result);
         return;
     }
 }