Ejemplo n.º 1
0
        public virtual ActionResult GenerateApiKey()
        {
            // Get the user
            var user = UserService.FindByUsername(User.Identity.Name);

            // Generate an API Key
            var apiKey = Guid.NewGuid();

            // Set the existing API Key field
            user.ApiKey = apiKey;

            // Add/Replace the API Key credential, and save to the database
            UserService.ReplaceCredential(user, CredentialBuilder.CreateV1ApiKey(apiKey));
            return(RedirectToAction(MVC.Users.Account()));
        }