public async Task <IActionResult> ChangePassword(string id) { try { string rawPostData = await this.Request.GetRawBodyStringAsync(); if (string.IsNullOrEmpty(rawPostData)) { return(this.NotFound("")); } if (rawPostData.Length > 10) { return(this.NotFound("len")); } AdminDM admin = await this.Database.Query <AdminDM>().Where("[id]={0}", id).LoadSingleAsync(); if (admin == null) { return(this.NotFound("no")); } admin.password = Crypter.Encrypt(rawPostData); await admin.UpdateAsync(); return(this.Ok()); } catch (Exception e) { return(this.NotFound("exc")); } }
public async Task <IActionResult> ChangeStatus(string id) { try { string rawPostData = await this.Request.GetRawBodyStringAsync(); if (string.IsNullOrEmpty(rawPostData)) { return(this.NotFound("")); } int statusID; if (!int.TryParse(rawPostData, out statusID)) { return(this.NotFound("err1")); } if (!Enum.IsDefined(typeof(AdminStatusDM), statusID)) { return(this.NotFound("err2")); } AdminDM admin = await this.Database.Query <AdminDM>().Where("[id]={0}", id).LoadSingleAsync(); if (admin == null) { return(this.NotFound("no")); } admin.privileges = statusID; await admin.UpdateAsync(); return(this.Ok()); } catch (Exception e) { return(this.NotFound("exc")); } }
public static void AdminDisconnected(AdminDM admin) => DashboardSocketsServer.SendToAll(new AdminDisconnectedModel() { Username = admin.username } .Pack(DashboardEvents.ADMIN_DISCONNECTED));