mirror of https://github.com/writeas/writefreely
Usage: writefreely --reset-pass <username> This closes #25, closes T534pull/29/head
parent
8c851545f6
commit
9016f87041
@ -0,0 +1,21 @@ |
|||||||
|
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 |
||||||
|
} |
Loading…
Reference in new issue