當前位置: 首頁>>代碼示例>>Golang>>正文


Golang User.Password方法代碼示例

本文整理匯總了Golang中github.com/EPICPaaS/account/models.User.Password方法的典型用法代碼示例。如果您正苦於以下問題:Golang User.Password方法的具體用法?Golang User.Password怎麽用?Golang User.Password使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/EPICPaaS/account/models.User的用法示例。


在下文中一共展示了User.Password方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: ConnectPost

func (this *SocialAuthController) ConnectPost() {
	token := this.Ctx.GetCookie("epic_user_token")
	ok, userId := tools.VerifyToken(token)
	if !ok || len(userId) == 0 {
		this.Redirect("/", 302)
		return
	}
	password := this.GetString("Password")
	userName := this.GetString("UserName")
	if len(userId) == 0 || len(password) == 0 || len(userName) == 0 {
		this.Data["userId"] = userId
		this.TplNames = "connect.html"
		this.Data["error"] = "[用戶名]或者[密碼]為空"
		this.Data["state"] = "注冊失敗"
		this.Data["msg"] = "[用戶名]或者[郵箱]已被注冊"
		return
	}
	isExist := auth.UserIsExists(userName, userName)
	if isExist {
		this.Data["userId"] = userId
		this.TplNames = "connect.html"
		this.Data["error"] = "[用戶名]或者[郵箱]已被注冊"
		this.Data["state"] = "注冊失敗"
		this.Data["msg"] = "[用戶名]或者[郵箱]已被注冊"
		return
	}
	user := models.User{}
	user.Password = password
	user.UserName = userName
	user.Id, _ = strconv.Atoi(userId)
	err := auth.ConnectUpdateUser(&user, password)
	if err != nil {
		this.Data["userId"] = userId
		this.TplNames = "connect.html"
		this.Data["error"] = err.Error()
		this.Data["state"] = "注冊失敗"
		beego.Error("注冊失敗-插入數據庫出錯", err)
		this.Data["msg"] = err.Error()
		return
	}

	subSitesConf := config.GetSubSites()
	this.Data["srcs"] = strings.Split(subSitesConf, ",")
	this.Data["token"] = token
	this.Data["state"] = "注冊成功"
	this.Data["msg"] = "3秒後自動跳轉!!"
	this.Data["succ"] = true
	this.Data["redirectURL"] = config.GetRedirectURL()
	this.TplNames = "succeed.html"
}
開發者ID:EPICPaaS,項目名稱:account,代碼行數:50,代碼來源:socialAuth.go

示例2: RegisterUser

func RegisterUser(user *models.User, username, email, password string) error {
	// use random salt encode password
	salt := models.GetUserSalt()
	pwd := tools.EncodePassword(password, salt)
	user.UserName = strings.ToLower(username)
	user.Email = strings.ToLower(email)
	// save salt and encode password, use $ as split char
	user.Password = fmt.Sprintf("%s$%s", salt, pwd)
	// save md5 email value for gravatar
	user.GrEmail = tools.EncodeMd5(user.Email)

	// Use username as default nickname.
	user.NickName = user.UserName
	//設置用戶默認激活
	user.IsActive = true

	return user.Insert()
}
開發者ID:EPICPaaS,項目名稱:account,代碼行數:18,代碼來源:auth.go

示例3: ConnectUpdateUser

func ConnectUpdateUser(user *models.User, password string) error {
	salt := models.GetUserSalt()
	pwd := tools.EncodePassword(password, salt)
	user.Password = fmt.Sprintf("%s$%s", salt, pwd)
	return user.Update("UserName", "Password")
}
開發者ID:EPICPaaS,項目名稱:account,代碼行數:6,代碼來源:auth.go

示例4: SaveNewPassword

func SaveNewPassword(user *models.User, password string) error {
	salt := models.GetUserSalt()
	user.Password = fmt.Sprintf("%s$%s", salt, tools.EncodePassword(password, salt))
	return user.Update("Password", "Rands", "Updated")
}
開發者ID:EPICPaaS,項目名稱:account,代碼行數:5,代碼來源:auth.go


注:本文中的github.com/EPICPaaS/account/models.User.Password方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。