From 5ca66f5819691c2483b9e728bd811d028c782599 Mon Sep 17 00:00:00 2001 From: Abdullah Atta Date: Mon, 22 May 2023 18:23:22 +0500 Subject: [PATCH] identity: save which platform a user signed up from this is normalized to web, android or iOS. Specific device information is not saved. --- ListMonk.SDK | 1 + Streetwriters.Identity/Controllers/SignupController.cs | 6 ++++++ 2 files changed, 7 insertions(+) create mode 160000 ListMonk.SDK diff --git a/ListMonk.SDK b/ListMonk.SDK new file mode 160000 index 0000000..4cb43f9 --- /dev/null +++ b/ListMonk.SDK @@ -0,0 +1 @@ +Subproject commit 4cb43f91bdc6a5dc0db292dfbccf7ad8b43f468c diff --git a/Streetwriters.Identity/Controllers/SignupController.cs b/Streetwriters.Identity/Controllers/SignupController.cs index 85f0aeb..18a606b 100644 --- a/Streetwriters.Identity/Controllers/SignupController.cs +++ b/Streetwriters.Identity/Controllers/SignupController.cs @@ -103,6 +103,7 @@ namespace Streetwriters.Identity.Controllers await UserManager.AddToRoleAsync(user, client.Id); if (Constants.IS_SELF_HOSTED) await UserManager.AddClaimAsync(user, UserService.SubscriptionTypeToClaim(client.Id, Common.Enums.SubscriptionType.PREMIUM)); + await UserManager.AddClaimAsync(user, new Claim("platform", PlatformFromUserAgent(base.HttpContext.Request.Headers.UserAgent))); var code = await UserManager.GenerateEmailConfirmationTokenAsync(user); var callbackUrl = Url.TokenLink(user.Id.ToString(), code, client.Id, TokenType.CONFRIM_EMAIL, Request.Scheme); @@ -116,5 +117,10 @@ namespace Streetwriters.Identity.Controllers return BadRequest(result.Errors.ToErrors()); } + + string PlatformFromUserAgent(string userAgent) + { + return userAgent.Contains("okhttp/") ? "android" : userAgent.Contains("Darwin/") || userAgent.Contains("CFNetwork/") ? "ios" : "web"; + } } }