Skip to content
Browse files

Merge pull request #4 from appharbor/add-cookie-reference-to-identity

Refactored CookieIdentity to take a reference to the AuthenticationCookie object for further use.
  • Loading branch information...
2 parents 106f2d8 + 44caf25 commit 0256255864683a176ad1b4b7d2a663015f9189df @mehrdada mehrdada committed
Showing with 14 additions and 12 deletions.
  1. +1 −1 AppHarbor.Web.Security/AuthenticationCookie.cs
  2. +13 −11 AppHarbor.Web.Security/CookieIdentity.cs
View
2 AppHarbor.Web.Security/AuthenticationCookie.cs
@@ -57,7 +57,7 @@ public AuthenticationCookie(short cookieType, Guid id, bool persistent, string n
public IPrincipal GetPrincipal()
{
- var identity = new CookieIdentity(_name, _tag);
+ var identity = new CookieIdentity(this);
return new GenericPrincipal(identity, _roles);
}
View
24 AppHarbor.Web.Security/CookieIdentity.cs
@@ -9,10 +9,16 @@ namespace AppHarbor.Web.Security
[Serializable]
public class CookieIdentity : MarshalByRefObject, IIdentity
{
- public CookieIdentity(string name, byte[] tag = null)
+ private readonly AuthenticationCookie _cookie;
+
+ public CookieIdentity(AuthenticationCookie cookie)
{
- Name = name;
- Tag = tag;
+ if (cookie == null)
+ {
+ throw new ArgumentNullException("cookie");
+ }
+
+ _cookie = cookie;
}
public bool IsAuthenticated
@@ -33,14 +39,10 @@ public string AuthenticationType
public string Name
{
- get;
- private set;
- }
-
- public byte[] Tag
- {
- get;
- private set;
+ get
+ {
+ return _cookie.Name;
+ }
}
}
}

0 comments on commit 0256255

Please sign in to comment.
Something went wrong with that request. Please try again.