* Profile.aspx: * ProfileEdition.cs: Fixes the username modification * Book-next.aspx: pollution * NpgsqlMembershipProvider.cs: xmldoc * NpgsqlProfileProvider.cs: use default values from configuration * NpgsqlUserNameProvider.cs: Fixes the username detection * test-domain-TestAPI.config: profile dates must be returned as DateTime * instdbws.sql: The conversion to a valid .Net DateTime requires a credible date time as source value, the null one is not supported. * style.css: Fixes the new notification style * AccountController.cs: Fixes the profile edition. Now using the anti forgery key at login time * Book.aspx: * LocalizedText.resx: * LocalizedText.fr.resx: * CalendarApi.cs: * GoogleController.cs: * LocalizedText.Designer.cs: * LocalizedText.fr.Designer.cs: WIP booking * HomeController.cs: code prettying * Global.asax.cs: Limits the usage of titles in a route to the blog controller * OAuth2.cs: Profile values may be of type DBNull ... * T.cs: All translated strings will be Html encoded, as expected from an html helper * YavscHelpers.cs: A new method to build a javascript string... * App.master: * AppAdmin.master: Notification.body is now a js string literal * NoLogin.master: sync with the true master * Login.aspx: Permits the anti forgery key usage * Estimate.aspx: refactoring * Web.config: Fixes a later commit on the catalog name space * Web.csproj: An ajax helper to notify * ChangePasswordModel.cs: * RegisterClientModel.cs: A regexp for user name * LoginModel.cs: A regexp for user name and password * Profile.cs: A regexp for user name, and profile usage fixes * UserManager.cs: Checks for username availability before trying to modify it * YavscModel.csproj: `ProfileEdition` class addition * ChangeLog: should not be indexed * ChangeLog: useless here * ValidateAjaxAttribute.cs: Fixes usage of HtmlFieldPrefix * BookQuery.cs: Start, end hour and role are required * OtherWebException.cs: useless
76 lines
2.2 KiB
C#
76 lines
2.2 KiB
C#
using System.Configuration;
|
|
using System.Reflection;
|
|
using System;
|
|
|
|
namespace Yavsc.Model.RolesAndMembers
|
|
{
|
|
/// <summary>
|
|
/// User manager.
|
|
/// </summary>
|
|
public static class UserManager
|
|
{
|
|
/// <summary>
|
|
/// Changes the name.
|
|
/// </summary>
|
|
/// <param name="oldName">Old name.</param>
|
|
/// <param name="newName">New name.</param>
|
|
public static void ChangeName (string oldName, string newName) {
|
|
if (!IsAvailable (newName))
|
|
throw new Exception (
|
|
string.Format(
|
|
LocalizedText.DuplicateUserName,
|
|
newName
|
|
));
|
|
Provider.ChangeName (oldName, newName);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Determines if is available the specified name.
|
|
/// </summary>
|
|
/// <returns><c>true</c> if is available the specified name; otherwise, <c>false</c>.</returns>
|
|
/// <param name="name">Name.</param>
|
|
public static bool IsAvailable(string name)
|
|
{
|
|
return Provider.IsNameAvailable (name);
|
|
}
|
|
/// <summary>
|
|
/// The provider.
|
|
/// </summary>
|
|
private static ChangeUserNameProvider provider;
|
|
|
|
/// <summary>
|
|
/// Gets the provider.
|
|
/// </summary>
|
|
/// <value>The provider.</value>
|
|
public static ChangeUserNameProvider Provider {
|
|
get {
|
|
if (provider == null)
|
|
provider = GetProvider ();
|
|
if (provider == null)
|
|
throw new ConfigurationErrorsException ("No username section defined");
|
|
return provider;
|
|
}
|
|
}
|
|
|
|
private static ChangeUserNameProvider GetProvider ()
|
|
{
|
|
DataProviderConfigurationSection config = ConfigurationManager.GetSection ("system.web/userNameManager") as DataProviderConfigurationSection;
|
|
if (config == null)
|
|
throw new ConfigurationErrorsException("The configuration bloc for the username provider was not found");
|
|
ProviderSettings celt=null;
|
|
if (config.DefaultProvider!=null)
|
|
celt = config.Providers[config.DefaultProvider];
|
|
if ((celt == null) && config.Providers!=null)
|
|
if (config.Providers.Count>0)
|
|
celt = config.Providers [0];
|
|
if (celt == null)
|
|
throw new ConfigurationErrorsException("The default username provider was not found");
|
|
ConstructorInfo ci = Type.GetType (celt.Type).GetConstructor (Type.EmptyTypes);
|
|
provider = ci.Invoke (Type.EmptyTypes) as ChangeUserNameProvider;
|
|
provider.Initialize (celt.Name, celt.Parameters);
|
|
return provider;
|
|
}
|
|
}
|
|
|
|
}
|