Skip to content

Commit 57406cf

Browse files
committed
Add user to group on first login.
1 parent 0741bbb commit 57406cf

File tree

16 files changed

+84
-49
lines changed

16 files changed

+84
-49
lines changed

.vscode/settings.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
22
"appService.preDeployTask": "publish-release",
33
"appService.deploySubpath": "bin\\Release\\net5.0\\publish",
4-
"appService.defaultWebAppToDeploy": "/subscriptions/84c290c7-23ff-45f5-9f6b-41a65b683505/resourceGroups/appsvc_windows_centralus/providers/Microsoft.Web/sites/mittbalans",
54
"azureFunctions.deploySubpath": "bin/Release/netcoreapp3.1/publish",
65
"azureFunctions.projectLanguage": "C#",
76
"azureFunctions.projectRuntime": "~3",
87
"debug.internalConsoleOptions": "neverOpen",
9-
"azureFunctions.preDeployTask": "publish"
8+
"azureFunctions.preDeployTask": "publish",
9+
"appService.defaultWebAppToDeploy": "/subscriptions/84c290c7-23ff-45f5-9f6b-41a65b683505/resourceGroups/Claes/providers/Microsoft.Web/sites/balans-api"
1010
}

.vscode/tasks.json

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -82,16 +82,6 @@
8282
"type": "process",
8383
"dependsOn": "clean release",
8484
"problemMatcher": "$msCompile"
85-
},
86-
{
87-
"type": "func",
88-
"dependsOn": "build",
89-
"options": {
90-
"cwd": "${workspaceFolder}/bin/Debug/netcoreapp3.1"
91-
},
92-
"command": "host start",
93-
"isBackground": true,
94-
"problemMatcher": "$func-dotnet-watch"
9585
}
9686
]
9787
}

Books.csproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,10 @@
1010
<PackageReference Include="Newtonsoft.json" Version="12.0.3" />
1111
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.6.3" />
1212
</ItemGroup>
13+
<ItemGroup>
14+
<Content Remove="client\**" />
15+
<Compile Remove="client\**" />
16+
<EmbeddedResource Remove="client\**" />
17+
<None Remove="client\**" />
18+
</ItemGroup>
1319
</Project>

Properties/launchSettings.json

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"iisSettings": {
3+
"windowsAuthentication": false,
4+
"anonymousAuthentication": true,
5+
"iisExpress": {
6+
"applicationUrl": "http://localhost:20895/",
7+
"sslPort": 44307
8+
}
9+
},
10+
"profiles": {
11+
"IIS Express": {
12+
"commandName": "IISExpress",
13+
"launchBrowser": true,
14+
"environmentVariables": {
15+
"ASPNETCORE_ENVIRONMENT": "Development"
16+
}
17+
},
18+
"Books": {
19+
"commandName": "Project",
20+
"launchBrowser": true,
21+
"environmentVariables": {
22+
"ASPNETCORE_ENVIRONMENT": "Development"
23+
},
24+
"applicationUrl": "https://localhost:5001;http://localhost:5000"
25+
}
26+
}
27+
}

api/Controllers/GroupController.cs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,13 @@ namespace Books.Api.Controllers
33
using Microsoft.AspNetCore.Mvc;
44
using System.Collections.Generic;
55

6-
using Books.Api.Models;
7-
using Books.Api.Services;
8-
96
[Route("api/[controller]")]
107
[ApiController]
118
public class GroupController : ControllerBase
129
{
13-
private readonly GroupService _groupService;
10+
private readonly Services.GroupService _groupService;
1411

15-
public GroupController(GroupService groupService)
12+
public GroupController(Services.GroupService groupService)
1613
{
1714
_groupService = groupService;
1815
}
@@ -21,7 +18,7 @@ public GroupController(GroupService groupService)
2118
public ActionResult<List<Models.Group>> Get() =>
2219
_groupService.Get();
2320

24-
[HttpGet("{id:length(36)}", Name = "GetUserGroups")]
21+
[HttpGet("User/{id:length(36)}", Name = "GetUserGroups")]
2522
public ActionResult<List<Models.Group>> Get(string id)
2623
{
2724
var groups = _groupService.Get(id);
@@ -34,7 +31,7 @@ public GroupController(GroupService groupService)
3431
return groups;
3532
}
3633

37-
[HttpGet("{id:length(24)}", Name = "GetUserGroup")]
34+
[HttpGet("{id:length(24)}", Name = "GetGroup")]
3835
public ActionResult<Models.Group> GetUserGroup(string id)
3936
{
4037
var group = _groupService.GetGroup(id);

api/Services/GroupService.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,11 @@ public Group Create(Models.Group group)
3131
{
3232
group.Id = MongoDB.Bson.ObjectId.GenerateNewId().ToString();
3333

34-
_groups.InsertOne(group);
35-
34+
if(_groups.CountDocuments(g => g.AzId == group.AzId && g.GroupName == group.GroupName) < 1)
35+
{
36+
_groups.InsertOne(group);
37+
}
38+
3639
return group;
3740
}
3841
}

bin/Debug/net5.0/Books.dll

0 Bytes
Binary file not shown.

bin/Debug/net5.0/Books.pdb

44 Bytes
Binary file not shown.

bin/Debug/net5.0/ref/Books.dll

0 Bytes
Binary file not shown.

client/public/signin-callback.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ <h1>Authentification callback processing...</h1>
1717
//new Oidc.UserManager({ response_mode: "query" }).signinRedirectCallback().then(function () {
1818
// Settings loadUserInfo: false because b2c does not currently support userinfo endpoint.
1919
new Oidc.UserManager({ response_mode: "query", loadUserInfo: false }).signinRedirectCallback().then(function () {
20-
20+
2121
window.location = "index.html";
2222
}).catch(function (e) {
2323
console.error(e);

0 commit comments

Comments
 (0)