Activate()
Activate a user account
Description
The Activate() method is used to assign a GCKey MBUN to a user via an activation (enrollment) key.
Package Details
Interface
IAccountManager
Syntax
AccountManager.Activate( UserActivationContext userActivationContext )
Returns
Task<User>
API
[POST] /api/v1/account/activate
Sample request body
{
"EnrollmentKey": "string",
"ServiceId": "int",
"AuthenticationContext": {
"Type": "GCKey",
"GCKey": {
"MBUN": "string",
"Issuer": "string"
},
"WindowsUserName": "string"
}
}
Returns
UserDTO
Example
using MTOA.BLL.Interfaces;
int myServiceId = 123;
string enrollmentKey = "xyz"; // Retrieve from URI
User user = await _accountManager.Activate(enrollmentKey, BaseController.AuthenticationContext, myServiceId );
if (user != null)
{
_logger.Info( $"User {user.FirstName} {user.LastName} is now bound to their account using {enrollmentKey}");
} else {
_logger.Error($"Failed to bind user to key {enrollmentKey}");
}
Related references