identity: save which platform a user signed up from

this is normalized to web, android or iOS.
Specific device information is not saved.
This commit is contained in:
Abdullah Atta
2023-05-22 18:23:22 +05:00
parent 4b67b7eedb
commit 5ca66f5819
2 changed files with 7 additions and 0 deletions

1
ListMonk.SDK Submodule

Submodule ListMonk.SDK added at 4cb43f91bd

View File

@@ -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";
}
}
}