-
Notifications
You must be signed in to change notification settings - Fork 644
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create derived UserAccountViewModel for User (non-Organization) accou…
…nts (#5295)
- Loading branch information
1 parent
518c019
commit a36fae4
Showing
11 changed files
with
219 additions
and
152 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,114 +1,24 @@ | ||
// Copyright (c) .NET Foundation. All rights reserved. | ||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.ComponentModel.DataAnnotations; | ||
using System.Web.Mvc; | ||
using NuGetGallery.Authentication.Providers; | ||
using NuGetGallery.Infrastructure; | ||
|
||
namespace NuGetGallery | ||
{ | ||
public class AccountViewModel | ||
public abstract class AccountViewModel | ||
{ | ||
public AccountViewModel() | ||
{ | ||
CuratedFeeds = new List<string>(); | ||
ChangePassword = new ChangePasswordViewModel(); | ||
ChangeEmail = new ChangeEmailViewModel(); | ||
CredentialGroups = new Dictionary<CredentialKind, List<CredentialViewModel>>(); | ||
ChangeNotifications = new ChangeNotificationsViewModel(); | ||
} | ||
|
||
public IList<string> CuratedFeeds { get; set; } | ||
public ChangePasswordViewModel ChangePassword { get; set; } | ||
public ChangeEmailViewModel ChangeEmail { get; set; } | ||
public ChangeNotificationsViewModel ChangeNotifications { get; set; } | ||
public int ExpirationInDaysForApiKeyV1 { get; set; } | ||
public bool HasPassword { get; set; } | ||
public string CurrentEmailAddress { get; set; } | ||
public bool HasUnconfirmedEmailAddress { get; set; } | ||
public bool HasConfirmedEmailAddress { get; set; } | ||
public IDictionary<CredentialKind, List<CredentialViewModel>> CredentialGroups { get; set; } | ||
public int SignInCredentialCount { get; set; } | ||
} | ||
|
||
public class ChangeNotificationsViewModel | ||
{ | ||
public bool EmailAllowed { get; set; } | ||
public bool NotifyPackagePushed { get; set; } | ||
} | ||
|
||
public class ChangeEmailViewModel | ||
{ | ||
[Required] | ||
[StringLength(255)] | ||
[Display(Name = "New Email Address")] | ||
[RegularExpression(RegisterViewModel.EmailValidationRegex, ErrorMessage = RegisterViewModel.EmailValidationErrorMessage)] | ||
public string NewEmail { get; set; } | ||
|
||
[Required] | ||
[DataType(DataType.Password)] | ||
[Display(Name = "Password")] | ||
[StringLength(64)] | ||
[AllowHtml] | ||
public string Password { get; set; } | ||
} | ||
|
||
public class ChangePasswordViewModel | ||
{ | ||
[Required] | ||
[Display(Name = "Enable Password Login")] | ||
public bool EnablePasswordLogin { get; set; } | ||
public ChangeEmailViewModel ChangeEmail { get; set; } | ||
|
||
[Required] | ||
[Display(Name = "Current Password")] | ||
[AllowHtml] | ||
public string OldPassword { get; set; } | ||
public ChangeNotificationsViewModel ChangeNotifications { get; set; } | ||
|
||
[Required] | ||
[Display(Name = "New Password")] | ||
[PasswordValidation] | ||
[AllowHtml] | ||
public string NewPassword { get; set; } | ||
public bool HasPassword { get; set; } | ||
|
||
[Required] | ||
[Display(Name = "Verify Password")] | ||
[PasswordValidation] | ||
[AllowHtml] | ||
public string VerifyPassword { get; set; } | ||
} | ||
|
||
public class CredentialViewModel | ||
{ | ||
public int Key { get; set; } | ||
public string Type { get; set; } | ||
public string TypeCaption { get; set; } | ||
public string Identity { get; set; } | ||
public DateTime Created { get; set; } | ||
public DateTime? Expires { get; set; } | ||
public CredentialKind Kind { get; set; } | ||
public AuthenticatorUI AuthUI { get; set; } | ||
public string Description { get; set; } | ||
public List<ScopeViewModel> Scopes { get; set; } | ||
public bool HasExpired { get; set; } | ||
public string Value { get; set; } | ||
public TimeSpan? ExpirationDuration { get; set; } | ||
public string CurrentEmailAddress { get; set; } | ||
|
||
public bool IsNonScopedApiKey | ||
{ | ||
get | ||
{ | ||
return CredentialTypes.IsApiKey(Type) && !Scopes.AnySafe(); | ||
} | ||
} | ||
} | ||
public bool HasUnconfirmedEmailAddress { get; set; } | ||
|
||
public enum CredentialKind | ||
{ | ||
Password, | ||
Token, | ||
External | ||
public bool HasConfirmedEmailAddress { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// Copyright (c) .NET Foundation. All rights reserved. | ||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
||
using System.ComponentModel.DataAnnotations; | ||
using System.Web.Mvc; | ||
|
||
namespace NuGetGallery | ||
{ | ||
public class ChangeEmailViewModel | ||
{ | ||
[Required] | ||
[StringLength(255)] | ||
[Display(Name = "New Email Address")] | ||
[RegularExpression(RegisterViewModel.EmailValidationRegex, ErrorMessage = RegisterViewModel.EmailValidationErrorMessage)] | ||
public string NewEmail { get; set; } | ||
|
||
[Required] | ||
[DataType(DataType.Password)] | ||
[Display(Name = "Password")] | ||
[StringLength(64)] | ||
[AllowHtml] | ||
public string Password { get; set; } | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
src/NuGetGallery/ViewModels/ChangeNotificationsViewModel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// Copyright (c) .NET Foundation. All rights reserved. | ||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
||
namespace NuGetGallery | ||
{ | ||
public class ChangeNotificationsViewModel | ||
{ | ||
public bool EmailAllowed { get; set; } | ||
|
||
public bool NotifyPackagePushed { get; set; } | ||
} | ||
} |
Oops, something went wrong.