Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 20 additions & 20 deletions docs/LEANCLOUD-COUNTER-SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,32 +8,32 @@ Please note the difference between **site config file** and **theme config file*
- Go to Leancloud website [leancloud.cn](leancloud.cn) and sign up to Leancloud. Then login.
- Click `1` to enter the console:

![1](https://dn-cqha0xyi.qbox.me/fc0c048a1e25dc3d10aa.jpg)
![1](https://lc-cqha0xyi.cn-n1.lcfile.com/fc0c048a1e25dc3d10aa.jpg)

- Then click `1` to create an app:

![2](https://dn-cqha0xyi.qbox.me/33a56b754753a5d34b01.jpg)
![2](https://lc-cqha0xyi.cn-n1.lcfile.com/33a56b754753a5d34b01.jpg)

- Type your app name in `1` in the pop up window(eg. "test"), then choose `2`, which means developer's plan, and then click `3` to create the app:

![3](https://dn-cqha0xyi.qbox.me/649ccfc6f12015d1eefb.jpg)
![3](https://lc-cqha0xyi.cn-n1.lcfile.com/649ccfc6f12015d1eefb.jpg)

# Create Counter class and enable plugin in NexT
- Click `1`(app name) to enter the app manage page:

![4](https://dn-cqha0xyi.qbox.me/d0889df29841661e0b9e.jpg)
![4](https://lc-cqha0xyi.cn-n1.lcfile.com/d0889df29841661e0b9e.jpg)

- then click `1` to create a class for counter:

![5](https://dn-cqha0xyi.qbox.me/b0fbc81bd6c19fa09a46.jpg)
![5](https://lc-cqha0xyi.cn-n1.lcfile.com/b0fbc81bd6c19fa09a46.jpg)

- Type `Counter` in the pop up window in `1`, check `2`, then click `3`:

![6](https://dn-cqha0xyi.qbox.me/ae6154d6a55f02f11ebf.jpg)
![6](https://lc-cqha0xyi.cn-n1.lcfile.com/ae6154d6a55f02f11ebf.jpg)

- Click `1` to enter the app setting, then click `2`:

![8](https://dn-cqha0xyi.qbox.me/9501a6372918dd9a8a92.jpg)
![8](https://lc-cqha0xyi.cn-n1.lcfile.com/9501a6372918dd9a8a92.jpg)

- Paste `App ID` and `App Key` to **theme config file**`_config.yml` like this:
```yml
Expand All @@ -48,16 +48,16 @@ Please note the difference between **site config file** and **theme config file*

- Set domain whitelist: Click`1`, then type your domain into `2`(**protocol, domain and port should be exactly the same**):

![9](https://dn-cqha0xyi.qbox.me/0e537cc4bec2e185201d.jpg)
![9](https://lc-cqha0xyi.cn-n1.lcfile.com/0e537cc4bec2e185201d.jpg)

# Deploy web engine to avoid your data being changed illegally
- Click `1 -> 2 -> 3` by order

![10](https://dn-cqha0xyi.qbox.me/d7056dfeeef7c5d66318.jpg)
![10](https://lc-cqha0xyi.cn-n1.lcfile.com/d7056dfeeef7c5d66318.jpg)

- Click`1`:

![11](https://dn-cqha0xyi.qbox.me/2737841bbc2bdd572ae0.jpg)
![11](https://lc-cqha0xyi.cn-n1.lcfile.com/2737841bbc2bdd572ae0.jpg)

- In the pop up window, click `1` to choose type `Hook`, then choose`beforeUpdate` in `2`, choose `Counter` in `3`. Paste code below into `4`, then click `5` to save it:
```javascript
Expand All @@ -71,19 +71,19 @@ Please note the difference between **site config file** and **theme config file*
}
```

![12](https://dn-cqha0xyi.qbox.me/a8e13418ed1d9405315b.jpg)
![12](https://lc-cqha0xyi.cn-n1.lcfile.com/a8e13418ed1d9405315b.jpg)

- Click `1` to deploy after the message in the red rect shows up:

![13](https://dn-cqha0xyi.qbox.me/ca56bf2e5fc2a1343565.jpg)
![13](https://lc-cqha0xyi.cn-n1.lcfile.com/ca56bf2e5fc2a1343565.jpg)

- Click `1` in the pop up:

![14](https://dn-cqha0xyi.qbox.me/17548c13b3b23c71d845.jpg)
![14](https://lc-cqha0xyi.cn-n1.lcfile.com/17548c13b3b23c71d845.jpg)

- Click `1` to close the pop up window after the message in the red rect shows up:

![15](https://dn-cqha0xyi.qbox.me/d2f50de6cefea9fd0ed3.jpg)
![15](https://lc-cqha0xyi.cn-n1.lcfile.com/d2f50de6cefea9fd0ed3.jpg)

# Set access control for your database
- Open **theme config file**`_config.yml`, set `leancloud_visitors: security` to `true`:
Expand Down Expand Up @@ -145,27 +145,27 @@ Please note the difference between **site config file** and **theme config file*

- Return to the Leancloud console. Click `1 -> 2`, check if there is a record added in the _User (the img below is using username "admin" for example):

![16](https://dn-cqha0xyi.qbox.me/99faa5a0e7160e66d506.jpg)
![16](https://lc-cqha0xyi.cn-n1.lcfile.com/99faa5a0e7160e66d506.jpg)

- Click `1 -> 2 -> 3` by order:

![17](https://dn-cqha0xyi.qbox.me/b72a9e64579f5b71749d.jpg)
![17](https://lc-cqha0xyi.cn-n1.lcfile.com/b72a9e64579f5b71749d.jpg)

- Click `1`(add_fields), then choose `2`:

![18](https://dn-cqha0xyi.qbox.me/14a8cb37062693d768ad.jpg)
![18](https://lc-cqha0xyi.cn-n1.lcfile.com/14a8cb37062693d768ad.jpg)

- click `1`(create), then choose `2`, type the username in `3`, then click `4 -> 5`:

![19](https://dn-cqha0xyi.qbox.me/d91714cfd703ef42b94c.jpg)
![19](https://lc-cqha0xyi.cn-n1.lcfile.com/d91714cfd703ef42b94c.jpg)

Now your page should be similar to this img after finishing the step.

![20](https://dn-cqha0xyi.qbox.me/c05e7ec9218820baf412.jpg)
![20](https://lc-cqha0xyi.cn-n1.lcfile.com/c05e7ec9218820baf412.jpg)

- Click `1`(delete), then choose `2`:

![21](https://dn-cqha0xyi.qbox.me/c37b6e20726cfb1d3197.jpg)
![21](https://lc-cqha0xyi.cn-n1.lcfile.com/c37b6e20726cfb1d3197.jpg)

Now the bug is fixed.

Expand Down
40 changes: 20 additions & 20 deletions docs/zh-CN/LEANCLOUD-COUNTER-SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,34 +8,34 @@
- 首先,前往Leancloud官网[leancloud.cn](leancloud.cn)进行注册,并登陆。
- 然后点击图示`1`处,进入控制台:

![1](https://dn-cqha0xyi.qbox.me/fc0c048a1e25dc3d10aa.jpg)
![1](https://lc-cqha0xyi.cn-n1.lcfile.com/fc0c048a1e25dc3d10aa.jpg)

- 接着,点击图示`1`处,创建应用:

![2](https://dn-cqha0xyi.qbox.me/33a56b754753a5d34b01.jpg)
![2](https://lc-cqha0xyi.cn-n1.lcfile.com/33a56b754753a5d34b01.jpg)

- 在弹出窗口`1`处输入应用名称(可随意输入,可更改,为演示方便取名为test),并选择`2`处“开发版”,然后点击`3`处创建:

![3](https://dn-cqha0xyi.qbox.me/649ccfc6f12015d1eefb.jpg)
![3](https://lc-cqha0xyi.cn-n1.lcfile.com/649ccfc6f12015d1eefb.jpg)

到这里应用创建完成。

# 建立Counter类并在NexT中启用插件
- 点击`1`处应用名称进入应用管理界面:

![4](https://dn-cqha0xyi.qbox.me/d0889df29841661e0b9e.jpg)
![4](https://lc-cqha0xyi.cn-n1.lcfile.com/d0889df29841661e0b9e.jpg)

- 如图,点击侧边栏`1`处创建Class:

![5](https://dn-cqha0xyi.qbox.me/b0fbc81bd6c19fa09a46.jpg)
![5](https://lc-cqha0xyi.cn-n1.lcfile.com/b0fbc81bd6c19fa09a46.jpg)

- 在弹出窗口`1`处填入`Counter`,勾选`2`处无限制,并点击`3`处创建Class:

![6](https://dn-cqha0xyi.qbox.me/ae6154d6a55f02f11ebf.jpg)
![6](https://lc-cqha0xyi.cn-n1.lcfile.com/ae6154d6a55f02f11ebf.jpg)

- 此时类已创建完成。接下来点击图示`1`处进入设置,然后点击`2`处进入应用Key:

![8](https://dn-cqha0xyi.qbox.me/9501a6372918dd9a8a92.jpg)
![8](https://lc-cqha0xyi.cn-n1.lcfile.com/9501a6372918dd9a8a92.jpg)

- 粘贴`App ID`和`App Key`到**NexT主题配置文件**`_config.yml`对应位置。此时配置文件应如下:
```yml
Expand All @@ -48,18 +48,18 @@ leancloud_visitors:

- 设置Web安全域名确保域名调用安全。点击`1`处进入安全中心,然后在`2`处填写自己博客对应的域名(**注意协议、域名和端口号需严格一致**):

![9](https://dn-cqha0xyi.qbox.me/0e537cc4bec2e185201d.jpg)
![9](https://lc-cqha0xyi.cn-n1.lcfile.com/0e537cc4bec2e185201d.jpg)

到这里内容均与Doublemine的[为NexT主题添加文章阅读量统计功能](https://notes.wanghao.work/2015-10-21-%E4%B8%BANexT%E4%B8%BB%E9%A2%98%E6%B7%BB%E5%8A%A0%E6%96%87%E7%AB%A0%E9%98%85%E8%AF%BB%E9%87%8F%E7%BB%9F%E8%AE%A1%E5%8A%9F%E8%83%BD.html#%E9%85%8D%E7%BD%AELeanCloud)这篇文章相同,只不过截图为新版的Leancloud的界面。

# 部署云引擎以保证访客数量不被随意篡改
- 点击左侧`1`处云引擎,然后点击`2`处部署,再点击`3`处在线编辑:

![10](https://dn-cqha0xyi.qbox.me/d7056dfeeef7c5d66318.jpg)
![10](https://lc-cqha0xyi.cn-n1.lcfile.com/d7056dfeeef7c5d66318.jpg)

- 点击`1`处创建函数:

![11](https://dn-cqha0xyi.qbox.me/2737841bbc2bdd572ae0.jpg)
![11](https://lc-cqha0xyi.cn-n1.lcfile.com/2737841bbc2bdd572ae0.jpg)

- 在弹出窗口选择`1`处`Hook`类型,然后`2`处选择`beforeUpdate`,`3`处选择刚才建立的`Counter`类。在`4`中粘贴下方代码后,点`5`处保存。
```javascript
Expand All @@ -75,19 +75,19 @@ leancloud_visitors:

如图所示:

![12](https://dn-cqha0xyi.qbox.me/a8e13418ed1d9405315b.jpg)
![12](https://lc-cqha0xyi.cn-n1.lcfile.com/a8e13418ed1d9405315b.jpg)

- 点击保存后应出现类似红框处函数。此时点击`1`处部署:

![13](https://dn-cqha0xyi.qbox.me/ca56bf2e5fc2a1343565.jpg)
![13](https://lc-cqha0xyi.cn-n1.lcfile.com/ca56bf2e5fc2a1343565.jpg)

- 在弹出窗口点击`1`处部署:

![14](https://dn-cqha0xyi.qbox.me/17548c13b3b23c71d845.jpg)
![14](https://lc-cqha0xyi.cn-n1.lcfile.com/17548c13b3b23c71d845.jpg)

- 等待出现红框处的成功部署信息后,点击`1`处关闭:

![15](https://dn-cqha0xyi.qbox.me/d2f50de6cefea9fd0ed3.jpg)
![15](https://lc-cqha0xyi.cn-n1.lcfile.com/d2f50de6cefea9fd0ed3.jpg)


至此云引擎已成功部署,任何非法的访客数量更改请求都将失败。
Expand Down Expand Up @@ -152,27 +152,27 @@ leancloud_visitors:

- 返回Leancloud控制台的应用内。依次点击`1` `2`,检查_User表中是否出现一条记录(图示以用户名为admin为例):

![16](https://dn-cqha0xyi.qbox.me/99faa5a0e7160e66d506.jpg)
![16](https://lc-cqha0xyi.cn-n1.lcfile.com/99faa5a0e7160e66d506.jpg)

- 点击`1`处进入Counter表,依次点击`2` `3`,打开权限设置:

![17](https://dn-cqha0xyi.qbox.me/b72a9e64579f5b71749d.jpg)
![17](https://lc-cqha0xyi.cn-n1.lcfile.com/b72a9e64579f5b71749d.jpg)

- 点击`1`add_fields后选择`2`指定用户, 并将下两栏留空:

![18](https://dn-cqha0xyi.qbox.me/14a8cb37062693d768ad.jpg)
![18](https://lc-cqha0xyi.cn-n1.lcfile.com/14a8cb37062693d768ad.jpg)

- 点击`1`create后选择`2`指定用户, 在`3`处键入用户名,点击`4`处后点击`5`处添加:

![19](https://dn-cqha0xyi.qbox.me/d91714cfd703ef42b94c.jpg)
![19](https://lc-cqha0xyi.cn-n1.lcfile.com/d91714cfd703ef42b94c.jpg)

完成此步操作后,界面应与图示类似:

![20](https://dn-cqha0xyi.qbox.me/c05e7ec9218820baf412.jpg)
![20](https://lc-cqha0xyi.cn-n1.lcfile.com/c05e7ec9218820baf412.jpg)

- 点击`1`delete后选择`2`指定用户, 并将下两栏留空:

![21](https://dn-cqha0xyi.qbox.me/c37b6e20726cfb1d3197.jpg)
![21](https://lc-cqha0xyi.cn-n1.lcfile.com/c37b6e20726cfb1d3197.jpg)

至此权限已设置完成,数据库记录只能在本地增删。

Expand Down