Permalink
Browse files

Prevent user registration in FeedOnlyMode

  • Loading branch information...
1 parent 65adb24 commit 535f03fcf476871eedb11383dd666d944d8f5afd @deepakaravindr deepakaravindr committed Jun 16, 2014
@@ -119,6 +119,11 @@ public virtual void CreateSession(IOwinContext owinContext, User user)
public virtual async Task<AuthenticatedUser> Register(string username, string emailAddress, Credential credential)
{
+ if (Config.FeedOnlyMode)
+ {
+ throw new FeedOnlyModeException(FeedOnlyModeException.FeedOnlyModeError);
+ }
+
var existingUser = Entities.Users
.FirstOrDefault(u => u.Username == username || u.EmailAddress == emailAddress);
if (existingUser != null)
@@ -0,0 +1,13 @@
+using System;
+
+namespace NuGetGallery.Authentication
+{
+ [Serializable]
+ public class FeedOnlyModeException : Exception
+ {
+ public const string FeedOnlyModeError = "Illegal request! Running on Feed Only mode. User Registration or authentication is disallowed";
+ public FeedOnlyModeException() { }
+
+ public FeedOnlyModeException(string message) : base(message) { }
+ }
+}

0 comments on commit 535f03f

Please sign in to comment.