本文整理汇总了Golang中gitlab.com/thanzen/identity/models/user.User.Email方法的典型用法代码示例。如果您正苦于以下问题:Golang User.Email方法的具体用法?Golang User.Email怎么用?Golang User.Email使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gitlab.com/thanzen/identity/models/user.User
的用法示例。
在下文中一共展示了User.Email方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: RegisterUser
// register a user
func (this *UserService) RegisterUser(u *user.User, username, email, password string, userType *user.UserType, role *user.Role) error {
u.UserType = userType
// use random salt encode password
salt := GetUserSalt()
pwd := utils.EncodePassword(password, salt)
u.Username = strings.ToLower(username)
u.Email = strings.ToLower(email)
// save salt and encode password, use $ as split char
u.Password = fmt.Sprintf("%s$%s", salt, pwd)
u.PasswordSalt = salt
var err error
tr := orm.NewOrm()
tr.Begin()
if err = this.InsertWithScope(tr, u); err == nil {
roleService := RoleService{}
err = roleService.InsertUsersWithScope(tr, role, u)
}
if err == nil {
tr.Commit()
} else {
tr.Rollback()
}
return err
}
示例2: HasUser
// check if exist user by username or email, ignore "deleted" users
func (this *UserService) HasUser(user *user.User, username string) bool {
var err error
qs := orm.NewOrm()
if strings.IndexRune(username, '@') == -1 {
user.Username = username
err = qs.Read(user, "Username", "Deleted")
} else {
user.Email = username
err = qs.Read(user, "Email", "Deleted")
}
if err == nil {
return true
}
return false
}