Creating The Family Page – Part 4, User Accounts–Cleaning up

This will be a short and a bit boring post – it is about cleaning up. Last time we expanded on the IdentyUser Object. I also told that we are not going to use the external log in code (that is the posibility to log in using Facebook, Twitter, Google etc.) The MVC template contains some code for external log in, even though it is not enabled by default. We are going to remove that code, to give us a more clean code base before we make further modifications to account handling.

In the Views folder we can remove the following files:

  • Account/_ExternalLoginListPartial.cshtml
  • Account/_RemoveAccountPartial.cshtml
  • Account/ExternalLoginConfirmation.cshtml
  • Account/ExternalLoginFailure.cshtml

In Account/Manage.cshtml the following div can be removed:

<section id=“externalLogins”> @Html.Action(“RemoveAccountList”) @Html.Partial(“_ExternalLoginsListPartial”, new { Action = “LinkLogin”, ReturnUrl = ViewBag.ReturnUrl })

 

 

In Account/Login.cshtml the followinf div can be removed:

<div class="col-md-4">
    <section id="socialLoginForm">
        @Html.Partial("_ExternalLoginsListPartial", new { Action = "ExternalLogin", ReturnUrl = ViewBag.ReturnUrl })
    </section>
</div>

 

In the Controllers/AccountController.cs file there are a lot methods that is used for handling the connection between social logins and a user account. These methods can be removed (listed in the other they are found the code):

  • Disassociate
  • ExternalLogin
  • ExternalLoginCallback
  • LinkLogin
  • LinkLoginCallback
  • ExternalLoginConfirmation
  • ExternalLoginFailure
  • RemoveAccountList

Remove the field “XsrfKey” that is used by the class “ChallengeResult”. Then remove that class also.

In the Manage method remove this line:

: message == ManageMessageId.RemoveLoginSuccess ? "The external login was removed."

In the method SignInAsync remove this line:

AuthenticationManager.SignOut(DefaultAuthenticationTypes.ExternalCookie);

Lastly we need to look at Models/AccountViewModel.cs – Here we can remove “all” classes related to social log ins:

Remove the ExternalLoginConfirmationViewModel class.

The last thing to do is to look at App_Start/Startup.Auth.cs. Remove all the comments regarding third party login providers. And remove this line:

app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);

 

Conclusion

If you have done everything right you should be able to build and run the web page without errors.

Next time we will look at how to handle forgotten passwords.

Advertisements

About Lund

Owner of iCodeIT, a software consulting company. I am primarily working the .NET development and architecture.
This entry was posted in C#, HTML5, Web and tagged , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s