Compare commits
No commits in common. "1d4e17dcef54ab51c86dbcc219a7d81858d1a974" and "e63309e5e39841034037d038643e4b86cc69c917" have entirely different histories.
1d4e17dcef
...
e63309e5e3
@ -1,12 +1,11 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Api.Models;
|
||||
using Api.DBAccess;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
|
||||
namespace Api.Controllers
|
||||
{
|
||||
[ApiController]
|
||||
[Route("[controller]")]
|
||||
[Route("api/[controller]")]
|
||||
public class DeviceController : Controller
|
||||
{
|
||||
private readonly DBContext _context;
|
||||
@ -16,7 +15,7 @@ namespace Api.Controllers
|
||||
_context = context;
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
// For at få json webtokens til at virke skriv [Authorize] over de endpoints
|
||||
[HttpGet]
|
||||
public async Task<IActionResult> GetDevices(int userId)
|
||||
{
|
||||
@ -26,7 +25,6 @@ namespace Api.Controllers
|
||||
return Ok(devices);
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpPost("adddevice/{userId}")]
|
||||
public async Task<IActionResult> AddDevice([FromBody] Device device, int userId)
|
||||
{
|
||||
@ -36,7 +34,6 @@ namespace Api.Controllers
|
||||
return Ok();
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpGet("logs/{deviceId}")]
|
||||
public async Task<IActionResult> GetLogs(int deviceId)
|
||||
{
|
||||
@ -46,7 +43,6 @@ namespace Api.Controllers
|
||||
return Ok(logs);
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpPut("Edit/{deviceId}")]
|
||||
public async Task<IActionResult> EditDevice([FromBody] Device device, int deviceId)
|
||||
{
|
||||
|
@ -1,12 +0,0 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Api.Controllers
|
||||
{
|
||||
[ApiController]
|
||||
[Route("[controller]")]
|
||||
public class HealthController : Controller
|
||||
{
|
||||
[HttpGet]
|
||||
public async Task<IActionResult> Health() { return Ok(); }
|
||||
}
|
||||
}
|
@ -5,12 +5,11 @@ using Microsoft.IdentityModel.Tokens;
|
||||
using System.IdentityModel.Tokens.Jwt;
|
||||
using System.Security.Claims;
|
||||
using System.Text;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
|
||||
namespace Api.Controllers
|
||||
{
|
||||
[ApiController]
|
||||
[Route("[controller]")]
|
||||
[Route("api/[controller]")]
|
||||
public class UserController : Controller
|
||||
{
|
||||
private readonly DBContext _context;
|
||||
@ -41,7 +40,6 @@ namespace Api.Controllers
|
||||
return Ok();
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpPut("Edit/{userId}")]
|
||||
public async Task<IActionResult> EditUser([FromBody] User user, int userId)
|
||||
{
|
||||
@ -51,7 +49,6 @@ namespace Api.Controllers
|
||||
return Ok();
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
[HttpDelete("Delete/{userId}")]
|
||||
public async Task<IActionResult> DeleteUser(int userId)
|
||||
{
|
||||
|
@ -44,11 +44,7 @@ namespace Api.DBAccess
|
||||
public async Task<User> Login(User user)
|
||||
{
|
||||
var profile = await _context.Users.FirstAsync(u => u.UserName == user.UserName);
|
||||
if (profile == null)
|
||||
{
|
||||
profile = await _context.Users.FirstAsync(u => u.Email == user.Email);
|
||||
}
|
||||
|
||||
|
||||
string hashedPassword = ComputeHash(user.Password, SHA256.Create(), profile.Salt);
|
||||
|
||||
if (hashedPassword == user.Password)
|
||||
|
@ -1,9 +0,0 @@
|
||||
namespace Api.Models
|
||||
{
|
||||
public class Login
|
||||
{
|
||||
public string Login { get; set; }
|
||||
|
||||
public string Password { get; set; }
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user