本文整理匯總了Golang中github.com/leanote/leanote/app/info.User.FromUserId方法的典型用法代碼示例。如果您正苦於以下問題:Golang User.FromUserId方法的具體用法?Golang User.FromUserId怎麽用?Golang User.FromUserId使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/leanote/leanote/app/info.User
的用法示例。
在下文中一共展示了User.FromUserId方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Register
// 1. 添加用戶
// 2. 將leanote共享給我
// [ok]
func (this *AuthService) Register(email, pwd, fromUserId string) (bool, string) {
// 用戶是否已存在
if userService.IsExistsUser(email) {
return false, "userHasBeenRegistered-" + email
}
user := info.User{UserId: bson.NewObjectId(), Email: email, Username: email, Pwd: Md5(pwd)}
if fromUserId != "" && IsObjectId(fromUserId) {
user.FromUserId = bson.ObjectIdHex(fromUserId)
}
LogJ(user)
return this.register(user)
}
示例2: Register
// 1. 添加用戶
// 2. 將leanote共享給我
// [ok]
func (this *AuthService) Register(email, pwd, fromUserId string) (bool, string) {
// 用戶是否已存在
if userService.IsExistsUser(email) {
return false, "userHasBeenRegistered-" + email
}
passwd := GenPwd(pwd)
if passwd == "" {
return false, "GenerateHash error"
}
user := info.User{UserId: bson.NewObjectId(), Email: email, Username: email, Pwd: passwd}
if fromUserId != "" && IsObjectId(fromUserId) {
user.FromUserId = bson.ObjectIdHex(fromUserId)
}
return this.register(user)
}