private void ChangePassword(User user, string id, byte[] password) { if (user.Authority <= Base.Security.GetUserAuthority(id)) { throw new RCServerException("Cannot change password of user who has more authority than you"); } Base.Security.ChangePassword(id, password); Base.SaveConfig(); Log <RCServerService> .Logger.InfoFormat("User {0} changed password of {1}", user.AccountId, id); }
private void ChangeMyPassword(User user, byte[] oldPassword, byte[] newPassword) { if (Base.Security.IsPassword(user.AccountId, oldPassword)) { Base.Security.ChangePassword(user.AccountId, newPassword); Base.SaveConfig(); this.NotifyMessage(user, MessageType.Information, "Password changed successfully!", new object[0]); return; } throw new RCServerException("Wrong current password!"); }
private void RemoveUser(User user, string id) { if (user.Authority > Base.Security.GetUserAuthority(id)) { Base.Security.RemoveUser(id); Base.SaveConfig(); Log <RCServerService> .Logger.InfoFormat("User {0} deleted account {1}", user.AccountId, id); return; } throw new RCServerException("Cannot remove user who has more authority than you"); }
private void ChangeAuthority(User user, string id, Authority authority) { if (user.Authority <= Base.Security.GetUserAuthority(id)) { throw new RCServerException("Cannot change authority of user who has higher or same than yours"); } if (user.Authority < authority) { throw new RCServerException("Cannot change user's authority to which is higher than yours"); } Base.Security.ChangeAuthority(id, authority); Base.SaveConfig(); Log <RCServerService> .Logger.InfoFormat("User {0} changed authority of {1}", user.AccountId, id); }
private void TemplateChange(User user, RCProcessCollection collection) { try { Base.ProcessTemplate = collection; Base.SaveConfig(); } catch (Exception ex) { throw new RCServerException("Exception : Cannot parse process templates!\nSource Error Message : {0}", new object[] { ex.Message }); } }
private void AddUser(User user, string id, byte[] password, Authority authority) { if (user.Authority < authority) { throw new RCServerException("Cannot create user who has more authority than you"); } try { Base.Security.AddUser(id, password, authority); Base.SaveConfig(); } catch (ArgumentException) { throw new RCServerException("Account already exist or Invalid account information"); } Log <RCServerService> .Logger.InfoFormat("User {0} created account {1}", user.AccountId, id); }
private void ServerGroupChange(User user, string newServerGroupString) { try { ServerGroupStructureNode.GetServerGroup(newServerGroupString); Base.ServerGroupString = newServerGroupString; Base.SaveConfig(); ServerGroupChangeMessage message = new ServerGroupChangeMessage(newServerGroupString); this.SendToUser <ServerGroupChangeMessage>(message); } catch (Exception ex) { throw new RCServerException("Exception : Cannot parse server group string!\nSource Error Message : {0}", new object[] { ex.Message }); } }
public static void SaveConfig() { Base.SaveConfig(BaseConfiguration.WorkingDirectory + "\\" + BaseConfiguration.ServerConfigFile); }
protected override void OnStop() { Base.SaveConfig(BaseConfiguration.WorkingDirectory + "\\" + BaseConfiguration.ServerConfigFile); Base.CleanUp(); GC.Collect(); }