Exemple #1
0
// update user password with user id and new password
func UpdatePassword(id int64, newPassword string) error {
	u := new(User)
	u.Salt = utils.Md5String(newPassword)[8:24]
	u.Password = utils.Sha256String(newPassword + u.Salt)
	if _, err := vars.Db.Cols("password,salt").Where("id = ?", id).Update(u); err != nil {
		log.Println("Db|UpdatePassword|%d|%s", id, err.Error())
		return err
	}
	return nil
}
Exemple #2
0
// check user's password
func (u *User) CheckPassword(pwd string) bool {
	return u.Password == utils.Sha256String(pwd+u.Salt)
}