• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang dozy.AuthContext类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中dozy.AuthContext的典型用法代码示例。如果您正苦于以下问题:Golang AuthContext类的具体用法?Golang AuthContext怎么用?Golang AuthContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了AuthContext类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: GetRideLikes

func GetRideLikes(reqJson []byte, qs map[string][]string, uri []string, ac *dozy.AuthContext, rawDb interface{}) (uint, []byte, string) {
	db := rawDb.(GetRideLikesDb)

	rideId, err := strconv.Atoi(uri[1])
	if err != nil {
		panic(err)
	}

	startingLikeNum, err1 := strconv.Atoi(qs["startingLikeNum"][0])
	if err1 != nil {
		panic(err1)
	}

	numLikesToFetch, err2 := strconv.Atoi(qs["numLikesToFetch"][0])
	if err2 != nil {
		panic(err2)
	}

	if numLikesToFetch > 25 {
		return dozy.StatusBadRequest, []byte(""), ""
	}

	if !ac.GetLoggedIn() {
		return dozy.StatusIncorrectPermissions, []byte(""), ""
	}

	status, returnJson := db.GetLikes(uint(rideId), startingLikeNum, numLikesToFetch)
	if status != mongodb.ReadSucceeded {
		return dozy.StatusBadRequest, []byte(""), ""
	}

	return dozy.StatusGetOk, returnJson, ""

}
开发者ID:hdiwan,项目名称:RedRoute,代码行数:34,代码来源:ride.go


示例2: GetRideLikesUser

func GetRideLikesUser(reqJson []byte, qs map[string][]string, uri []string, ac *dozy.AuthContext, rawDb interface{}) (uint, []byte, string) {
	db := rawDb.(GetRideLikesUserDb)

	rideId, err := strconv.Atoi(uri[1])
	if err != nil {
		panic(err)
	}

	userId, err := strconv.Atoi(uri[3])
	if err != nil {
		panic(err)
	}

	if !ac.GetLoggedIn() {
		return dozy.StatusIncorrectPermissions, []byte(""), ""
	}

	status, returnJson := db.DidLike(uint(rideId), uint(userId))
	if status != mongodb.ReadSucceeded {
		return dozy.StatusBadRequest, []byte(""), ""
	}

	return dozy.StatusGetOk, returnJson, ""

}
开发者ID:hdiwan,项目名称:RedRoute,代码行数:25,代码来源:ride.go


示例3: PutRideLikesUser

func PutRideLikesUser(reqJson []byte, qs map[string][]string, uri []string, ac *dozy.AuthContext, rawDb interface{}) (uint, []byte, string) {
	db := rawDb.(PutRideLikesUserDb)

	rideId, err := strconv.Atoi(uri[1])
	if err != nil {
		panic(err)
	}

	userId, err := strconv.Atoi(uri[3])
	if err != nil {
		panic(err)
	}

	if !ac.GetLoggedIn() || ac.GetUserId() != uint(userId) {
		return dozy.StatusIncorrectPermissions, []byte(""), ""
	}

	isLiked := bson.M{}
	unmarshalErr := json.Unmarshal(reqJson, &isLiked)
	if unmarshalErr != nil {
		panic(unmarshalErr)
	}

	status, returnJson := db.AddLike(uint(rideId), uint(userId), isLiked["isLiked"].(bool))
	if status != mongodb.WriteSucceeded {
		return dozy.StatusBadRequest, []byte(""), ""
	}

	return dozy.StatusGetOk, returnJson, ""
}
开发者ID:hdiwan,项目名称:RedRoute,代码行数:30,代码来源:ride.go


示例4: PostRideComments

