1.8.8.Social Logins

  • 1.Enable SSL

    • Enable SSL

    • Copy https URL to project URL

  • 2.Register a key and secret from developer facebook

  • 3.Modify App_Start\Startup.Auth.cs

      app.UseFacebookAuthentication(
                 appId: "",
                 appSecret: "");
  • 4.Modify AccountController

    public async Task<ActionResult> ExternalLoginConfirmation(ExternalLoginConfirmationViewModel model, string returnUrl)
          {
              if (User.Identity.IsAuthenticated)
              {
                  return RedirectToAction("Index", "Manage");
              }
    
              if (ModelState.IsValid)
              {
                  // Get the information about the user from the external login provider
                  var info = await AuthenticationManager.GetExternalLoginInfoAsync();
                  if (info == null)
                  {
                      return View("ExternalLoginFailure");
                  }
                  var user = new ApplicationUser {
                      UserName = model.Email,
                      Email = model.Email,
                      DrivingLicense = model.DrivingLicense
                  };
  • 5.Modify AccountViewModel

    public class ExternalLoginConfirmationViewModel
      {
          [Required]
          [Display(Name = "Email")]
          public string Email { get; set; }
    
          [Required]
          [Display(Name = "Driving License")]
          public string DrivingLicense { get; set; }
      }
  • 6.Modify ExternalLoginConfirmation.cshtml

    <div class="form-group">
          @Html.LabelFor(m => m.DrivingLicense, new { @class = "col-md-2 control-label" })
          <div class="col-md-10">
              @Html.TextBoxFor(m => m.DrivingLicense, new { @class = "form-control" })
          </div>
      </div>

Last updated

Was this helpful?