Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
How to create umbraco BackOffice admin user using code c#
Assuming you have a SurfaceController or UmbracoController or something then I'd be injecting an IBackOfficeUserManager and using that.
IBackOfficeUserManager
Something like this should get you started:
using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Options; using Umbraco.Cms.Core.Configuration.Models; using Umbraco.Cms.Core.Security; // change this namespace to your own namespace Umbraco.Cms.Web.UI.Controllers; public class SomethingController : UmbracoController { private readonly IBackOfficeUserManager _backOfficeUserManager; private readonly GlobalSettings _globalSettings; public SomethingController( IBackOfficeUserManager backOfficeUserManager, IOptions<GlobalSettings> globalSettings) { _backOfficeUserManager = backOfficeUserManager; _globalSettings = globalSettings.Value; } public async Task<IActionResult> Index(string name, string email, string password) { var identityUser = BackOfficeIdentityUser.CreateNew( _globalSettings, email, email, _globalSettings.DefaultUILanguage); identityUser.Name = name; IdentityResult created = await _backOfficeUserManager.CreateAsync(identityUser, password); return created.Succeeded ? Ok() : BadRequest(); } }
That should at least get you started
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
How to create umbraco BackOffice admin user using code c#
How to create umbraco BackOffice admin user using code c#
Assuming you have a SurfaceController or UmbracoController or something then I'd be injecting an
IBackOfficeUserManager
and using that.Something like this should get you started:
That should at least get you started
is working on a reply...