func PostRideComments(reqJson []byte, qs map[string][]string, uri []string, ac *dozy.AuthContext, rawDb interface{}) (uint, []byte, string) {
	db := rawDb.(PostRideCommentsDb)

	comment := bson.M{}
	unmarshalErr := json.Unmarshal(reqJson, &comment)
	if unmarshalErr != nil {
		panic(unmarshalErr)
	}

	rideId, err := strconv.Atoi(uri[1])
	if err != nil {
		panic(err)
	}

	if !ac.GetLoggedIn() {
		return dozy.StatusIncorrectPermissions, []byte(""), ""
	}

	status, returnJson, location := db.PostComment(uint(rideId), ac.GetUserId(), comment["content"].(string))
	if status != mongodb.WriteSucceeded {
		return dozy.StatusBadRequest, []byte(""), ""
	}

	return dozy.StatusPutOk, returnJson, location

}
开发者ID:hdiwan,项目名称:RedRoute,代码行数:26,代码来源:ride.go


示例5: PutRideTip

func PutRideTip(reqJson []byte, qs map[string][]string, uri []string, ac *dozy.AuthContext, rawDb interface{}) (uint, []byte, string) {
	db := rawDb.(PutRideTipDb)

	tip := bson.M{}
	unmarshalErr := json.Unmarshal(reqJson, &tip)
	if unmarshalErr != nil {
		panic(unmarshalErr)
	}

	rideId, err := strconv.Atoi(uri[1])
	if err != nil {
		panic(err)
	}

	if !ac.GetLoggedIn() {
		return dozy.StatusIncorrectPermissions, []byte(""), ""
	}

	status, returnJson := db.UpdateTip(uint(rideId), ac.GetUserId(), uint(tip["tip"].(int)))
	if status != mongodb.WriteSucceeded {
		return dozy.StatusBadRequest, []byte(""), ""
	}

	return dozy.StatusPutOk, returnJson, ""

}
开发者ID:hdiwan,项目名称:RedRoute,代码行数:26,代码来源:ride.go


示例6: DeleteAuthtoken

func DeleteAuthtoken(reqJson []byte, qs map[string][]string, uri []string, ac *dozy.AuthContext) (uint, []byte, string) {
	if !ac.GetLoggedIn() {
		return dozy.StatusIncorrectPermissions, []byte(""), ""
	}

	ac.Logout()

	return dozy.StatusDeleteOk, []byte(""), ""
}
开发者ID:hdiwan,项目名称:RedRoute,代码行数:9,代码来源:authtoken.go


示例7: PostRide

func PostRide(reqJson []byte, qs map[string][]string, uri []string, ac *dozy.AuthContext, rawDb interface{}) (uint, []byte, string) {
	db := rawDb.(PostRideDb)

	ride := bson.M{}
	unmarshalErr := json.Unmarshal(reqJson, &ride)
	if unmarshalErr != nil {
		panic(unmarshalErr)
	}

	if !ac.GetLoggedIn() {
		return dozy.StatusIncorrectPermissions, []byte(""), ""
	}

	returnJson, location := db.SetRide(ride, ac.GetUserId())

	return dozy.StatusPostOk, returnJson, location
}
开发者ID:hdiwan,项目名称:RedRoute,代码行数:17,代码来源:ride.go


示例8: GetAuthtokenEmail

func GetAuthtokenEmail(reqJson []byte, qs map[string][]string, uri []string, ac *dozy.AuthContext, rawDb interface{}) (uint, []byte, string) {
	db := rawDb.(GetAuthtokenEmailDb)

	var resJson map[string]interface{}

	if ac.GetLoggedIn() {
		return dozy.StatusIncorrectPermissions, []byte(""), ""
	}

	getHashStatus, hash, userId := db.GetUserHashIdByEmail(qs["email"][0])

	if getHashStatus == mongodb.ReadSucceeded {
		loginOk, needNewHash, newHash := ac.Login(userId, qs["password"][0], hash)

		if loginOk {
			resJson = map[string]interface{}{
				"succeeded": true,
				"authtoken": ac.GetAuthtoken(),
				"userId":    ac.GetUserId(),
			}

			if needNewHash {
				updateHashStatus := db.UpdateHashById(userId, newHash)

				if updateHashStatus != mongodb.WriteSucceeded {
					panic(updateHashStatus)
				}
			}
		} else {
			resJson = map[string]interface{}{
				"succeeded":              false,
				"failedDueToBadPassword": true,
				"failedDueToBadUsername": false,
			}
		}
	} else if getHashStatus == mongodb.ReadNotFound {
		resJson = map[string]interface{}{
			"succeeded":              false,
			"failedDueToBadPassword": false,
			"failedDueToBadUsername": true,
		}
	} else {
		panic(getHashStatus)
	}

	resJsonBytes, marshalErr := json.Marshal(resJson)
	if marshalErr != nil {
		panic(marshalErr)
	}
	return dozy.StatusGetOk, resJsonBytes, ""
}
开发者ID:hdiwan,项目名称:RedRoute,代码行数:51,代码来源:authtoken.go


