Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Prevent user registration in FeedOnlyMode

  • Loading branch information...
commit 535f03fcf476871eedb11383dd666d944d8f5afd 1 parent 65adb24
@deepakaravindr deepakaravindr authored
View
5 src/NuGetGallery/Authentication/AuthenticationService.cs
@@ -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)
View
13 src/NuGetGallery/Authentication/FeedOnlyModeException.cs
@@ -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) { }
+ }
+}
Please sign in to comment.
Something went wrong with that request. Please try again.