Created Woodpecker CI/CD deployment
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
- Created Dockerfile for packing up API and Web projects as Docker image
This commit is contained in:
44
API/YABA.API/Controllers/UsersController.cs
Normal file
44
API/YABA.API/Controllers/UsersController.cs
Normal file
@ -0,0 +1,44 @@
|
||||
using AutoMapper;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System.Net;
|
||||
using YABA.API.Extensions;
|
||||
using YABA.API.ViewModels;
|
||||
using YABA.Service.Interfaces;
|
||||
|
||||
namespace YABA.API.Controllers
|
||||
{
|
||||
[ApiController]
|
||||
[ApiVersion("1")]
|
||||
[Authorize]
|
||||
[Route("api/v{version:apiVersion}/[controller]")]
|
||||
public class UsersController : ControllerBase
|
||||
{
|
||||
private readonly IMapper _mapper;
|
||||
private readonly IUserService _userService;
|
||||
|
||||
public UsersController(IMapper mapper, IUserService userService)
|
||||
{
|
||||
_mapper = mapper;
|
||||
_userService = userService;
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[ProducesResponseType(typeof(UserResponse), (int)HttpStatusCode.OK)]
|
||||
[ProducesResponseType((int)HttpStatusCode.NotFound)]
|
||||
[ProducesResponseType((int)HttpStatusCode.NoContent)]
|
||||
public async Task<IActionResult> Register()
|
||||
{
|
||||
var authProviderId = this.GetAuthProviderId();
|
||||
|
||||
if (string.IsNullOrEmpty(authProviderId)) return NotFound();
|
||||
|
||||
var isRegistered = _userService.IsUserRegistered(authProviderId);
|
||||
|
||||
if (isRegistered) return NoContent();
|
||||
|
||||
var registedUser = await _userService.RegisterUser(authProviderId);
|
||||
return Ok(_mapper.Map<UserResponse>(registedUser));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user