diff options
author | Andrew Arnott <andrewarnott@gmail.com> | 2010-01-08 17:14:28 -0800 |
---|---|---|
committer | Andrew Arnott <andrewarnott@gmail.com> | 2010-01-08 17:14:28 -0800 |
commit | 04731f1c419cba207a680af08bb752d9599d8145 (patch) | |
tree | 685aa2a6b985dbb3cc7e7979e14dd6701135be52 /projecttemplates/MvcRelyingParty/Code/FormsAuthenticationService.cs | |
parent | ac387777ab361e39236df0138f19f4f7dd9da2f5 (diff) | |
parent | 23aa694f3850fcfdc9caad053747d3cf6ff78800 (diff) | |
download | DotNetOpenAuth-04731f1c419cba207a680af08bb752d9599d8145.zip DotNetOpenAuth-04731f1c419cba207a680af08bb752d9599d8145.tar.gz DotNetOpenAuth-04731f1c419cba207a680af08bb752d9599d8145.tar.bz2 |
Merge branch 'master' into master-Dev10
Conflicts:
build.proj
src/DotNetOpenAuth.sln
Diffstat (limited to 'projecttemplates/MvcRelyingParty/Code/FormsAuthenticationService.cs')
-rw-r--r-- | projecttemplates/MvcRelyingParty/Code/FormsAuthenticationService.cs | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/projecttemplates/MvcRelyingParty/Code/FormsAuthenticationService.cs b/projecttemplates/MvcRelyingParty/Code/FormsAuthenticationService.cs new file mode 100644 index 0000000..471c3250 --- /dev/null +++ b/projecttemplates/MvcRelyingParty/Code/FormsAuthenticationService.cs @@ -0,0 +1,36 @@ +namespace MvcRelyingParty { + using System; + using System.Collections.Generic; + using System.Linq; + using System.Web; + using System.Web.Security; + using DotNetOpenAuth.OpenId; + + /// <summary> + /// Forms authentication interface to facilitate login/logout functionality. + /// </summary> + /// <remarks> + /// The FormsAuthentication type is sealed and contains static members, so it is difficult to + /// unit test code that calls its members. The interface and helper class below demonstrate + /// how to create an abstract wrapper around such a type in order to make the AccountController + /// code unit testable. + /// </remarks> + public interface IFormsAuthentication { + void SignIn(Identifier claimedIdentifier, bool createPersistentCookie); + + void SignOut(); + } + + /// <summary> + /// The standard FormsAuthentication behavior to use for the live site. + /// </summary> + public class FormsAuthenticationService : IFormsAuthentication { + public void SignIn(Identifier claimedIdentifier, bool createPersistentCookie) { + FormsAuthentication.SetAuthCookie(claimedIdentifier, createPersistentCookie); + } + + public void SignOut() { + FormsAuthentication.SignOut(); + } + } +} |