You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
PortfolioLink/backend/Controllers/CreateAccount.cs

48 lines
1.8 KiB

// using Microsoft.AspNetCore.Mvc;
// using Microsoft.EntityFrameworkCore;
// using Models;
// namespace backend.Controllers
// {
// //FIXME: This needs to be behind authorization in production
// [Route("api/createaccount")]
// [ApiController]
// public class CreateAccountController : ControllerBase
// {
// private readonly IConfiguration _config;
// private readonly ILogger _logger;
// public CreateAccountController(IConfiguration config, ILogger<CreateAccountController> logger)
// {
// _config = config;
// _logger = logger;
// }
// [HttpPost]
// async public Task<ActionResult> CreateAccount([FromBody] dynamic accountInfo)
// { //TODO Create a model for this request
// User newUser = new User(accountInfo.username, accountInfo.email, accountInfo.password, null);
// _logger.LogDebug($"New user to be added: {newUser}");
// using (var db = new PortfolioPortalDbContext())
// {
// var addTask = await db.AddAsync(newUser);
// await db.SaveChangesAsync();
// var newUserDb = await db.Users.FirstOrDefaultAsync(u => u.Email == newUser.Email);
// // Add auths
// if (addTask.State == EntityState.Added)
// {
// _logger.LogInformation($"User user added to database: {newUserDb}.");
// return Ok($"Account created for {accountInfo.email}.");
// }
// else
// {
// _logger.LogError($"Failed to add new user to database: {newUser}!");
// return BadRequest("Failed to add account to database.");
// }
// }
// }
// }
// }