aboutsummaryrefslogtreecommitdiff
path: root/API
diff options
context:
space:
mode:
authortranstrike <transtrike@gmail.com>2020-12-13 12:29:02 +0200
committertranstrike <transtrike@gmail.com>2020-12-13 12:29:02 +0200
commit3abbc13bcc55e68740564457fff455c849a1cd8a (patch)
tree84eadad792ff05ba171c75de9e9a5376aa8cf752 /API
parent3f9d6457360bba2eef24c013c5ba40fa92bf8cc7 (diff)
downloadDevHive-3abbc13bcc55e68740564457fff455c849a1cd8a.tar
DevHive-3abbc13bcc55e68740564457fff455c849a1cd8a.tar.gz
DevHive-3abbc13bcc55e68740564457fff455c849a1cd8a.zip
Ordering Models
Diffstat (limited to 'API')
-rw-r--r--API/Controllers/RoleController.cs36
-rw-r--r--API/Controllers/UserController.cs2
-rw-r--r--API/Service/RoleService.cs27
-rw-r--r--API/Service/UserService.cs4
4 files changed, 66 insertions, 3 deletions
diff --git a/API/Controllers/RoleController.cs b/API/Controllers/RoleController.cs
new file mode 100644
index 0000000..20179f4
--- /dev/null
+++ b/API/Controllers/RoleController.cs
@@ -0,0 +1,36 @@
+using System;
+using System.Net;
+using System.Net.Http;
+using System.Threading.Tasks;
+using API.Database;
+using API.Service;
+using Microsoft.AspNetCore.Builder;
+using Microsoft.AspNetCore.Mvc;
+using Microsoft.EntityFrameworkCore;
+
+namespace API.Controllers
+{
+ [ApiController]
+ [Route("/api/[controller]")]
+ public class RoleController
+ {
+ private readonly RoleService _service;
+
+ public RoleController(DevHiveContext context)
+ {
+ this._service = new RoleService(context);
+ }
+
+ [HttpPost]
+ public Task<IActionResult> Create(string name)
+ {
+ return this._service.CreatePost(name);
+ }
+
+ [HttpGet]
+ public Task<IActionResult> ShowPost(uint postId)
+ {
+ return this._service.GetPostById(postId);
+ }
+ }
+}
diff --git a/API/Controllers/UserController.cs b/API/Controllers/UserController.cs
index 8503922..5817d47 100644
--- a/API/Controllers/UserController.cs
+++ b/API/Controllers/UserController.cs
@@ -3,7 +3,7 @@ using API.Database;
using API.Service;
using AutoMapper;
using Microsoft.AspNetCore.Mvc;
-using Data.Models.DTOs;
+using Data.Models.DTOs.Identity;
using Microsoft.AspNetCore.Authorization;
using Data.Models.Options;
diff --git a/API/Service/RoleService.cs b/API/Service/RoleService.cs
new file mode 100644
index 0000000..82c89b8
--- /dev/null
+++ b/API/Service/RoleService.cs
@@ -0,0 +1,27 @@
+using System;
+using System.Threading.Tasks;
+using API.Database;
+using Microsoft.AspNetCore.Mvc;
+
+namespace API.Service
+{
+ public class RoleService
+ {
+ private readonly DevHiveContext _context;
+
+ public RoleService(DevHiveContext context)
+ {
+ this._context = context;
+ }
+
+ public Task<IActionResult> CreatePost(string name)
+ {
+ throw new NotImplementedException();
+ }
+
+ public Task<IActionResult> GetPostById(uint postId)
+ {
+ throw new NotImplementedException();
+ }
+ }
+}
diff --git a/API/Service/UserService.cs b/API/Service/UserService.cs
index d480bec..a1a9fde 100644
--- a/API/Service/UserService.cs
+++ b/API/Service/UserService.cs
@@ -2,7 +2,7 @@ using System.Threading.Tasks;
using API.Database;
using AutoMapper;
using Data.Models.Classes;
-using Data.Models.DTOs;
+using Data.Models.DTOs.Identity;
using Microsoft.AspNetCore.Mvc;
using Data.Models.Options;
using System.IdentityModel.Tokens.Jwt;
@@ -47,7 +47,7 @@ namespace API.Service
new Claim(ClaimTypes.Role, user.Role) // Authorize user by role
}),
Expires = DateTime.UtcNow.AddDays(7),
- SigningCredentials = new SigningCredentials(new SymmetricSecurityKey(key), SecurityAlgorithms.Sha512)
+ SigningCredentials = new SigningCredentials(new SymmetricSecurityKey(key), SecurityAlgorithms.HmacSha512Signature)
};
var tokenHandler = new JwtSecurityTokenHandler();