Skip to content
This repository has been archived by the owner on Oct 19, 2022. It is now read-only.

Commit

Permalink
Merge pull request #28 from stormpath/fix-27
Browse files Browse the repository at this point in the history
Restore IAccount sanitization logic
  • Loading branch information
nbarbettini authored Aug 26, 2016
2 parents 0590cd0 + 526264f commit 4bcea65
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
23 changes: 23 additions & 0 deletions src/Stormpath.Owin.Middleware/Internal/ResponseSanitizer{T}.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
// </copyright>

using System;
using Stormpath.SDK.Account;
using Stormpath.SDK.Oauth;

namespace Stormpath.Owin.Middleware.Internal
Expand All @@ -23,6 +24,11 @@ internal sealed class ResponseSanitizer<T>
{
public object Sanitize(T model)
{
if (typeof(T) == typeof(IAccount))
{
return SanitizeAccount((IAccount)model);
}

if (typeof(T) == typeof(IOauthGrantAuthenticationResult))
{
return SanitizeToken((IOauthGrantAuthenticationResult)model);
Expand All @@ -31,6 +37,23 @@ public object Sanitize(T model)
throw new NotImplementedException($"Cannot sanitize type '{typeof(T).Name}'");
}

private object SanitizeAccount(IAccount account)
{
return new
{
Href = account.Href,
Username = account.Username,
ModifiedAt = account.ModifiedAt,
Status = account.Status.ToString(),
CreatedAt = account.CreatedAt,
Email = account.Email,
MiddleName = account.MiddleName,
Surname = account.Surname,
GivenName = account.GivenName,
FullName = account.FullName
};
}

private static object SanitizeToken(IOauthGrantAuthenticationResult tokenResult)
{
return new
Expand Down
2 changes: 1 addition & 1 deletion src/Stormpath.Owin.Middleware/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,5 @@
"tooling": {
"defaultNamespace": "Stormpath.Owin.Middleware"
},
"version": "1.4.0"
"version": "1.4.1"
}

0 comments on commit 4bcea65

Please sign in to comment.