Skip to content

Commit 89a72d4

Browse files
committed
Add delete user method
Also add content_available = true to Push notifications
1 parent abdef64 commit 89a72d4

4 files changed

Lines changed: 40 additions & 5 deletions

File tree

RequestTests.paw

-9.67 KB
Binary file not shown.

src/SimpleToDoService/Common/PushNotificationScheduler.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ async System.Threading.Tasks.Task CreatePushNotification(Task task)
9696
{
9797
app_id = Environment.GetEnvironmentVariable("ONE_SIGNAL_APP_ID"),
9898
contents = new { en = task.Description },
99+
content_available = true,
99100
filters = new[] { new { field = "tag", key = "user_id", relation = "=", value = repository.User(task.UserUuid).FirebaseId } },
100101
send_after = notificationDate.Value.ToString("yyyy-MM-dd HH:mm:ss 'GMT'zzzz")
101102
});

src/SimpleToDoService/Controllers/TasksController.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,6 @@ public Guid CurrentUserUuid
2323
get { return (Guid)HttpContext.Items["UserUuid"]; }
2424
}
2525

26-
public string CurrentUserFirebaseId
27-
{
28-
get { return HttpContext.User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.NameIdentifier).Value; }
29-
}
30-
3126
public TasksController(IToDoRepository repository)
3227
{
3328
this.repository = repository;
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
using System;
2+
using Microsoft.AspNetCore.Authorization;
3+
using Microsoft.AspNetCore.Mvc;
4+
using SimpleToDoService.Middleware;
5+
using SimpleToDoService.Repository;
6+
7+
namespace SimpleToDoService.Controllers
8+
{
9+
[Authorize]
10+
[MiddlewareFilter(typeof(CheckUserMiddleware))]
11+
[Route("api/v1/[controller]")]
12+
public class UsersController : Controller
13+
{
14+
private readonly IToDoRepository repository;
15+
16+
public Guid CurrentUserUuid
17+
{
18+
get { return (Guid)HttpContext.Items["UserUuid"]; }
19+
}
20+
21+
public UsersController(IToDoRepository repository)
22+
{
23+
this.repository = repository;
24+
}
25+
26+
[HttpDelete()]
27+
public IActionResult DeleteUser()
28+
{
29+
var user = repository.User(CurrentUserUuid);
30+
31+
if (user == null)
32+
return NotFound();
33+
34+
repository.DeleteUser(user);
35+
36+
return new StatusCodeResult(204);
37+
}
38+
}
39+
}

0 commit comments

Comments
 (0)