Skip to content

Commit

Permalink
更新文档
Browse files Browse the repository at this point in the history
  • Loading branch information
atjiu committed Apr 18, 2019
1 parent fbcf258 commit 9c9706f
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 4 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ mvn clean assembly:assembly

## 贡献

- 感谢 [@sunkaifei](https://github.com/sunkaifei) 提供的阿里云短信验证码登录要用到的 `key` `secret`
- 感谢 [@gdhua](https://github.com/gdhua) 提供的微信联合登录要用到的 `appid` `appsecret`

欢迎大家提 issues 及 pr

## 其它版本
Expand Down
Binary file added docs/assets/QQ20190418-153321.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions docs/zh-cn/_sidebar.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
- [配置Redis](zh-cn/redis)
- [上传配置](zh-cn/upload)
- [OAuth登录配置](zh-cn/oauth)
- [短信验证码登录配置](zh-cn/sms)
- [WebSocket配置](zh-cn/websocket)

- 部署
Expand Down
17 changes: 16 additions & 1 deletion docs/zh-cn/oauth.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
项目里实现了一个github登录功能,下面说一下配置方法
项目里实现了一个github登录功能,又实现了一个微信登录的功能

### Github登录配置方法

申请clientId, clientSecret地址:https://github.com/settings/developers 前提要先登录github

Expand All @@ -16,10 +18,23 @@

拷贝上图中红框内容,粘贴到网站后台系统设置页面里的 Github 配置信息里

刷新登录页面即可出现相应按钮

![](../assets/QQ20190418-153321.png)

**注意**

- 网站域名必须外网能访问,如是你要在内网测试,可以使用ngrok,frp等工具来做内网穿透,具体使用方法百度吧,网上很多
- 回调地址格式是 网站域名+/oauth/github/callback 假如你的域名是 `http://example.com` 那么这里的回调地址就是 `http://example.com/oauth/github/callback` 不要填错了

配置好之后,保存,再次回到首页,就可以看到页面 header 上就有了`Github登录`的入口了

### 微信登录配置方法

注册开放平台 http://open.weixin.qq.com 然后创建web应用,跟着步骤一步一步来就可以了,最后可以拿到 `appid` `appsecret` 加上在创建应用的时候填上的 `callback`

总共三个参数,都配置在`朋也社区`后台设置页面里`微信登录`区域,然后刷新登录页面,就有微信登录按钮了!!

![](../assets/QQ20190418-153321.png)

**感谢 [@gdhua](https://github.com/gdhua) 提供的微信联合登录要用到的 `appid` `appsecret`**
18 changes: 18 additions & 0 deletions docs/zh-cn/sms.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
在群友提供的阿里云短信的key, secret及模板的帮助下,朋也社区也有了短信验证码登录的功能了,配置如下

登录 http://aliyun.com ,打开 https://dysms.console.aliyun.com/dysms.htm?spm=5176.8195934.1283918..623230c9cuQEpk#/domestic/text/sign 链接

配置 `签名` `模板` `区域`

然后在 https://usercenter.console.aliyun.com/?spm=5176.12207334.0.0.8dae1cbeSq0lnd#/manage/ak 这个页面拿到 `key` `secret`

最后配置在项目后台的系统设置里,刷新登录页面,就会有手机号登录的按钮出现

![](../assets/QQ20190418-153321.png)

**注意**

- 短信服务目前只支持阿里云短信服务
- 申请模板的时候,动态内容的变量名是 `${code}` 请不要写成其它的

**感谢 [@sunkaifei](https://github.com/sunkaifei) 提供的阿里云短信验证码登录要用到的 `key` `secret`**
9 changes: 6 additions & 3 deletions src/main/java/co/yiiu/pybbs/config/service/SmsService.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public class SmsService {
private IAcsClient client;
private String signName;
private String templateCode;
private String regionId;

private SmsService() {
}
Expand All @@ -43,13 +44,15 @@ public IAcsClient instance() {
String secret = (String) systemConfigService.selectAllConfig().get("sms_secret");
signName = (String) systemConfigService.selectAllConfig().get("sms_sign_name");
templateCode = (String) systemConfigService.selectAllConfig().get("sms_template_code");
regionId = (String) systemConfigService.selectAllConfig().get("sms_region_id");
if (StringUtils.isEmpty(accessKeyId)
|| StringUtils.isEmpty(secret)
|| StringUtils.isEmpty(signName)
|| StringUtils.isEmpty(templateCode)) {
|| StringUtils.isEmpty(templateCode)
|| StringUtils.isEmpty(regionId)) {
return null;
}
DefaultProfile profile = DefaultProfile.getProfile("cn-hangzhou", accessKeyId, secret);
DefaultProfile profile = DefaultProfile.getProfile(regionId, accessKeyId, secret);
IAcsClient client = new DefaultAcsClient(profile);
this.client = client;
return client;
Expand All @@ -68,7 +71,7 @@ public boolean sendSms(String mobile, String code) {
request.setDomain("dysmsapi.aliyuncs.com");
request.setVersion("2017-05-25");
request.setAction("SendSms");
request.putQueryParameter("RegionId", "cn-hangzhou");
request.putQueryParameter("RegionId", regionId);
request.putQueryParameter("PhoneNumbers", mobile);
request.putQueryParameter("SignName", signName);
request.putQueryParameter("TemplateCode", templateCode);
Expand Down
3 changes: 3 additions & 0 deletions src/main/resources/db/migration/V1.8__add_sms_region_id.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
INSERT INTO `system_config` (`id`, `key`, `value`, `description`, `pid`, `type`, `option`, `reboot`)
VALUES
(58, 'sms_region_id', '', '短信服务所在区域 例如: cn-hangzhou', 49, 'text', NULL, 0);

0 comments on commit 9c9706f

Please sign in to comment.