|
|
@@ -1,19 +1,13 @@
|
|
|
package service
|
|
|
|
|
|
import (
|
|
|
- //"fmt"
|
|
|
- //"server/dao/gorm"
|
|
|
- //"server/dao/short_msg"
|
|
|
- //"server/dao/wx"
|
|
|
- //"server/errors"
|
|
|
- //"server/function"
|
|
|
- //"server/model"
|
|
|
- //"server/utils"
|
|
|
- //"strconv"
|
|
|
- //"time"
|
|
|
- h "video_course/repository/http"
|
|
|
-
|
|
|
+ "fmt"
|
|
|
"github.com/mojocn/base64Captcha"
|
|
|
+ "time"
|
|
|
+ "video_course/errors"
|
|
|
+ "video_course/global"
|
|
|
+ "video_course/model"
|
|
|
+ rdb "video_course/repository/redis"
|
|
|
)
|
|
|
|
|
|
var store = base64Captcha.DefaultMemStore
|
|
|
@@ -82,14 +76,25 @@ func (Auth) GenVerifyPic(config *base64Captcha.DriverString) (id string, pic str
|
|
|
}
|
|
|
|
|
|
// 手机号发送短信验证码
|
|
|
-func (a Auth) GenVFCode(codeTypeInt int, name string, ip string,
|
|
|
+func (a Auth) GenVFCode(codeTypeInt int, phone string, ip string,
|
|
|
picId string,
|
|
|
- picCode string) {
|
|
|
- //if !store.Verify(picId, picCode, true) {
|
|
|
- // panic(errors.ErrPicVerifyCode)
|
|
|
- //}
|
|
|
+ picCode string) (err error) {
|
|
|
+ //图形验证码验证
|
|
|
+ if !store.Verify(picId, picCode, true) {
|
|
|
+ return errors.ErrPicVerifyCode
|
|
|
+ }
|
|
|
+ //生成短信验证码
|
|
|
+ smsCode := "123456"
|
|
|
+ //发送短信
|
|
|
+ fmt.Println(smsCode)
|
|
|
+ //存储短信验证码
|
|
|
+ redisdb := rdb.GetRedis()
|
|
|
+ redisdb.Set(global.AppName+":"+"smsCode:"+phone, []byte(smsCode), 3*time.Minute)
|
|
|
+
|
|
|
+ return
|
|
|
+ //dao := a.getUserDao()
|
|
|
//_ = dao.User{}.GetUserByPhone(name)
|
|
|
- h.LoalloutServer{}.CheckPhone(name)
|
|
|
+ //h.LoalloutServer{}.CheckPhone(phone)
|
|
|
//codeType := model.VFCodeCodeTypeFromInt(codeTypeInt)
|
|
|
//vfcodeDao := dao.VFCode{}
|
|
|
//nameLastSend := vfcodeDao.NameLastSendTime(codeType, name)
|
|
|
@@ -116,18 +121,20 @@ func (a Auth) GenVFCode(codeTypeInt int, name string, ip string,
|
|
|
|
|
|
}
|
|
|
|
|
|
-//func (a Auth) PhoneSignIn(phone string, code string, channel model.LoginChannel, ip string) (
|
|
|
-// sess *model.Session, logInfo string) {
|
|
|
-//
|
|
|
-// gorm.VFCodeDAO{}.CheckVFCode(model.VFCodeCodeTypeLogin, phone, code)
|
|
|
-//
|
|
|
-// user := gorm.UserDAO{}.GetUserByPhone(phone)
|
|
|
-// user.CheckStatus()
|
|
|
-//
|
|
|
-// sess = function.Auth{}.WxLoginUser(user, channel, "", ip, phone, user.Phone)
|
|
|
-// logInfo = fmt.Sprintf("用户[%s]通过手机验证码登录", user.Name)
|
|
|
-// return
|
|
|
-//}
|
|
|
+func (a Auth) PhoneSignIn(phone string, smsCode string, ip string) (
|
|
|
+ sess *model.Session, err error) {
|
|
|
+
|
|
|
+ //sess = NewSession
|
|
|
+ //
|
|
|
+ //gorm.VFCodeDAO{}.CheckVFCode(model.VFCodeCodeTypeLogin, phone, code)
|
|
|
+ //
|
|
|
+ //user := gorm.UserDAO{}.GetUserByPhone(phone)
|
|
|
+ //user.CheckStatus()
|
|
|
+ //
|
|
|
+ //sess = function.Auth{}.WxLoginUser(user, channel, "", ip, phone, user.Phone)
|
|
|
+ //logInfo = fmt.Sprintf("用户[%s]通过手机验证码登录", user.Name)
|
|
|
+ return
|
|
|
+}
|
|
|
|
|
|
//func (a Auth) PassEdit(sess *model.Session, oldpass string, newpass string) (
|
|
|
// logInfo string, err error) {
|