diff options
| author | ivarlovlie <git@ivarlovlie.no> | 2022-10-05 14:45:21 +0200 |
|---|---|---|
| committer | ivarlovlie <git@ivarlovlie.no> | 2022-10-05 14:45:21 +0200 |
| commit | b7e39b59fd0fc7b5610ebff29035bf622079e0d8 (patch) | |
| tree | 64be84ebbdac9f7ceced983390c53b10d575af5c /server/src/Endpoints/Internal/Account/CreateInitialAccountRoute.cs | |
| parent | 2001c035fbb417ab0a3d42cfb04d17420bde4086 (diff) | |
| download | greatoffice-b7e39b59fd0fc7b5610ebff29035bf622079e0d8.tar.xz greatoffice-b7e39b59fd0fc7b5610ebff29035bf622079e0d8.zip | |
refactor: Change file structure
Diffstat (limited to 'server/src/Endpoints/Internal/Account/CreateInitialAccountRoute.cs')
| -rw-r--r-- | server/src/Endpoints/Internal/Account/CreateInitialAccountRoute.cs | 34 |
1 files changed, 0 insertions, 34 deletions
diff --git a/server/src/Endpoints/Internal/Account/CreateInitialAccountRoute.cs b/server/src/Endpoints/Internal/Account/CreateInitialAccountRoute.cs deleted file mode 100644 index 13fbdf4..0000000 --- a/server/src/Endpoints/Internal/Account/CreateInitialAccountRoute.cs +++ /dev/null @@ -1,34 +0,0 @@ -namespace IOL.GreatOffice.Api.Endpoints.Internal.Account; - -/// <inheritdoc /> -public class CreateInitialAccountRoute : RouteBaseAsync.WithoutRequest.WithActionResult -{ - private readonly AppDbContext _context; - private readonly UserService _userService; - - /// <inheritdoc /> - public CreateInitialAccountRoute(AppDbContext context, UserService userService) { - _context = context; - _userService = userService; - } - - /// <summary> - /// Create an initial user account. - /// </summary> - /// <param name="cancellationToken"></param> - /// <returns></returns> - [AllowAnonymous] - [HttpGet("~/_/account/create-initial")] - public override async Task<ActionResult> HandleAsync(CancellationToken cancellationToken = default) { - if (_context.Users.Any()) { - return NotFound(); - } - - var user = new User("admin@ivarlovlie.no"); - user.HashAndSetPassword("ivar123"); - _context.Users.Add(user); - await _context.SaveChangesAsync(cancellationToken); - await _userService.LogInUser(HttpContext, user); - return Redirect("/"); - } -} |
