Exemple #1
0
        public static async Task OnHttpRequest(Microsoft.AspNetCore.Http.HttpContext e, DbUser u, string token)
        {
            //Validate challenges
            if (Program.FindRequestMethod(e) != RequestHttpMethod.delete)
            {
                throw new StandardError("A required challenge failed.", StandardErrorCode.MissingRequiredArg);
            }
            if (e.Request.Query["chal_name"] != u.screen_name)
            {
                throw new StandardError("A required challenge failed.", StandardErrorCode.MissingRequiredArg);
            }

            //We're confirmed to delete this user. Go ahead and start removing data

            //We'll remove analytic data first
            using (HttpClient hc = new HttpClient())
                await hc.PostAsync("https://web-analytics.deltamap.net/v1/destroy?access_token=" + token, new StringContent(""));

            //Now, delete all servers we own
            var owned_servers = u.GetOwnedServersAsync(Program.connection).GetAwaiter().GetResult();

            foreach (var s in owned_servers)
            {
                s.DeleteAsync(Program.connection).GetAwaiter().GetResult();
            }

            //Destroy all of our tokens
            u.DevalidateAllTokens(Program.connection).GetAwaiter().GetResult();

            //Finally, destroy our user
            u.DeleteAsync(Program.connection).GetAwaiter().GetResult();

            //Goodbye!
            await Program.QuickWriteStatusToDoc(e, true);
        }