Add a user server XMLRPC method to set the MOTD and the minimum GodLevel
required to log in. set_login_params accepts avatar_uuid and password of a user with god level 200 or more, and allows setting either or both the login_motd or login_level0.6.0-stable
parent
dabe61f283
commit
fecbb2febd
|
@ -275,6 +275,22 @@ namespace OpenSim.Framework.Communications
|
|||
"false");
|
||||
}
|
||||
|
||||
public XmlRpcResponse CreateLoginBlockedResponse()
|
||||
{
|
||||
return
|
||||
(GenerateFailureResponse("presence",
|
||||
"Logins are currently restricted. Please try again later",
|
||||
"false"));
|
||||
}
|
||||
|
||||
public LLSD CreateLoginBlockedResponseLLSD()
|
||||
{
|
||||
return GenerateFailureResponseLLSD(
|
||||
"presence",
|
||||
"Logins are currently restricted. Please try again later",
|
||||
"false");
|
||||
}
|
||||
|
||||
public XmlRpcResponse CreateDeadRegionResponse()
|
||||
{
|
||||
return
|
||||
|
|
|
@ -47,6 +47,7 @@ namespace OpenSim.Framework.Communications
|
|||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
protected string m_welcomeMessage = "Welcome to OpenSim";
|
||||
protected int m_minLoginLevel = 0;
|
||||
protected UserManagerBase m_userManager = null;
|
||||
protected Mutex m_loginMutex = new Mutex(false);
|
||||
|
||||
|
@ -196,6 +197,10 @@ namespace OpenSim.Framework.Communications
|
|||
|
||||
return logResponse.CreateLoginFailedResponse();
|
||||
}
|
||||
else if (userProfile.GodLevel < m_minLoginLevel)
|
||||
{
|
||||
return logResponse.CreateLoginBlockedResponse();
|
||||
}
|
||||
else
|
||||
{
|
||||
// If we already have a session...
|
||||
|
@ -363,6 +368,10 @@ namespace OpenSim.Framework.Communications
|
|||
{
|
||||
return logResponse.CreateLoginFailedResponseLLSD();
|
||||
}
|
||||
else if (userProfile.GodLevel < m_minLoginLevel)
|
||||
{
|
||||
return logResponse.CreateLoginBlockedResponseLLSD();
|
||||
}
|
||||
else
|
||||
{
|
||||
// If we already have a session...
|
||||
|
|
|
@ -146,6 +146,7 @@ namespace OpenSim.Grid.UserServer
|
|||
m_httpServer.AddXmlRPCHandler("logout_of_simulator", m_userManager.XmlRPCLogOffUserMethodUUID);
|
||||
m_httpServer.AddXmlRPCHandler("get_agent_by_uuid", m_userManager.XmlRPCGetAgentMethodUUID);
|
||||
m_httpServer.AddXmlRPCHandler("check_auth_session", m_userManager.XmlRPCCheckAuthSession);
|
||||
m_httpServer.AddXmlRPCHandler("set_login_params", m_loginService.XmlRPCSetLoginParams);
|
||||
// Message Server ---> User Server
|
||||
m_httpServer.AddXmlRPCHandler("register_messageserver", m_messagesService.XmlRPCRegisterMessageServer);
|
||||
m_httpServer.AddXmlRPCHandler("agent_change_region", m_messagesService.XmlRPCUserMovedtoRegion);
|
||||
|
|
|
@ -437,5 +437,48 @@ namespace OpenSim.Grid.UserServer
|
|||
"A root inventory folder for user {0} could not be retrieved from the inventory service",
|
||||
userID));
|
||||
}
|
||||
|
||||
public XmlRpcResponse XmlRPCSetLoginParams(XmlRpcRequest request)
|
||||
{
|
||||
XmlRpcResponse response = new XmlRpcResponse();
|
||||
Hashtable requestData = (Hashtable) request.Params[0];
|
||||
UserProfileData userProfile;
|
||||
Hashtable responseData = new Hashtable();
|
||||
|
||||
UUID uid;
|
||||
string pass = requestData["password"].ToString();
|
||||
|
||||
if(!UUID.TryParse((string) requestData["avatar_uuid"], out uid))
|
||||
{
|
||||
responseData["error"] = "No authorization";
|
||||
response.Value = responseData;
|
||||
return response;
|
||||
}
|
||||
|
||||
userProfile = m_userManager.GetUserProfile(uid);
|
||||
|
||||
if (userProfile == null ||
|
||||
(!AuthenticateUser(userProfile, pass)) ||
|
||||
userProfile.GodLevel < 200)
|
||||
{
|
||||
responseData["error"] = "No authorization";
|
||||
response.Value = responseData;
|
||||
return response;
|
||||
}
|
||||
|
||||
if (requestData.ContainsKey("login_level"))
|
||||
{
|
||||
m_minLoginLevel = Convert.ToInt32(requestData["login_level"]);
|
||||
}
|
||||
|
||||
if (requestData.ContainsKey("login_motd"))
|
||||
{
|
||||
m_welcomeMessage = requestData["login_motd"].ToString();
|
||||
}
|
||||
|
||||
response.Value = responseData;
|
||||
return response;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue