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;
3using System.Threading.Tasks;
4using System.Xml;
5using Waher.Content;
8using Waher.Script;
11
13{
17 public class Info : AgentPostResource
18 {
22 public Info()
23 : base("Account/Info",
24 new KeyValuePair<Type, Expression>(typeof(Dictionary<string, object>), new Expression(jsonPattern)),
25 new KeyValuePair<Type, Expression>(typeof(XmlDocument), new Expression(xmlPattern)))
26 {
27 }
28
29 private static readonly string jsonPattern = Resources.LoadResourceAsText(typeof(GetSessionToken).Namespace + ".JSON.Info.req");
30 private static readonly string xmlPattern = Resources.LoadResourceAsText(typeof(GetSessionToken).Namespace + ".XML.Info.req");
31
35 public override bool UserSessions => true;
36
45 public override async Task POST(HttpRequest Request, HttpResponse Response, Dictionary<string, IElement> Parameters)
46 {
47 AccountUser User = AssertUserAuthenticated(Request, false);
48
49 await Response.Return(new NamedDictionary<string, object>("AccountInfo", AgentNamespace)
50 {
51 { "userName", User.Account.UserName.Value },
52 { "created", User.Account.Created },
53 { "updated", User.Account.Updated },
54 { "eMail", User.Account.Enabled ? User.Account.EMail.Value : null },
55 { "eMailVerified", User.Account.EMailVerified },
56 { "phoneNr", User.Account.Enabled ? User.Account.PhoneNr?.Value : null },
57 { "phoneNrVerified", User.Account.PhoneNrVerified }
58 });
59 }
60 }
61}
A Named dictionary is a dictionary, with a local name and a namespace. Use it to return content that ...
Represents an HTTP request.
Definition: HttpRequest.cs:22
Represets a response of an HTTP client request.
Definition: HttpResponse.cs:23
Task Return(Exception ex)
Returns an error to the client.
Static class managing loading of resources stored as embedded resources or in content files.
Definition: Resources.cs:13
static string LoadResourceAsText(string ResourceName)
Loads a text resource from an embedded resource.
Definition: Resources.cs:55
Class managing a script expression.
Definition: Expression.cs:41
CaseInsensitiveString PhoneNr
Phone number associated with account.
Definition: Account.cs:185
Gets information about a newly created token stored in a session variable.
Gets information about the currently logged in account.
Definition: Info.cs:18
override async Task POST(HttpRequest Request, HttpResponse Response, Dictionary< string, IElement > Parameters)
Executes the POST method on the resource.
Definition: Info.cs:45
Info()
Gets information about the currently logged in account.
Definition: Info.cs:22
override bool UserSessions
If the resource uses user sessions.
Definition: Info.cs:35
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