本文整理匯總了Golang中github.com/leanote/leanote/app/info.User類的典型用法代碼示例。如果您正苦於以下問題:Golang User類的具體用法?Golang User怎麽用?Golang User使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了User類的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: setUserLogo
func (this *UserService) setUserLogo(user *info.User) {
// Logo路徑問題, 有些有http: 有些沒有
if user.Logo == "" {
user.Logo = "images/blog/default_avatar.png"
}
if user.Logo != "" && !strings.HasPrefix(user.Logo, "http") {
user.Logo = strings.Trim(user.Logo, "/")
user.Logo = configService.GetSiteUrl() + "/" + user.Logo
}
}
示例2: 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)
}
示例3: 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)
}
示例4: AddUser
// 添加用戶
func (this *UserService) AddUser(user info.User) bool {
if user.UserId == "" {
user.UserId = bson.NewObjectId()
}
user.CreatedTime = time.Now()
if user.Email != "" {
user.Email = strings.ToLower(user.Email)
// 發送驗證郵箱
go func() {
this.RegisterSendActiveEmail(user.UserId.Hex(), user.Email)
}()
}
return db.Insert(db.Users, user)
}
示例5: AddUser
// 添加用戶
func (this *UserService) AddUser(user info.User) bool {
if user.UserId == "" {
user.UserId = bson.NewObjectId()
}
user.CreatedTime = time.Now()
if user.Email != "" {
user.Email = strings.ToLower(user.Email)
// 發送驗證郵箱
go func() {
emailService.RegisterSendActiveEmail(user, user.Email)
// 發送給我 [email protected]
emailService.SendEmail("[email protected]", "新增用戶", "{header}用戶名"+user.Email+"{footer}")
}()
}
return db.Insert(db.Users, user)
}
示例6: GetUserInfo
// 得到用戶信息
func (c BaseController) GetUserInfo() info.User {
if userId, ok := c.Session["UserId"]; ok && userId != "" {
notebookWidth, _ := strconv.Atoi(c.Session["NotebookWidth"])
noteListWidth, _ := strconv.Atoi(c.Session["NoteListWidth"])
user := info.User{UserId: bson.ObjectIdHex(userId),
Email: c.Session["Email"],
Username: c.Session["Username"],
UsernameRaw: c.Session["UsernameRaw"],
Theme: c.Session["Theme"],
NotebookWidth: notebookWidth,
NoteListWidth: noteListWidth,
}
if c.Session["Verified"] == "1" {
user.Verified = true
}
if c.Session["LeftIsMin"] == "1" {
user.LeftIsMin = true
}
return user
}
return info.User{}
}
示例7: setRenderUserInfo
// 可以不要, 因為注冊的時候已經把username設為email了
func (c Blog) setRenderUserInfo(userInfo info.User) {
if userInfo.Username == "" {
userInfo.Username = userInfo.Email
}
c.RenderArgs["userInfo"] = userInfo
}