public void EnableEmail(string server, string port, string username, string password, string content, LoginInfo info) { if (!int.TryParse(port, out int smtpPort)) { throw new Exception("端口错误,不是有效数字"); } var key = SystemKey.EMAIL.ToString(); MailAccount mailAccount = new MailAccount() { enable = true, password = password, userName = username, smtpServer = server, smtpPort = smtpPort, content = content }; if (SysDB.Exist(key)) { SysDB.Update(key, mailAccount.ToJsonString()); } else { SysDB.Insert(key, mailAccount.ToJsonString()); } ServerContext.logger.Info($"{info.username}开启了邮件通知"); }
public void AddUserV2(string userName, string userpwd, string isAdmin) { if (Dbop.Exist(userName)) { throw new Exception("error: user exist."); } var user = new User { userId = SUPER_VARIABLE_INDEX_ID, //索引id userName = userName, userPwd = EncryptHelper.SHA256(userpwd), regTime = DateTime.Now.ToString(), isAdmin = isAdmin }; //if (isAdmin == true) user. //1.增加用户 Dbop.Insert(userName, user.ToJsonString()); }
public void AddUserV2(string userName, string userpwd, string role, LoginInfo info = null) { if (Dbop.Exist(userName)) { throw new Exception("error: user exist."); } var user = new User { userId = SUPER_VARIABLE_INDEX_ID, //索引id userName = userName, userPwd = EncryptHelper.SHA256(userpwd), regTime = DateTime.Now, role = int.Parse(role) }; Dbop.Insert(userName, user.ToJsonString()); if (info != null) ServerContext.logger.Info($"{info.username}添加了用户{userName}"); }