Browse Source

Merge pull request #5029 from paulfwilliams/patch-1

correct docs wording of Principle to Principal
pull/5037/head
liangshiwei 6 years ago
committed by GitHub
parent
commit
9a0059dade
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 12
      docs/en/CurrentUser.md
  2. 12
      docs/zh-Hans/CurrentUser.md

12
docs/en/CurrentUser.md

@ -1,4 +1,4 @@
# Current User
# Current User
It is very common to retrieve the information about the logged in user in a web application. The current user is the active user related to the current request in a web application.
@ -86,7 +86,7 @@ Beside these standard methods, there are some extension methods:
## ICurrentPrincipalAccessor
`ICurrentPrincipalAccessor` is the service that should be used (by the ABP Framework and your application code) whenever the current principle of the current user is needed.
`ICurrentPrincipalAccessor` is the service that should be used (by the ABP Framework and your application code) whenever the current principal of the current user is needed.
For a web application, it gets the `User` property of the current `HttpContext`. For a non-web application, it returns the `Thread.CurrentPrincipal`.
@ -114,9 +114,9 @@ public class MyService : ITransientDependency
}
````
### Changing the Current Principle
### Changing the Current Principal
Current principle is not something you want to set or change, except at some advanced scenarios. If you need it, use the `Change` method of the `ICurrentPrincipalAccessor`. It takes a `ClaimsPrinciple` object and makes it "current" for a scope.
Current principal is not something you want to set or change, except at some advanced scenarios. If you need it, use the `Change` method of the `ICurrentPrincipalAccessor`. It takes a `ClaimsPrincipal` object and makes it "current" for a scope.
Example:
@ -132,7 +132,7 @@ public class MyAppService : ApplicationService
public void Foo()
{
var newPrinciple = new ClaimsPrincipal(
var newPrincipal = new ClaimsPrincipal(
new ClaimsIdentity(
new Claim[]
{
@ -143,7 +143,7 @@ public class MyAppService : ApplicationService
)
);
using (_currentPrincipalAccessor.Change(newPrinciple))
using (_currentPrincipalAccessor.Change(newPrincipal))
{
var userName = CurrentUser.UserName; //returns "john"
//...

12
docs/zh-Hans/CurrentUser.md

@ -86,7 +86,7 @@ namespace AbpDemo
## ICurrentPrincipalAccessor
`ICurrentPrincipalAccessor` 是当需要当前用户的principle时使用的服务(由ABP框架和你的应用程序代码使用).
`ICurrentPrincipalAccessor` 是当需要当前用户的Principal时使用的服务(由ABP框架和你的应用程序代码使用).
对于Web应用程序, 它获取当前 `HttpContext``User` 属性,对于非Web应用程序它将返回 `Thread.CurrentPrincipal`.
@ -114,9 +114,9 @@ public class MyService : ITransientDependency
}
````
### 更改当前Principle
### 更改当前Principal
除了某些高级场景外,你不需要设置或更改当前principle. 如果需要可以使用 `ICurrentPrincipalAccessor``Change` 方法. 它接受一个 `ClaimsPrinciple` 对象并使其成为作用域的"当前"对象.
除了某些高级场景外,你不需要设置或更改当前Principal. 如果需要可以使用 `ICurrentPrincipalAccessor``Change` 方法. 它接受一个 `ClaimsPrincipal` 对象并使其成为作用域的"当前"对象.
示例:
@ -132,7 +132,7 @@ public class MyAppService : ApplicationService
public void Foo()
{
var newPrinciple = new ClaimsPrincipal(
var newPrincipal = new ClaimsPrincipal(
new ClaimsIdentity(
new Claim[]
{
@ -143,7 +143,7 @@ public class MyAppService : ApplicationService
)
);
using (_currentPrincipalAccessor.Change(newPrinciple))
using (_currentPrincipalAccessor.Change(newPrincipal))
{
var userName = CurrentUser.UserName; //returns "john"
//...
@ -164,4 +164,4 @@ public class MyAppService : ApplicationService
* 其他属性,如 `EmailVerified`, `PhoneNumber`, `TenantId` ...是由ABP框架通过尽可能遵循标准名称来定义的.
建议使用这个类的属性来代替声明名称的魔术字符串.
建议使用这个类的属性来代替声明名称的魔术字符串.

Loading…
Cancel
Save