Refreshtoken is recieved as a json object
This commit is contained in:
parent
76a0e6afee
commit
fac4e04c2c
@ -65,7 +65,7 @@ namespace API.Controllers
|
|||||||
[HttpGet("chatbot/{dish}")]
|
[HttpGet("chatbot/{dish}")]
|
||||||
public async Task<IActionResult> GenerateRecipe(string dish, string language, int numberOfRecipes = 5)
|
public async Task<IActionResult> GenerateRecipe(string dish, string language, int numberOfRecipes = 5)
|
||||||
{
|
{
|
||||||
var recipes = await _openAiRecipes.ChatGPT(dish, language);
|
var recipes = await _openAiRecipes.ChatGPT(dish, language, numberOfRecipes);
|
||||||
if (recipes.Content[0].Text == null || recipes.Content[0].Text == "")
|
if (recipes.Content[0].Text == null || recipes.Content[0].Text == "")
|
||||||
{
|
{
|
||||||
return new ConflictObjectResult(new { message = "Could not connect to chatGPT" });
|
return new ConflictObjectResult(new { message = "Could not connect to chatGPT" });
|
||||||
|
@ -69,10 +69,11 @@ namespace API.Controllers
|
|||||||
return await _userLogic.DeleteUser(userId);
|
return await _userLogic.DeleteUser(userId);
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost("refreshtoken/{refreshToken}")]
|
[HttpPost("refreshtoken")]
|
||||||
public async Task<IActionResult> RefreashToken(string refreshToken)
|
public async Task<IActionResult> RefreashToken([FromBody] RefreshTokenDTO refreshToken)
|
||||||
{
|
{
|
||||||
return await _userLogic.RefreshToken(refreshToken);
|
var token = refreshToken.RefreshToken;
|
||||||
|
return await _userLogic.RefreshToken(token);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
7
backend/API/Models/UserModels/RefreshTokenDTO.cs
Normal file
7
backend/API/Models/UserModels/RefreshTokenDTO.cs
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
namespace API.Models.UserModels
|
||||||
|
{
|
||||||
|
public class RefreshTokenDTO
|
||||||
|
{
|
||||||
|
public string RefreshToken { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -12,7 +12,7 @@ namespace API.Services
|
|||||||
_configuration = configuration;
|
_configuration = configuration;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<ChatCompletion> ChatGPT(string message, string language, int numberOfRecipes = 5)
|
public async Task<ChatCompletion> ChatGPT(string message, string language, int numberOfRecipes)
|
||||||
{
|
{
|
||||||
ChatClient client = new(
|
ChatClient client = new(
|
||||||
model: _configuration["OpenAI:Model"],
|
model: _configuration["OpenAI:Model"],
|
||||||
|
Loading…
Reference in New Issue
Block a user