();
+ claims.Add(new Claim(ClaimTypes.NameIdentifier, user.Id.ToString()));
+ claims.Add(new Claim(ClaimTypes.Name, user.UserName));
var roles = await _userManager.GetRolesAsync(user);
- var token = _jwt.GenerateJwtToken(user,roles);
-
- var frontendCallback = $"{Request.Query["frontendCallback"]}?token={token}";
+ foreach (string role in roles)
+ {
+ claims.Add(new Claim(ClaimTypes.Role, role));
+ }
+ string jwtToken = _jwt.BuildToken(claims, jwtOptions.Value);
+
+
+ var frontendCallback = $"{Request.Query["frontendCallback"]}?token={jwtToken}";
return Redirect(frontendCallback);
}
diff --git a/AGSS/Areas/Identity/Pages/Account/Register.cshtml b/AGSS/Areas/Identity/Pages/Account/Register.cshtml
index cdbeffe..eba2f18 100644
--- a/AGSS/Areas/Identity/Pages/Account/Register.cshtml
+++ b/AGSS/Areas/Identity/Pages/Account/Register.cshtml
@@ -12,6 +12,11 @@
创建新账户。
+
+
+
+
+