示例9: PutUsersDebtsPaymentToken

func PutUsersDebtsPaymentToken(reqJson []byte, qs map[string][]string, uri []string, ac *dozy.AuthContext, rawDb interface{}) (uint, []byte, string) {
	db := rawDb.(PutUsersDebtsPaymentTokenDb)

	userId, convErr := strconv.Atoi(uri[1])
	if convErr != nil {
		return dozy.StatusBadRequest, []byte(""), ""
	}

	if !ac.GetLoggedIn() || ac.GetUserId() != uint(userId) {
		return dozy.StatusIncorrectPermissions, []byte(""), ""
	}

	paymentToken := bson.M{}
	unmarshalErr := json.Unmarshal(reqJson, &paymentToken)
	if unmarshalErr != nil {
		panic(unmarshalErr)
	}

	paymentToken["timeStamp"] = time.Now().Unix()

	status, returnJson := db.UpdatePaymentInfo(ac.GetUserId(), paymentToken)
	if status != mongodb.WriteSucceeded {
		return dozy.StatusNotFound, []byte(""), ""
	}

	return dozy.StatusPutOk, returnJson, ""
}
开发者ID:hdiwan,项目名称:RedRoute,代码行数:27,代码来源:users.go


示例10: PutUsersSettings

func PutUsersSettings(reqJson []byte, qs map[string][]string, uri []string, ac *dozy.AuthContext, rawDb interface{}) (uint, []byte, string) {
	db := rawDb.(PutUsersSettingsDb)
	userId, convErr := strconv.Atoi(uri[1])
	if convErr != nil {
		return dozy.StatusBadRequest, []byte(""), ""
	}

	if !ac.GetLoggedIn() || ac.GetUserId() != uint(userId) {
		return dozy.StatusIncorrectPermissions, []byte(""), ""
	}

	j := dozy.JsonObj{}
	unmarshalErr := json.Unmarshal(reqJson, &j)
	if unmarshalErr != nil {
		panic(unmarshalErr)
	}

	updateStatus, emailExists := db.UpdateSettings(ac.GetUserId(), j)
	if updateStatus != mongodb.WriteSucceeded {
		if emailExists {
			return dozy.StatusBadRequest, []byte(`{"succeeded": false, "failedBecauseEmailAlreadyExists": true}`), ""
		}
		return dozy.StatusBadRequest, []byte(`"{succeeded": false, "failedBecauseEmailAlreadyExists": false}`), ""
	}

	return dozy.StatusPutOk, []byte(`"{succeeded": true}`), ""
}
开发者ID:hdiwan,项目名称:RedRoute,代码行数:27,代码来源:users.go


示例11: PutRideAcceptSplit

func PutRideAcceptSplit(reqJson []byte, qs map[string][]string, uri []string, ac *dozy.AuthContext, rawDb interface{}) (uint, []byte, string) {
	db := rawDb.(PutAcceptSplitDb)

	splitDetails := bson.M{}
	unmarshalErr := json.Unmarshal(reqJson, &splitDetails)
	if unmarshalErr != nil {
		panic(unmarshalErr)
	}

	rideId, err := strconv.Atoi(uri[1])
	if err != nil {
		panic(err)
	}

	status, returnJson := db.AcceptSplit(uint(rideId), ac.GetUserId(), splitDetails["paymentNonce"].(string), uint(splitDetails["tip"].(int)))
	if status != mongodb.WriteSucceeded {
		return dozy.StatusBadRequest, []byte(""), ""
	}

	return dozy.StatusPutOk, returnJson, ""

}
开发者ID:hdiwan,项目名称:RedRoute,代码行数:22,代码来源:ride.go


