Click or drag to resize

ContextFactoryCreateByUserEncryptedKey Method

Creates a context using the encryption key of a user.

Namespace:  AskiaPortalCmn
Assembly:  AskiaPortalCmn (in AskiaPortalCmn.dll) Version: 1.7.0-build068
Syntax
public static IContext CreateByUserEncryptedKey(
	string encryptedKey,
	string apiKey = null
)

Parameters

encryptedKey
Type: SystemString
Encrypted key from a user account (See: BuildEncryptedKey(EncryptedKeyAction)).
apiKey (Optional)
Type: SystemString
Indicates the API key of the application that currently request a context. If null, we assume that the application in used is AskiaPortal.

Return Value

Type: IContext
A context of execution
Remarks
This method is mostly used to:

- Activate an account
- Reset the user password
Examples

This example shows how to create a context to activate a user account.

string cipherParam = Request.Params["x"];
var context = ContextFactory.CreateByUserEncryptedKey(cipherParam);
var result = context.Validate();
if (!result.Success)
{
    throw result.Exception;
}
result = context.User.Activate();
if (!result.Success)
{
      throw result.Exception;
}
result = context.User.Save();
if (!result.Success)
{
     throw result.Exception;
}
See Also