Ejemplo n.º 1
0
//Token登陆
func (service *superRpc) AuthByToken(req *msg.OAtuhTokenLogin, res *msg.OAuth2Response) error {
	data := service.super.FindBySinaID(req.GetToken())
	if data == nil {
		res.RetCode = proto.Uint32(uint32(msg.OAtuhRetCode_TOKEN_NOT_FOUND))
	} else {
		res.RetCode = proto.Uint32(uint32(msg.OAtuhRetCode_AUTH_OK))
		res.Accid = proto.Uint64(data.GetAccid())
		res.AuthSid = proto.Uint64(0)
		res.User = data
	}
	return nil
}
Ejemplo n.º 2
0
//等待Sina授权返回结果
func (service *superRpc) WaitAuthResultBySina(req *msg.OAuth2Request, res *msg.OAuth2Response) error {
	if ch, ok := service.auths[req.GetAuthSid()]; ok {
		defer delete(service.auths, req.GetAuthSid())
		data := <-ch
		if data != nil {
			user := service.super.FindBySinaID(data.AuthUID)
			if user != nil {

			} else {
				res.RetCode = proto.Uint32(uint32(msg.OAtuhRetCode_AUTH_OK))
				res.Accid = proto.Uint64(req.GetAccid())
				res.AuthSid = proto.Uint64(req.GetAuthSid())
				res.User = new(msg.OAtuhUserProfile)
				res.User.Accid = proto.Uint64(req.GetAccid())
				res.User.Oauth = proto.String(data.ServiceName)
				res.User.Name = proto.String(data.AuthName)
			}
		} else {
			res.RetCode = proto.Uint32(uint32(msg.OAtuhRetCode_SINA_AUTH_FAILED))
		}
	}
	return nil
}