1
0
Fork 0
forked from forgejo/forgejo

finish delete ssh key and delete account. all with confirm.

This commit is contained in:
slene 2014-03-16 21:07:50 +08:00
parent 0754dd2f95
commit f6e32b1b08
7 changed files with 334 additions and 52 deletions

View file

@ -175,8 +175,8 @@ func DeleteUser(user *User) error {
// EncodePasswd encodes password to safe format.
func (user *User) EncodePasswd() error {
newPasswd, err := scrypt.Key([]byte(user.Passwd), []byte(UserPasswdSalt), 16384, 8, 1, 64)
user.Passwd = fmt.Sprintf("%x", newPasswd)
var err error
user.Passwd, err = EncodePasswd(user.Passwd)
return err
}
@ -184,6 +184,14 @@ func UserPath(userName string) string {
return filepath.Join(RepoRootPath, userName)
}
func EncodePasswd(rawPasswd string) (string, error) {
newPasswd, err := scrypt.Key([]byte(rawPasswd), []byte(UserPasswdSalt), 16384, 8, 1, 64)
if err != nil {
return "", err
}
return fmt.Sprintf("%x", newPasswd), nil
}
func GetUserByKeyId(keyId int64) (*User, error) {
user := new(User)
has, err := orm.Sql("select a.* from user as a, public_key as b where a.id = b.owner_id and b.id=?", keyId).Get(user)