|
|
|
|
@ -1,7 +1,5 @@
|
|
|
|
|
using EVABackend.Areas.Identity.Data; |
|
|
|
|
using EVABackend.Models; |
|
|
|
|
using Microsoft.AspNetCore.Authentication; |
|
|
|
|
using Microsoft.AspNetCore.Authentication.Cookies; |
|
|
|
|
using Microsoft.AspNetCore.Authorization; |
|
|
|
|
using Microsoft.AspNetCore.Identity; |
|
|
|
|
using Microsoft.AspNetCore.Mvc; |
|
|
|
|
@ -32,7 +30,27 @@ namespace EVABackend.Controllers
|
|
|
|
|
[AllowAnonymous] |
|
|
|
|
public ActionResult Login() |
|
|
|
|
{ |
|
|
|
|
return Ok(new { status = "Nicht unterstützt" }); |
|
|
|
|
return StatusCode(404, new { status = "Nicht unerstützt" }); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
[HttpGet] |
|
|
|
|
[Route("unauthorized")] |
|
|
|
|
[AllowAnonymous] |
|
|
|
|
public ActionResult GetUnauthorized() |
|
|
|
|
{ |
|
|
|
|
return StatusCode(401, new { status = "401 - Unauthorized" }); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#if DEBUG |
|
|
|
|
[HttpGet] |
|
|
|
|
[Route("login_test")] |
|
|
|
|
[AllowAnonymous] |
|
|
|
|
public async Task<ActionResult> LoginTest() |
|
|
|
|
{ |
|
|
|
|
var user = await _userManager.FindByNameAsync("Test"); |
|
|
|
|
await _signInManager.SignInAsync(user, true); |
|
|
|
|
|
|
|
|
|
return Ok(new { status = "Eingeloggt als Test" }); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
[HttpGet] |
|
|
|
|
@ -42,7 +60,6 @@ namespace EVABackend.Controllers
|
|
|
|
|
{ |
|
|
|
|
if (_userManager.FindByNameAsync("Test") == null) |
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
var user = new EVABackendUser |
|
|
|
|
{ |
|
|
|
|
UserName = "Test", |
|
|
|
|
@ -66,6 +83,7 @@ namespace EVABackend.Controllers
|
|
|
|
|
|
|
|
|
|
return Ok(); |
|
|
|
|
} |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
[HttpPost] |
|
|
|
|
[Route("login")] |
|
|
|
|
@ -78,15 +96,18 @@ namespace EVABackend.Controllers
|
|
|
|
|
return Ok(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return Unauthorized(); |
|
|
|
|
return GetUnauthorized(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
[HttpPost] |
|
|
|
|
#if DEBUG |
|
|
|
|
[HttpGet] |
|
|
|
|
#endif |
|
|
|
|
[Route("logout")] |
|
|
|
|
[Authorize] |
|
|
|
|
public async Task<ActionResult> Logout() |
|
|
|
|
{ |
|
|
|
|
await HttpContext.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme); |
|
|
|
|
await _signInManager.SignOutAsync(); |
|
|
|
|
|
|
|
|
|
return Ok(); |
|
|
|
|
} |
|
|
|
|
@ -146,7 +167,7 @@ namespace EVABackend.Controllers
|
|
|
|
|
await _context.SaveChangesAsync(); |
|
|
|
|
|
|
|
|
|
antrag.Instrumente = instrumente.Select(i => new AntragInstrument { AntragId = antrag.Id, InstrumentId = i.Id }).ToList(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await _context.SaveChangesAsync(); |
|
|
|
|
|
|
|
|
|
return Ok(); |
|
|
|
|
@ -172,7 +193,7 @@ namespace EVABackend.Controllers
|
|
|
|
|
var model = rooms.Select(r => new |
|
|
|
|
{ |
|
|
|
|
RaumID = r.Id, |
|
|
|
|
RaumName= r.Name, |
|
|
|
|
RaumName = r.Name, |
|
|
|
|
Instrumente = r.Instrumente.Select(i => new |
|
|
|
|
{ |
|
|
|
|
InstrumentID = i.InstrumentId, |
|
|
|
|
@ -188,7 +209,7 @@ namespace EVABackend.Controllers
|
|
|
|
|
[Authorize(Roles = "Verwaltung")] |
|
|
|
|
public async Task<ActionResult> CreateRooms(CreateRooms model) |
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
throw new System.NotImplementedException(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|