UserFactoryFindByToken Method |
Find a non-deleted user using his token,
return null if not found.
Namespace:
AskiaPortalCmn
Assembly:
AskiaPortalCmn (in AskiaPortalCmn.dll) Version: 1.7.0-build068
Syntax public static IUser FindByToken(
IContext context,
string key,
string token,
IServer server = null,
Nullable<Guid> moduleGuid = null
)
Public Shared Function FindByToken (
context As IContext,
key As String,
token As String,
Optional server As IServer = Nothing,
Optional moduleGuid As Nullable(Of Guid) = Nothing
) As IUser
public:
static IUser^ FindByToken(
IContext^ context,
String^ key,
String^ token,
IServer^ server = nullptr,
Nullable<Guid> moduleGuid = nullptr
)
Parameters
- context
- Type: AskiaPortalCmnIContext
Context of execution. - key
- Type: SystemString
Indicates the key of the token to find. - token
- Type: SystemString
Indicates the value of the token to find. - server (Optional)
- Type: AskiaPortalCmnIServer
Indicates on which server to find the token. - moduleGuid (Optional)
- Type: SystemNullableGuid
Guid of the module that manage the object (if null use the CurrentModule).
Return Value
Type:
IUser
Return null if the user was not found or deleted,
or if the user within the context doesn't have
enough right to access it.
Examples
Find the user using his token.
var context = ContextFactory.CreateByUserGuid(Guid.Parse("20BE5F84-F006-49A0-9674-4B16A090AF2D"));
var contextValidation = context.Validate();
if (!contextValidation.Success)
{
throw contextValidation.Exception;
}
var user = UserFactory.FindByToken(context, "SSO", "a_secret_key");
if (user != null)
{
Console.WriteLine("User Id={0} was found: {1}", user.Id, user.Email);
}
else
{
Console.WriteLine("The specified user doesn't exist, or the current user within the context could not access it");
}
See Also