private OSDMap ActivateAccount(OSDMap map)
{
OSDMap resp = new OSDMap();
resp["Verified"] = OSD.FromBoolean(false);
if (map.ContainsKey("UserName") && map.ContainsKey("PasswordHash") && map.ContainsKey("ActivationToken"))
{
IUserAccountService accountService = m_registry.RequestModuleInterface<IUserAccountService>();
UserAccount user = accountService.GetUserAccount(null, map["UserName"].ToString());
if (user != null)
{
IAgentConnector con = DataPlugins.RequestPlugin<IAgentConnector>();
IAgentInfo agent = con.GetAgent(user.PrincipalID);
if (agent != null && agent.OtherAgentInformation.ContainsKey("WebUIActivationToken"))
{
UUID activationToken = map["ActivationToken"];
string WebUIActivationToken = agent.OtherAgentInformation["WebUIActivationToken"];
string PasswordHash = map["PasswordHash"];
if (!PasswordHash.StartsWith("$1$"))
{
PasswordHash = "$1$" + Util.Md5Hash(PasswordHash);
}
PasswordHash = PasswordHash.Remove(0, 3); //remove $1$
bool verified = Utils.MD5String(activationToken.ToString() + ":" + PasswordHash) == WebUIActivationToken;
resp["Verified"] = verified;
if (verified)
{
user.UserLevel = 0;
accountService.StoreUserAccount(user);
agent.OtherAgentInformation.Remove("WebUIActivationToken");
con.UpdateAgent(agent);
}
}
}
}
return resp;
}