-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f0a20f4
commit 78dba75
Showing
20 changed files
with
1,166 additions
and
182 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
using Microsoft.AspNetCore.Authorization; | ||
using Microsoft.AspNetCore.Mvc; | ||
using taskmaster_api.Data.DTOs; | ||
using taskmaster_api.Services.Interface; | ||
|
||
namespace taskmaster_api.Controllers | ||
{ | ||
[Route("api/[controller]")] | ||
[ApiController] | ||
public class AuthController : ApplicationControllerBase | ||
{ | ||
private readonly IAuthService _authService; | ||
|
||
public AuthController(IAuthService authService) | ||
{ | ||
_authService = authService; | ||
} | ||
|
||
[HttpPost("login")] | ||
[AllowAnonymous] | ||
public IActionResult Login(LoginDto loginDto) | ||
{ | ||
return ToHttpResult<LoginResponseDto>(_authService.Login(loginDto)); | ||
} | ||
|
||
[HttpPost("register")] | ||
[AllowAnonymous] | ||
public IActionResult Register(RegisterDto registerDto) | ||
{ | ||
return ToHttpResult<RegisterDto>(_authService.Register(registerDto)); | ||
} | ||
|
||
[HttpPost("register-admin")] | ||
[AllowAnonymous] | ||
public IActionResult RegisterAdmin(RegisterDto registerDto) | ||
{ | ||
return ToHttpResult<RegisterDto>(_authService.RegisterAdmin(registerDto)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,15 @@ | ||
using Microsoft.EntityFrameworkCore; | ||
using Microsoft.AspNetCore.Identity.EntityFrameworkCore; | ||
using Microsoft.EntityFrameworkCore; | ||
using taskmaster_api.Data.Entities; | ||
|
||
namespace taskmaster_api.Data.Contexts | ||
{ | ||
public class ApplicationDbContext : DbContext | ||
public class ApplicationDbContext : IdentityDbContext | ||
{ | ||
public ApplicationDbContext(DbContextOptions options) : base(options) | ||
{ | ||
} | ||
|
||
public virtual DbSet<UserEntity> Users { get; set; } | ||
public virtual DbSet<TaskEntity> Tasks { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using System.ComponentModel.DataAnnotations; | ||
|
||
namespace taskmaster_api.Data.DTOs | ||
{ | ||
public class LoginDto | ||
{ | ||
[Required(ErrorMessage = "User Name is required")] | ||
public string? Username { get; set; } | ||
|
||
[Required(ErrorMessage = "Password is required")] | ||
public string? Password { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
namespace taskmaster_api.Data.DTOs | ||
{ | ||
public class LoginResponseDto | ||
{ | ||
public string Token { get; set; } | ||
public DateTime Expiration { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using System.ComponentModel.DataAnnotations; | ||
|
||
namespace taskmaster_api.Data.DTOs | ||
{ | ||
public class RegisterDto | ||
{ | ||
[Required(ErrorMessage = "User Name is required")] | ||
public string? Username { get; set; } | ||
|
||
[EmailAddress] | ||
[Required(ErrorMessage = "Email is required")] | ||
public string? Email { get; set; } | ||
|
||
[Required(ErrorMessage = "Password is required")] | ||
public string? Password { get; set; } | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
namespace taskmaster_api.Data.Models | ||
{ | ||
public static class UserRoles | ||
{ | ||
public const string Admin = "Admin"; | ||
public const string User = "User"; | ||
} | ||
} |
75 changes: 0 additions & 75 deletions
75
taskmaster-api/Migrations/20231207132920_InitialCreate.Designer.cs
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.