Merge branch 'beta' into x/sqlx

x/navis
Michael Li 1 year ago
commit 9ac483f996
No known key found for this signature in database

@ -517,6 +517,17 @@ x/sqlx
**代码分支演进图**
![](docs/proposal/.assets/000-01.png)
### 部署站点信息
* [官方 paopao.info](https://www.paopao.info)
> 具体部署站点信息请查阅 [deployed-sites](./deployed-sites.md 'deployed sites'). 欢迎站长将已部署PaoPao实例的站点信息添加到 [deployed-sites](./deployed-sites.md 'deployed sites') 列表中。
#### Collaborator's paopao account
| 昵称 | [@GitHub](https://github.com 'github.com') | [@PaoPao](https://www.paopao.info 'paopao.info') |
| ----- | ----- | ----- |
| ROC | [ROC](https://github.com/rocboss 'ROC')|[ROC](https://www.paopao.info/#/user?username=roc 'ROC @roc')|
| 北野 | [Michael Li](https://github.com/alimy 'Michael Li') | [alimy](https://www.paopao.info/#/user?username=alimy '北野 @alimy')|
| orzi!| [orzi!](https://github.com/orziz 'orzi!')||
### 其他说明
建议后端服务使用 `supervisor` 守护进程,并通过 `nginx` 反向代理后提供API给前端服务调用。

@ -0,0 +1,6 @@
## 部署站点
PaoPao部署站点信息。
| 名称 | 网址 | 备注 |
| ----- | ----- | ----- |
|泡泡|[www.paopao.info](https://www.paopao.info)|PaoPao官方站点|

@ -11,7 +11,6 @@ import (
"time"
"unicode/utf8"
"github.com/alimy/cfg"
"github.com/alimy/mir/v3"
"github.com/gin-gonic/gin"
api "github.com/rocboss/paopao-ce/auto/api/v1"
@ -34,8 +33,6 @@ var (
_ api.Core = (*coreSrv)(nil)
_ api.CoreBinding = (*coreBinding)(nil)
_ api.CoreRender = (*coreRender)(nil)
_EnablePhoneVerify = cfg.If("Sms")
)
type coreSrv struct {
@ -284,19 +281,12 @@ func (s *coreSrv) GetCollections(req *web.GetCollectionsReq) (*web.GetCollection
func (s *coreSrv) UserPhoneBind(req *web.UserPhoneBindReq) mir.Error {
// 手机重复性检查
u, err := s.Ds.GetUserByPhone(req.Phone)
if err != nil {
logrus.Errorf("Ds.GetUserByPhone err: %v", err)
return _errExistedUserPhone
}
if u.Model == nil || u.ID == 0 {
return _errExistedUserPhone
}
if u.ID == req.User.ID {
if err == nil && u.Model != nil && u.ID != 0 && u.ID != req.User.ID {
return _errExistedUserPhone
}
// 如果禁止phone verify 则允许通过任意验证码
if !_EnablePhoneVerify {
if _EnablePhoneVerify {
c, err := s.Ds.GetLatestPhoneCaptcha(req.Phone)
if err != nil {
return _errErrorPhoneCaptcha

@ -204,6 +204,7 @@ func (s *pubSrv) SendCaptcha(req *web.SendCaptchaReq) mir.Error {
// 验证图片验证码
if res, err := s.Redis.Get(ctx, "PaoPaoCaptcha:"+req.ImgCaptchaID).Result(); err != nil || res != req.ImgCaptcha {
logrus.Debugf("get captcha err:%s expect:%s got:%s", err, res, req.ImgCaptcha)
return _errErrorCaptchaPassword
}
s.Redis.Del(ctx, "PaoPaoCaptcha:"+req.ImgCaptchaID).Result()

@ -5,6 +5,8 @@
package web
import (
"sync"
"github.com/alimy/cfg"
"github.com/gin-gonic/gin"
api "github.com/rocboss/paopao-ce/auto/api/v1"
@ -15,8 +17,14 @@ import (
"github.com/smartwalle/alipay/v3"
)
var (
_EnablePhoneVerify bool
_onceInitial sync.Once
)
// RouteWeb register web route
func RouteWeb(e *gin.Engine) {
lazyInitial()
oss := dao.ObjectStorageService()
ds := &base.DaoServant{
Redis: conf.MustRedis(),
@ -66,3 +74,10 @@ func mustAlipayClient() *alipay.Client {
}
return client
}
// lazyInitial do some package lazy initialize for performance
func lazyInitial() {
_onceInitial.Do(func() {
_EnablePhoneVerify = cfg.If("Sms")
})
}

Loading…
Cancel
Save