mirror of
https://github.com/QuotifyTeam/QuotifyBE.git
synced 2025-12-16 15:40:07 +01:00
fix: fixes to addQuote (don't require categories nor imageUrl)
also sends back role upon login
This commit is contained in:
@@ -141,13 +141,13 @@ public class QuotesController : ControllerBase
|
|||||||
Author = request.Author,
|
Author = request.Author,
|
||||||
CreatedAt = DateTime.UtcNow,
|
CreatedAt = DateTime.UtcNow,
|
||||||
LastUpdatedAt = DateTime.UtcNow,
|
LastUpdatedAt = DateTime.UtcNow,
|
||||||
ImageId = image?.Id ?? 0,
|
ImageId = image?.Id ?? null,
|
||||||
UserId = userId,
|
UserId = userId,
|
||||||
QuoteCategories = new List<QuoteCategory>()
|
QuoteCategories = new List<QuoteCategory>()
|
||||||
};
|
};
|
||||||
|
|
||||||
// Attach categories
|
// Attach categories
|
||||||
foreach (var categoryId in request.CategoryIds)
|
foreach (var categoryId in request.CategoryIds ?? [])
|
||||||
{
|
{
|
||||||
var categoryExists = await _db.Categories.AnyAsync(c => c.Id == categoryId);
|
var categoryExists = await _db.Categories.AnyAsync(c => c.Id == categoryId);
|
||||||
if (!categoryExists)
|
if (!categoryExists)
|
||||||
|
|||||||
@@ -29,7 +29,8 @@ namespace QuotifyBE.Controllers
|
|||||||
Name="admin",
|
Name="admin",
|
||||||
Email = "admin@mail.com",
|
Email = "admin@mail.com",
|
||||||
// hashed twice, once by frontend, and second time by backend
|
// hashed twice, once by frontend, and second time by backend
|
||||||
PasswordHash = guhf.HashWithSHA512(guhf.HashWithSHA512("admin"))
|
PasswordHash = guhf.HashWithSHA512(guhf.HashWithSHA512("admin")),
|
||||||
|
Role = 0 // role 0 - greatest power, admin, role 0 > role 1
|
||||||
};
|
};
|
||||||
_db.Users.Add(Admin);
|
_db.Users.Add(Admin);
|
||||||
await _db.SaveChangesAsync();
|
await _db.SaveChangesAsync();
|
||||||
|
|||||||
@@ -2,6 +2,6 @@ public record class CreateQuoteDTO
|
|||||||
{
|
{
|
||||||
public string Text { get; set; }
|
public string Text { get; set; }
|
||||||
public string Author { get; set; }
|
public string Author { get; set; }
|
||||||
public List<int> CategoryIds { get; set; }
|
public List<int>? CategoryIds { get; set; }
|
||||||
public string? ImageUrl { get; set; }
|
public string? ImageUrl { get; set; }
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -5,6 +5,6 @@ public record class UserInfoDTO
|
|||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
required public string Name { get; set; }
|
required public string Name { get; set; }
|
||||||
required public string Email { get; set; }
|
required public string Email { get; set; }
|
||||||
public int Role { get; set; }
|
public int Role { get; set; }
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user