示例12: GetUsersNotificationsCount

func GetUsersNotificationsCount(reqJson []byte, qs map[string][]string, uri []string, ac *dozy.AuthContext, rawDb interface{}) (uint, []byte, string) {
	db := rawDb.(GetUsersNotificationsCountDb)

	userId, convErr := strconv.Atoi(uri[1])
	if convErr != nil {
		return dozy.StatusBadRequest, []byte(""), ""
	}

	if !ac.GetLoggedIn() || ac.GetUserId() != uint(userId) {
		return dozy.StatusIncorrectPermissions, []byte(""), ""
	}

	status, returnJson := db.GetNotificationsCount(ac.GetUserId())
	if status != mongodb.ReadSucceeded {
		return dozy.StatusNotFound, []byte(""), ""
	}

	return dozy.StatusGetOk, returnJson, ""
}
开发者ID:hdiwan,项目名称:RedRoute,代码行数:19,代码来源:users.go


示例13: PutUsersMyPlaces

func PutUsersMyPlaces(reqJson []byte, qs map[string][]string, uri []string, ac *dozy.AuthContext, rawDb interface{}) (uint, []byte, string) {
	db := rawDb.(PutUsersMyPlacesDb)
	userId, convErr := strconv.Atoi(uri[1])
	if convErr != nil {
		return dozy.StatusBadRequest, []byte(""), ""
	}

	if !ac.GetLoggedIn() || ac.GetUserId() != uint(userId) {
		return dozy.StatusIncorrectPermissions, []byte(""), ""
	}

	j := dozy.JsonObj{}
	unmarshalErr := json.Unmarshal(reqJson, &j)
	if unmarshalErr != nil {
		panic(unmarshalErr)
	}

	updateStatus := db.UpdateMyPlaces(ac.GetUserId(), j)
	if updateStatus != mongodb.WriteSucceeded {
		return dozy.StatusBadRequest, []byte(""), ""
	}

	return dozy.StatusPutOk, []byte(""), ""
}
开发者ID:hdiwan,项目名称:RedRoute,代码行数:24,代码来源:users.go


示例14: GetUsersProfile

func GetUsersProfile(reqJson []byte, qs map[string][]string, uri []string, ac *dozy.AuthContext, rawDb interface{}) (uint, []byte, string) {
	db := rawDb.(GetUsersProfileDb)

	userId, convErr := strconv.Atoi(uri[1])
	if convErr != nil {
		return dozy.StatusBadRequest, []byte(""), ""
	}

	numPostsToFetch, convErr1 := strconv.Atoi(qs["numPostsToFetch"][0])
	if convErr1 != nil {
		return dozy.StatusBadRequest, []byte(""), ""
	}

	startingPostNum, convErr2 := strconv.Atoi(qs["startingPostNum"][0])
	if convErr2 != nil {
		return dozy.StatusBadRequest, []byte(""), ""
	}

	status, responseJson := db.GetProfile(uint(userId), uint(numPostsToFetch), uint(startingPostNum), db.AreFriends(ac.GetUserId(), uint(userId)))
	if status != mongodb.WriteSucceeded {
		return dozy.StatusNotFound, []byte(""), ""
	}

	return dozy.StatusGetOk, responseJson, ""
}
开发者ID:hdiwan,项目名称:RedRoute,代码行数:25,代码来源:users.go



注:本文中的dozy.AuthContext类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang assignment.Assignment类代码示例发布时间:2022-05-24
下一篇:
Golang websocketserver.WebsocketServer类代码示例发布时间:2022-05-24
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap