mirror of
https://github.com/writefreely/writefreely
synced 2024-11-24 09:33:11 +00:00
9016f87041
Usage: writefreely --reset-pass <username> This closes #25, closes T534
21 lines
574 B
Go
21 lines
574 B
Go
package writefreely
|
|
|
|
import (
|
|
"fmt"
|
|
"github.com/writeas/impart"
|
|
"github.com/writeas/web-core/auth"
|
|
"net/http"
|
|
)
|
|
|
|
func adminResetPassword(app *app, u *User, newPass string) error {
|
|
hashedPass, err := auth.HashPass([]byte(newPass))
|
|
if err != nil {
|
|
return impart.HTTPError{http.StatusInternalServerError, fmt.Sprintf("Could not create password hash: %v", err)}
|
|
}
|
|
|
|
err = app.db.ChangePassphrase(u.ID, true, "", hashedPass)
|
|
if err != nil {
|
|
return impart.HTTPError{http.StatusInternalServerError, fmt.Sprintf("Could not update passphrase: %v", err)}
|
|
}
|
|
return nil
|
|
}
|