Merge pull request 'Le créateur vient de l'authentification, donc on ne le prend pas du post' (#10) from fix/OIDC-debugging into main
Reviewed-on: #10
This commit is contained in:
commit
ead74b7cff
3 changed files with 23 additions and 13 deletions
25
.vscode/tasks.json
vendored
25
.vscode/tasks.json
vendored
|
|
@ -13,16 +13,17 @@
|
||||||
"isBackground": true
|
"isBackground": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"label": "build-web",
|
"label": "test blogs backend",
|
||||||
"type": "process",
|
"type": "process",
|
||||||
"problemMatcher": ["$msCompile"],
|
"problemMatcher": ["$msCompile"],
|
||||||
"command": "dotnet",
|
"command": "dotnet",
|
||||||
"args": ["build"],
|
"args": ["test"],
|
||||||
"options": {
|
"options": {
|
||||||
"cwd": "src/Yavsc.Org"
|
"cwd": "src/Yavsc.Blogs.Tests"
|
||||||
},
|
},
|
||||||
"group": {
|
"group": {
|
||||||
"kind": "build"
|
"kind": "test",
|
||||||
|
"isDefault": false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -40,17 +41,23 @@
|
||||||
"isBackground": true
|
"isBackground": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"label": "build-web",
|
"label": "test blogs",
|
||||||
"type": "process",
|
"type": "process",
|
||||||
"problemMatcher": ["$msCompile"],
|
"problemMatcher": ["$msCompile"],
|
||||||
"command": "dotnet",
|
"command": "dotnet",
|
||||||
"args": ["build"],
|
"args": ["test"],
|
||||||
"runOptions": {},
|
"runOptions": {
|
||||||
|
"instanceLimit": 1
|
||||||
|
},
|
||||||
"options": {
|
"options": {
|
||||||
"cwd": "src/Yavsc.Web"
|
"cwd": "src/Yavsc.Blogs",
|
||||||
|
"env": {
|
||||||
|
"DOTNET_CLI_UI_LANGUAGE": "en-US",
|
||||||
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"group": {
|
"group": {
|
||||||
"kind": "build"
|
"kind": "test"
|
||||||
},
|
},
|
||||||
"isBackground": true,
|
"isBackground": true,
|
||||||
"presentation": {
|
"presentation": {
|
||||||
|
|
|
||||||
|
|
@ -114,7 +114,8 @@ namespace Yavsc.Blogs.Controllers
|
||||||
var files = Request.HasFormContentType
|
var files = Request.HasFormContentType
|
||||||
? Request.Form.Files
|
? Request.Form.Files
|
||||||
: (IFormFileCollection)new FormFileCollection();
|
: (IFormFileCollection)new FormFileCollection();
|
||||||
var post = blogSpotService.Create(User.GetUserId(), blog, files);
|
var uid = User.GetUserId();
|
||||||
|
var post = blogSpotService.Create(uid, blog, files);
|
||||||
return CreatedAtRoute("GetBlog", new { id = post.Id }, post);
|
return CreatedAtRoute("GetBlog", new { id = post.Id }, post);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,8 @@ public class BlogSpotService
|
||||||
public BlogPost Create(string userId, BlogPost post, IFormFileCollection files)
|
public BlogPost Create(string userId, BlogPost post, IFormFileCollection files)
|
||||||
{
|
{
|
||||||
// Sauvegarder le post d'abord pour obtenir son ID
|
// Sauvegarder le post d'abord pour obtenir son ID
|
||||||
|
// Le créateur vient de l'authentification, donc on ne le prend pas du post
|
||||||
|
post.AuthorId = userId;
|
||||||
_context.BlogSpot.Add(post);
|
_context.BlogSpot.Add(post);
|
||||||
_context.SaveChanges(userId);
|
_context.SaveChanges(userId);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue