mirror of
https://github.com/writefreely/writefreely
synced 2024-11-28 03:20:17 +00:00
22 lines
574 B
Go
22 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
|
||
|
}
|