|
|
package auth
|
|
|
|
|
|
import (
|
|
|
"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"
|
|
|
"strings"
|
|
|
)
|
|
|
|
|
|
func Login(request *protocol.LoginRequest)*mybeego.Message{
|
|
|
user,err:=models.GetUsersByMobile(request.Phone)
|
|
|
if err!=nil{
|
|
|
log.Error(err)
|
|
|
return mybeego.NewMessage(1)
|
|
|
}
|
|
|
switch request.GrantType {
|
|
|
case protocol.LoginPassPord:
|
|
|
if strings.Compare(user.Password,request.PassWord)==0{
|
|
|
goto Success
|
|
|
}
|
|
|
break
|
|
|
case protocol.LoginSmdcode:
|
|
|
goto Success
|
|
|
default:
|
|
|
return mybeego.NewErrMessage(2,"err grantType")
|
|
|
}
|
|
|
Success:
|
|
|
{
|
|
|
userInfo,err :=models.GetUserInfoByMobile(request.Phone)
|
|
|
if err!=nil{
|
|
|
log.Error(err)
|
|
|
return mybeego.NewMessage(1)
|
|
|
}
|
|
|
rsp :=protocol.LoginResponse{AuthCode:userInfo.Auth}
|
|
|
msg :=mybeego.NewMessage(0)
|
|
|
msg.Data =rsp
|
|
|
return msg
|
|
|
}
|
|
|
return mybeego.NewMessage(1)
|
|
|
} |
|
|
\ No newline at end of file |
...
|
...
|
|