mirror of
https://github.com/getAlby/lndhub.go.git
synced 2026-01-22 06:16:13 +01:00
Merge pull request #27 from bumi/return-not-hashed-password
Return not hashed password
This commit is contained in:
@@ -34,8 +34,9 @@ func (CreateUserController) CreateUser(c echo.Context) error {
|
||||
user := &models.User{}
|
||||
|
||||
user.Login = randStringBytes(8)
|
||||
user.Password = randStringBytes(15)
|
||||
security.HashPassword(&user.Password)
|
||||
password := randStringBytes(15)
|
||||
hashedPassword := security.HashPassword(password)
|
||||
user.Password = hashedPassword
|
||||
|
||||
if err := db.Create(&user).Error; err != nil {
|
||||
return err
|
||||
@@ -45,7 +46,7 @@ func (CreateUserController) CreateUser(c echo.Context) error {
|
||||
Password string `json:"password"`
|
||||
}
|
||||
ResponseBody.Login = user.Login
|
||||
ResponseBody.Password = user.Password
|
||||
ResponseBody.Password = password
|
||||
|
||||
return c.JSON(http.StatusOK, &ResponseBody)
|
||||
}
|
||||
|
||||
@@ -5,7 +5,9 @@ import (
|
||||
)
|
||||
|
||||
// HashPassword : Hash Password
|
||||
func HashPassword(password *string) {
|
||||
bytes, _ := bcrypt.GenerateFromPassword([]byte(*password), bcrypt.DefaultCost)
|
||||
*password = string(bytes)
|
||||
func HashPassword(password string) string {
|
||||
bytes, _ := bcrypt.GenerateFromPassword([]byte(password), bcrypt.DefaultCost)
|
||||
password = string(bytes)
|
||||
|
||||
return password
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user