2using System.Collections.Generic;
3using System.Threading.Tasks;
26 : base(
"Account/CreateWebForm")
36 base.GetAuthenticationSchemes(Request);
68 if (!(Decoded is Dictionary<string, string> Form))
71 if (!Form.TryGetValue(
"UserName", out
string UserName) ||
string.IsNullOrEmpty(UserName))
74 if (!Form.TryGetValue(
"EMail", out
string EMail) ||
string.IsNullOrEmpty(EMail))
77 if (!Form.TryGetValue(
"PhoneNr", out
string PhoneNr))
78 PhoneNr =
string.Empty;
80 if (!Form.TryGetValue(
"Password", out
string Password) ||
string.IsNullOrEmpty(Password))
83 if (!Form.TryGetValue(
"g-recaptcha-response", out
string RecaptchaResponse) ||
string.IsNullOrEmpty(RecaptchaResponse))
86 if (!Form.TryGetValue(
"RedirectionUrl", out
string RedirectionUrl) ||
string.IsNullOrEmpty(RedirectionUrl))
89 if (!Form.TryGetValue(
"Seconds", out
string s) || !
int.TryParse(s, out
int Seconds) || Seconds <= 0 || Seconds > 3600)
99 throw new BadRequestException(
"Phone numbers must be provided using the international number format, starting with +, then the country code, then the number.");
101 Create.AssertUserNameValid(UserName);
106 string Msg =
"Resource disabled. No Agent API Key configured.";
115 if (Key.NrCreated - Key.NrDeleted >= Key.MaxAccounts)
124 EMailVerified =
null,
126 PhoneNrVerified =
null,
128 CanRelayMessages =
false,
129 Created = DateTime.Now
144 bool Updated =
false;
151 Account.EMail = EMail;
152 Account.EMailVerified =
null;
162 Account.PhoneNr = PhoneNr;
163 Account.PhoneNrVerified =
null;
181 new Uri(
"https://" + OnboardingDomainName +
"/ID/SendVerificationMessage.ws"),
182 new Dictionary<string, object>()
184 {
"EMail", Account.EMail.Value }
187 is Dictionary<string, object> EMailResult))
192 if (!EMailResult.TryGetValue(
"Status", out
object Obj) || !(Obj is
bool Status) || !Status)
194 if (EMailResult.TryGetValue(
"Message", out Obj) && Obj is
string Message)
203 new Uri(
"https://" + OnboardingDomainName +
"/ID/SendVerificationMessage.ws"),
204 new Dictionary<string, object>()
206 {
"Nr", Account.PhoneNr.Value }
209 is Dictionary<string, object> SmsResult))
214 if (!SmsResult.TryGetValue(
"Status", out Obj) || !(Obj is
bool Status2) || !Status2)
216 if (SmsResult.TryGetValue(
"Message", out Obj) && Obj is
string Message)
224 int IssuedAt = (int)Math.Round(DateTime.UtcNow.Subtract(
JSON.
UnixEpoch).TotalSeconds);
225 int Expires = IssuedAt + (int)Seconds;
227 string Token = Factory.
Create(
Static class managing encoding and decoding of internet content.
static Task< object > PostAsync(Uri Uri, object Data, params KeyValuePair< string, string >[] Headers)
Posts to a resource, using a Uniform Resource Identifier (or Locator).
Helps with common JSON-related tasks.
static readonly DateTime UnixEpoch
Unix Date and Time epoch, starting at 1970-01-01T00:00:00Z
const string DefaultContentType
application/json
Static class managing the runtime environment of the IoT Gateway.
static CaseInsensitiveString Domain
Domain name.
static byte[] NextBytes(int NrBytes)
Generates an array of random bytes.
The request could not be understood by the server due to malformed syntax. The client SHOULD NOT repe...
The server understood the request, but is refusing to fulfill it. Authorization will not help and the...
Base class for all HTTP authentication schemes, as defined in RFC-7235: https://datatracker....
Represents an HTTP request.
string RemoteEndPoint
Remote end-point.
bool HasData
If the request has data.
Variables Session
Contains session states, if the resource requires sessions, or null otherwise.
async Task< object > DecodeDataAsync()
Decodes data sent in request.
Represets a response of an HTTP client request.
The server is currently unable to handle the request due to a temporary overloading or maintenance of...
The requested resource resides temporarily under a different URI. Since the redirection MAY be altere...
Represents a case-insensitive string.
string Value
String-representation of the case-insensitive string. (Representation is case sensitive....
static bool IsNullOrEmpty(CaseInsensitiveString value)
Indicates whether the specified string is null or an CaseInsensitiveString.Empty string.
Static interface for database persistence. In order to work, a database provider has to be assigned t...
static async Task Update(object Object)
Updates an object in the database.
static async Task Insert(object Object)
Inserts an object into the default collection of the database.
This filter selects objects that have a named field equal to a given value.
Static class containing predefined JWT claim names.
const string Issuer
Issuer of the JWT
const string IssueTime
Time at which the JWT was issued; can be used to determine age of the JWT
const string JwtId
Unique identifier; can be used to prevent the JWT from being replayed (allows a token to be used only...
const string Subject
Subject of the JWT (the user)
const string ExpirationTime
Time after which the JWT expires
string Create(params KeyValuePair< string, object >[] Claims)
Creates a new JWT token.
Class that monitors login events, and help applications determine malicious intent....
static async void Success(string Message, string UserName, string RemoteEndpoint, string Protocol, params KeyValuePair< string, object >[] Tags)
Handles a successful login attempt.
Contains information about a broker account.
CaseInsensitiveString EMail
E-mail address associated with account.
CaseInsensitiveString UserName
User Name of account
bool Enabled
If account is enabled
string Password
Password of account
CaseInsensitiveString PhoneNr
Phone number associated with account.
Account()
Contains information about a broker account.
async Task LoggedIn(string RemoteEndpoint)
Registers a log-in event on the account.
Provisioning and registry service component.
static Task< string > GetOnboardingNeuronDomainName()
Gets the domain name of the Nnboarding Neuron.
Creates an account on the server.
static readonly Regex InternationalNumberFormat
International phone number format.
async Task< ApiKey > GetAgentApiApiKey()
Gets API Key for the Agent API.
Abstract base class for agent resources
AgentApi Api
Reference to Agent API.
async Task CheckBlocks(HttpRequest Request)
Checks if the client is blocked.
POST Interface for HTTP resources.