public void delete_Click(object sender, EventArgs e) { if (! inputConfirm.Checked) { throw new Exception("Please check the \"I understand that this cannot be undone.\" box."); } TransitAccountDeleteOptions options = new TransitAccountDeleteOptions(); options.DeleteContent = inputDeleteContent.Checked && SessionManager.IsAdministrator; SessionManager.AccountService.DeleteAccountWithOptions(SessionManager.Ticket, Account.Id, options); SessionManager.FlushCache(); pnlAccount.Visible = false; if (!SessionManager.IsAdministrator) { // logout the user that deletes himself only SessionManager.Logout(); } ReportInfo("Account deleted."); }
public void delete_Click(object sender, EventArgs e) { if (!inputConfirm.Checked) { throw new Exception("Please check the \"I understand that this cannot be undone.\" box."); } TransitAccountDeleteOptions options = new TransitAccountDeleteOptions(); options.DeleteContent = inputDeleteContent.Checked && SessionManager.IsAdministrator; SessionManager.AccountService.DeleteAccountWithOptions(SessionManager.Ticket, Account.Id, options); SessionManager.FlushCache(); pnlAccount.Visible = false; if (!SessionManager.IsAdministrator) { // logout the user that deletes himself only SessionManager.Logout(); } ReportInfo("Account deleted."); }
public void DeleteAccountWithOptions(string ticket, int id, TransitAccountDeleteOptions options) { using (SnCore.Data.Hibernate.Session.OpenConnection()) { ISession session = SnCore.Data.Hibernate.Session.Current; ManagedSecurityContext sec = new ManagedSecurityContext(session, ticket); ManagedAccount user = new ManagedAccount(session, id); if (user.IsAdministrator()) { throw new Exception( "You cannot delete an administrative account."); } if (sec.Account.Id != user.Id) { if (!sec.IsAdministrator()) { // only admin can delete other people's account throw new ManagedAccount.AccessDeniedException(); } } if (options != null && options.DeleteContent) { if (!sec.IsAdministrator()) { // only admin can delete other people's content throw new ManagedAccount.AccessDeniedException(); } user.DeleteContent(sec); } } WebServiceImpl<TransitAccount, ManagedAccount, Account>.Delete( ticket, id); }