Ejemplo n.º 1
0
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
	}
}
Ejemplo n.º 2
0
// 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)
}
Ejemplo n.º 3
0
// 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)
}
Ejemplo n.º 4
0
// 添加用户
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)
}
Ejemplo n.º 5
0
// 添加用户
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("*****@*****.**", "新增用户", "{header}用户名"+user.Email+"{footer}")
		}()
	}

	return db.Insert(db.Users, user)
}
Ejemplo n.º 6
0
// 得到用户信息
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{}
}
Ejemplo n.º 7
0
// 可以不要, 因为注册的时候已经把username设为email了
func (c Blog) setRenderUserInfo(userInfo info.User) {
	if userInfo.Username == "" {
		userInfo.Username = userInfo.Email
	}
	c.RenderArgs["userInfo"] = userInfo
}