本文整理匯總了Golang中github.com/urandom/readeef/content.User.Password方法的典型用法代碼示例。如果您正苦於以下問題:Golang User.Password方法的具體用法?Golang User.Password怎麽用?Golang User.Password使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/urandom/readeef/content.User
的用法示例。
在下文中一共展示了User.Password方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: setUserAttribute
func setUserAttribute(user content.User, secret []byte, attr string, data []byte) (resp responseError) {
resp = newResponse()
in := user.Data()
resp.val["Login"] = in.Login
switch attr {
case "FirstName":
resp.err = json.Unmarshal(data, &in.FirstName)
case "LastName":
resp.err = json.Unmarshal(data, &in.LastName)
case "Email":
resp.err = json.Unmarshal(data, &in.Email)
case "ProfileData":
if resp.err = json.Unmarshal(data, &in.ProfileData); resp.err == nil {
in.ProfileJSON = []byte{}
}
case "Active":
in.Active = string(data) == "true"
case "Password":
passwd := struct {
Current string
New string
}{}
if resp.err = json.Unmarshal(data, &passwd); resp.err != nil {
/* TODO: non-fatal error */
return
}
if user.Authenticate(passwd.Current, secret) {
user.Password(passwd.New, secret)
resp.err = user.Err()
} else {
resp.err = errors.New("Error change user password: current password is invalid")
}
default:
resp.err = errors.New("Error getting user attribute: unknown attribute " + attr)
}
if resp.err != nil {
return
}
user.Data(in)
user.Update()
if resp.err = user.Err(); resp.err != nil {
return
}
resp.val["Success"] = true
resp.val["Attribute"] = attr
return
}