Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
Info.cs
1using System;
2using System.Collections.Generic;
3using System.Threading.Tasks;
4using System.Xml;
5using Waher.Content;
7using Waher.Script;
10
12{
16 public class Info : AgentPostResource
17 {
21 public Info()
22 : base("Account/Info",
23 new KeyValuePair<Type, Expression>(typeof(Dictionary<string, object>), new Expression(jsonPattern)),
24 new KeyValuePair<Type, Expression>(typeof(XmlDocument), new Expression(xmlPattern)))
25 {
26 }
27
28 private static readonly string jsonPattern = Resources.LoadResourceAsText(typeof(GetSessionToken).Namespace + ".JSON.Info.req");
29 private static readonly string xmlPattern = Resources.LoadResourceAsText(typeof(GetSessionToken).Namespace + ".XML.Info.req");
30
34 public override bool UserSessions => true;
35
44 public override async Task POST(HttpRequest Request, HttpResponse Response, Dictionary<string, IElement> Parameters)
45 {
46 AccountUser User = AssertUserAuthenticated(Request, true);
47
48 await Response.Return(new NamedDictionary<string, object>("AccountInfo", AgentNamespace)
49 {
50 { "userName", User.Account.UserName.Value },
51 { "created", User.Account.Created },
52 { "eMail", User.Account.EMail.Value },
53 { "phoneNr", User.Account.PhoneNr?.Value }
54 });
55 }
56 }
57}
A Named dictionary is a dictionary, with a local name and a namespace. Use it to return content that ...
Static class managing loading of resources stored as embedded resources or in content files.
Definition: Resources.cs:15
static string LoadResourceAsText(string ResourceName)
Loads a text resource from an embedded resource.
Definition: Resources.cs:96
Represents an HTTP request.
Definition: HttpRequest.cs:18
Represets a response of an HTTP client request.
Definition: HttpResponse.cs:21
async Task Return(object Object)
Returns an object to the client. This method can only be called once per response,...
Class managing a script expression.
Definition: Expression.cs:39
CaseInsensitiveString PhoneNr
Phone number associated with account.
Definition: Account.cs:138
Gets information about a newly created token stored in a session variable.
Gets information about the currently logged in account.
Definition: Info.cs:17
override async Task POST(HttpRequest Request, HttpResponse Response, Dictionary< string, IElement > Parameters)
Executes the POST method on the resource.
Definition: Info.cs:44
Info()
Gets information about the currently logged in account.
Definition: Info.cs:21
override bool UserSessions
If the resource uses user sessions.
Definition: Info.cs:34
Abstract base class for agent resources supporting the POST method.
static AccountUser AssertUserAuthenticated(HttpRequest Request)
Makes sure the request is made by an authenticated API user.
const string AgentNamespace
https://waher.se/Schema/BrokerAgent.xsd