Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
DeleteAccount.cs
1using System.Threading.Tasks;
5
7{
9 {
10 public DeleteAccount()
11 : base("/DeleteAccount")
12 {
13 }
14
15 public override bool HandlesSubPaths => false;
16 public override bool UserSessions => true;
17 public bool AllowsPOST => true;
18
19 public async Task POST(HttpRequest Request, HttpResponse Response)
20 {
21 Gateway.AssertUserAuthenticated(Request, "Admin.Broker.Accounts");
22
23 if (!Request.HasData)
24 throw new BadRequestException();
25
26 object Obj = await Request.DecodeDataAsync();
27 if (!(Obj is string UserName))
28 throw new BadRequestException();
29
30 DataStorage.PersistenceLayer PersistenceLayer = XmppServerModule.PersistenceLayer ?? new DataStorage.PersistenceLayer();
31 await PersistenceLayer.DeleteAccount(UserName, Request.RemoteEndPoint);
32
33 Response.StatusCode = 200;
34 Response.ContentType = PlainTextCodec.DefaultContentType;
35 await Response.Write("1");
36 }
37 }
38}
Plain text encoder/decoder.
const string DefaultContentType
text/plain
Static class managing the runtime environment of the IoT Gateway.
Definition: Gateway.cs:126
static IUser AssertUserAuthenticated(HttpRequest Request, string Privilege)
Makes sure a request is being made from a session with a successful user login.
Definition: Gateway.cs:3041
The request could not be understood by the server due to malformed syntax. The client SHOULD NOT repe...
Represents an HTTP request.
Definition: HttpRequest.cs:18
string RemoteEndPoint
Remote end-point.
Definition: HttpRequest.cs:195
bool HasData
If the request has data.
Definition: HttpRequest.cs:74
async Task< object > DecodeDataAsync()
Decodes data sent in request.
Definition: HttpRequest.cs:95
Represets a response of an HTTP client request.
Definition: HttpResponse.cs:21
async Task Write(byte[] Data)
Returns binary data in the response.
Base class for all synchronous HTTP resources. A synchronous resource responds within the method hand...
async Task< bool > DeleteAccount(CaseInsensitiveString UserName, string RemoteEndpoint)
Deletes an account.
bool AllowsPOST
If the POST method is allowed.
async Task POST(HttpRequest Request, HttpResponse Response)
Executes the POST method on the resource.
POST Interface for HTTP resources.