mirror of https://github.com/writeas/writefreely
A focused writing and publishing space.
https://write.with.parts
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
22 lines
574 B
22 lines
574 B
6 years ago
|
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
|
||
|
}
|