Permalink
Browse files

refactor check on Join method to make it more generic

  • Loading branch information...
1 parent ef29883 commit c15e3a9803fc73068c21eb47a3ca8660a6665540 woloski committed Jul 11, 2012
View
@@ -74,15 +74,8 @@ public bool Join()
return false;
}
- // Migrate all users to use new auth
- if (!String.IsNullOrEmpty(_settings.AuthApiKey) &&
- String.IsNullOrEmpty(user.Identity))
- {
- return false;
- }
-
- if (!String.IsNullOrEmpty(ConfigurationManager.AppSettings["fedauth.identityProviderUrl"]) &&
- String.IsNullOrEmpty(user.Identity))
+ // Migrate all users to use the non-default auth (janrain or fedauth)
+ if (_settings.AllowNullIdentity(user))
{
return false;
}
View
@@ -830,6 +830,7 @@
<Compile Include="Migrations\201206201924146_RoomWelcome.Designer.cs">
<DependentUpon>201206201924146_RoomWelcome.cs</DependentUpon>
</Compile>
+ <Compile Include="Services\ApplicationSettingsExtensions.cs" />
<Compile Include="WebApi\Model\ErrorModel.cs" />
<Compile Include="Infrastructure\HttpRequestExtensions.cs" />
<Compile Include="WebApi\MessagesController.cs" />
@@ -36,5 +36,14 @@ public string AuthAppId
return ConfigurationManager.AppSettings["auth.appId"];
}
}
+
+
+ public string FedAuthIdentityProviderUrl
+ {
+ get
+ {
+ return ConfigurationManager.AppSettings["fedauth.identityProviderUrl"];
+ }
+ }
}
}
@@ -0,0 +1,17 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Web;
+using JabbR.Models;
+
+namespace JabbR.Services
+{
+ public static class ApplicationSettingsExtensions
+ {
+ public static bool AllowNullIdentity(this IApplicationSettings settings, ChatUser user)
+ {
+ return String.IsNullOrEmpty(user.Identity) &&
+ (!String.IsNullOrEmpty(settings.AuthApiKey) || !String.IsNullOrEmpty(settings.FedAuthIdentityProviderUrl));
+ }
+ }
+}
@@ -9,5 +9,7 @@ public interface IApplicationSettings
string DefaultAdminPassword { get; }
string AuthAppId { get; }
+
+ string FedAuthIdentityProviderUrl { get; }
}
}

0 comments on commit c15e3a9

Please sign in to comment.