本文整理汇总了C#中Universe.Modules.Web.WebInterface.UserTypeToUserFlags方法的典型用法代码示例。如果您正苦于以下问题:C# WebInterface.UserTypeToUserFlags方法的具体用法?C# WebInterface.UserTypeToUserFlags怎么用?C# WebInterface.UserTypeToUserFlags使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Universe.Modules.Web.WebInterface
的用法示例。
在下文中一共展示了WebInterface.UserTypeToUserFlags方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Fill
public Dictionary<string, object> Fill(WebInterface webInterface, string filename, OSHttpRequest httpRequest,
OSHttpResponse httpResponse, Dictionary<string, object> requestParameters,
ITranslator translator, out string response)
{
response = null;
var vars = new Dictionary<string, object>();
var settings = webInterface.GetWebUISettings();
bool adminUser = Authenticator.CheckAdminAuthentication(httpRequest, Constants.USER_GOD_CUSTOMER_SERVICE);
bool allowRegistration = settings.WebRegistration;
bool anonymousLogins;
// allow configuration to override the web settings
var simBase = webInterface.Registry.RequestModuleInterface<ISimulationBase>();
IConfig loginServerConfig = simBase.ConfigSource.Configs["LoginService"];
if (loginServerConfig != null)
{
anonymousLogins = loginServerConfig.GetBoolean ("AllowAnonymousLogin", allowRegistration);
allowRegistration = (allowRegistration || anonymousLogins);
}
if (!adminUser && !allowRegistration)
{
vars.Add("ErrorMessage", "");
vars.Add("RegistrationText", translator.GetTranslatedString("RegistrationText"));
vars.Add("RegistrationsDisabled", translator.GetTranslatedString("RegistrationsDisabled"));
vars.Add("Registrations", false);
vars.Add("NoRegistrations", true);
return vars;
}
if (requestParameters.ContainsKey("Submit"))
{
string AvatarName = requestParameters["AvatarName"].ToString();
string AvatarPassword = requestParameters["AvatarPassword"].ToString();
string AvatarPasswordCheck = requestParameters["AvatarPassword2"].ToString();
string FirstName = requestParameters["FirstName"].ToString();
string LastName = requestParameters["LastName"].ToString();
//removed - greythane - deemed not used
//string UserAddress = requestParameters["UserAddress"].ToString();
//string UserZip = requestParameters["UserZip"].ToString();
string UserCity = requestParameters["UserCity"].ToString();
string UserEmail = requestParameters["UserEmail"].ToString();
string UserHomeRegion = requestParameters["UserHomeRegion"].ToString();
string UserDOBMonth = requestParameters["UserDOBMonth"].ToString();
string UserDOBDay = requestParameters["UserDOBDay"].ToString();
string UserDOBYear = requestParameters["UserDOBYear"].ToString();
string AvatarArchive = requestParameters.ContainsKey("AvatarArchive")
? requestParameters["AvatarArchive"].ToString()
: "";
bool ToSAccept = requestParameters.ContainsKey("ToSAccept") &&
requestParameters["ToSAccept"].ToString() == "Accepted";
string UserType = requestParameters.ContainsKey("UserType") // only admins can set membership
? requestParameters ["UserType"].ToString ()
: "Resident";
// revise UserDOBMonth to a number
UserDOBMonth = ShortMonthToNumber(UserDOBMonth);
// revise Type flags
int UserFlags = webInterface.UserTypeToUserFlags (UserType);
// a bit of idiot proofing
if (AvatarName == "") {
response = "<h3>" + translator.GetTranslatedString ("AvatarNameError") + "</h3>";
return null;
}
if ( (AvatarPassword == "") || (AvatarPassword != AvatarPasswordCheck) )
{
response = "<h3>" + translator.GetTranslatedString ("AvatarPasswordError") + "</h3>";
return null;
}
if (UserEmail == "")
{
response = "<h3>" + translator.GetTranslatedString ("AvatarEmailError") + "</h3>";
return null;
}
// Thish - Only one space is allowed in the name to seperate First and Last of the avatar name
if (AvatarName.Split (' ').Length != 2)
{
response = "<h3>" + translator.GetTranslatedString("AvatarNameSpacingError") + "</h3>";
return null;
}
// so far so good...
if (ToSAccept)
{
AvatarPassword = Util.Md5Hash(AvatarPassword);
IUserAccountService accountService =
webInterface.Registry.RequestModuleInterface<IUserAccountService>();
UUID userID = UUID.Random();
string error = accountService.CreateUser(userID, settings.DefaultScopeID, AvatarName, AvatarPassword,
UserEmail);
if (error == "")
{
// set the user account type
UserAccount account = accountService.GetUserAccount (null, userID);
//.........这里部分代码省略.........
示例2: Fill
public Dictionary<string, object> Fill (WebInterface webInterface, string filename, OSHttpRequest httpRequest,
OSHttpResponse httpResponse, Dictionary<string, object> requestParameters,
ITranslator translator, out string response)
{
response = null;
var vars = new Dictionary<string, object> ();
string error = "";
UUID userID = httpRequest.Query.ContainsKey ("userid")
? UUID.Parse (httpRequest.Query ["userid"].ToString ())
: UUID.Parse (requestParameters ["userid"].ToString ());
IUserAccountService userService = webInterface.Registry.RequestModuleInterface<IUserAccountService> ();
UserAccount account = null;
if (userService != null)
account = userService.GetUserAccount (null, userID);
var agentService = Framework.Utilities.DataManager.RequestPlugin<IAgentConnector> ();
IAgentInfo agent = agentService.GetAgent (userID);
if (agent == null)
error = "No agent information is available";
// Set user type
if (requestParameters.ContainsKey ("Submit") &&
requestParameters ["Submit"].ToString () == "SubmitSetUserType") {
string UserType = requestParameters ["UserType"].ToString ();
int UserFlags = webInterface.UserTypeToUserFlags (UserType);
// set the user account type
if (account != null) {
account.UserFlags = UserFlags;
userService.StoreUserAccount (account);
} else {
response = "User account not found - Unable to update!'";
return null;
}
if (agent != null) {
agent.OtherAgentInformation ["UserFlags"] = UserFlags;
agentService.UpdateAgent (agent);
} else {
response = "Agent information is not available! Has the user logged in yet?";
return null;
}
IProfileConnector profileData =
Framework.Utilities.DataManager.RequestPlugin<IProfileConnector> ();
if (profileData != null) {
IUserProfileInfo profile = profileData.GetUserProfile (userID);
if (profile == null) {
profileData.CreateNewProfile (userID);
profile = profileData.GetUserProfile (userID);
}
profile.MembershipGroup = webInterface.UserFlagToType (UserFlags, webInterface.EnglishTranslator); // membership is english
profileData.UpdateUserProfile (profile);
}
response = "User account has been updated.";
return null;
}
// Password change
if (requestParameters.ContainsKey ("Submit") &&
requestParameters ["Submit"].ToString () == "SubmitPasswordChange") {
string password = requestParameters ["password"].ToString ();
string passwordconf = requestParameters ["passwordconf"].ToString ();
if (password != passwordconf)
response = "Passwords do not match";
else {
IAuthenticationService authService =
webInterface.Registry.RequestModuleInterface<IAuthenticationService> ();
if (authService != null)
response = authService.SetPassword (userID, "UserAccount", password)
? "Successfully set password"
: "Failed to set your password, try again later";
else
response = "No authentication service was available to change the account passwor!";
}
return null;
}
// Email change
if (requestParameters.ContainsKey ("Submit") &&
requestParameters ["Submit"].ToString () == "SubmitEmailChange") {
string email = requestParameters ["email"].ToString ();
if (account != null) {
account.Email = email;
userService.StoreUserAccount (account);
response = "Successfully updated email";
} else
response = "No authentication service was available to change the email details!";
return null;
}
//.........这里部分代码省略.........