|
|
package auth
|
|
|
|
|
|
import (
|
|
|
"fmt"
|
|
|
"gitlab.fjmaimaimai.com/mmm-go/ability/models"
|
|
|
"gitlab.fjmaimaimai.com/mmm-go/ability/protocol"
|
|
|
"gitlab.fjmaimaimai.com/mmm-go/gocomm/pkg/mybeego"
|
|
|
"gitlab.fjmaimaimai.com/mmm-go/gocomm/pkg/log"
|
|
|
"gitlab.fjmaimaimai.com/mmm-go/gocomm/pkg/mybeego"
|
|
|
"strings"
|
|
|
)
|
|
|
|
|
|
func Login(request *protocol.LoginRequest)*mybeego.Message{
|
|
|
user,err:=models.GetUsersByMobile(request.Phone)
|
|
|
func Login(request *protocol.LoginRequest)(rsp *protocol.LoginResponse,err error){
|
|
|
var (
|
|
|
user *models.Users
|
|
|
userInfo *models.UserInfo
|
|
|
)
|
|
|
user,err =models.GetUsersByMobile(request.Phone)
|
|
|
if err!=nil{
|
|
|
log.Error(err)
|
|
|
return mybeego.NewMessage(1)
|
|
|
return
|
|
|
}
|
|
|
switch request.GrantType {
|
|
|
case protocol.LoginPassPord:
|
...
|
...
|
@@ -23,19 +28,20 @@ func Login(request *protocol.LoginRequest)*mybeego.Message{ |
|
|
case protocol.LoginSmdcode:
|
|
|
goto Success
|
|
|
default:
|
|
|
return mybeego.NewErrMessage(2,"err grantType")
|
|
|
err =fmt.Errorf("grantType error")
|
|
|
return
|
|
|
}
|
|
|
Success:
|
|
|
{
|
|
|
userInfo,err :=models.GetUserInfoByMobile(request.Phone)
|
|
|
userInfo,err =models.GetUserInfoByMobile(request.Phone)
|
|
|
if err!=nil{
|
|
|
log.Error(err)
|
|
|
return mybeego.NewMessage(1)
|
|
|
return
|
|
|
}
|
|
|
rsp :=protocol.LoginResponse{AuthCode:userInfo.Auth}
|
|
|
msg :=mybeego.NewMessage(0)
|
|
|
msg.Data =rsp
|
|
|
return msg
|
|
|
return
|
|
|
}
|
|
|
return mybeego.NewMessage(1)
|
|
|
return
|
|
|
} |
|
|
\ No newline at end of file |
...
|
...
|
|