-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This library creates bridge between api and controllers
- Loading branch information
novru
authored and
novru
committed
May 17, 2024
1 parent
66b0e60
commit 50fcc48
Showing
13 changed files
with
233 additions
and
218 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
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
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
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,9 @@ | ||
using Microsoft.AspNetCore.Mvc; | ||
|
||
namespace Presentation.Abstraction; | ||
|
||
[ApiController] | ||
[Route("api/[controller]")] | ||
public abstract class ApiController : ControllerBase | ||
{ | ||
} |
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 @@ | ||
using System.Reflection; | ||
|
||
namespace Presentation; | ||
|
||
public static class AssemblyReference | ||
{ | ||
public static readonly Assembly Assembly = typeof(Assembly).Assembly; | ||
} |
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,61 @@ | ||
using Application.Models.Requests; | ||
using Application.Models.Responses; | ||
using Application.Services; | ||
using Microsoft.AspNetCore.Mvc; | ||
using Presentation.Abstraction; | ||
|
||
namespace Presentation.Controllers; | ||
|
||
public sealed class AuthController : ApiController | ||
{ | ||
private readonly IAuthService _authService; | ||
|
||
public AuthController(IAuthService authService) | ||
{ | ||
_authService = authService; | ||
} | ||
|
||
[HttpPost("Login")] | ||
public async Task<ActionResult> Login(LoginUserRequest request) | ||
{ | ||
try | ||
{ | ||
return Ok(await _authService.Login(request)); | ||
} | ||
catch (Exception) | ||
{ | ||
return BadRequest("Error occured with loginning"); | ||
} | ||
} | ||
|
||
[HttpPost("Register")] | ||
public async Task<ActionResult> Register(RegisterUserRequest request) | ||
{ | ||
try | ||
{ | ||
if (await _authService.Register(request)) | ||
{ | ||
return Ok("Successfully Registered!"); | ||
} | ||
throw new ArgumentException("Error occured with registering, try again later."); | ||
} | ||
catch (Exception ex) | ||
{ | ||
return BadRequest(ex.Message); | ||
} | ||
} | ||
|
||
[HttpPost("RefreshToken")] | ||
public async Task<ActionResult<AuthTokenInfo>> RefreshToken([FromBody] RefreshTokenRequest request) | ||
{ | ||
try | ||
{ | ||
var token = await _authService.RefreshToken(request); | ||
return Ok(token); | ||
} | ||
catch (Exception ex) | ||
{ | ||
return BadRequest(ex.Message); | ||
} | ||
} | ||
} |
Oops, something went wrong.