tsk-30: Update password (#33)

Closes #30

Reviewed-on: phoenix/textsender-auth#33
Co-authored-by: phoenix <kundeng00@pm.me>
Co-committed-by: phoenix <kundeng00@pm.me>
This commit is contained in:
phoenix
2025-12-26 21:14:40 +00:00
committed by phoenix
parent 760a778a27
commit d34cad033d
22 changed files with 727 additions and 98 deletions
+24 -1
View File
@@ -1,6 +1,8 @@
package handler
import (
"context"
"fmt"
"log"
"os"
"path"
@@ -9,10 +11,12 @@ import (
"github.com/joho/godotenv"
"git.kundeng.us/phoenix/textsender-auth/internal/config"
"git.kundeng.us/phoenix/textsender-auth/internal/store/mock"
"git.kundeng.us/phoenix/textsender-auth/internal/utility"
)
func GetTestUser() user.User {
return user.User{Username: "ghost", PhoneNumber: "+1234567890", Password: "dfgdffddfd"}
return user.User{Username: "ghost", PhoneNumber: "+1234567890", Password: "Dfgdffd343dfd!"}
}
func GetConfig() *config.Config {
@@ -38,3 +42,22 @@ func GetConfig() *config.Config {
EnableRegistration: config.CheckRegistration(),
}
}
func createUser(ctx context.Context, userStore *mock.MockUserStore) (*user.User, *string, error) {
testUser := GetTestUser()
unhashedPassword := testUser.Password
hashing := utility.HashMash{}
if err := hashing.SetPassword(testUser.Password); err != nil {
return nil, nil, fmt.Errorf("Error setting password: %v", err)
}
hashedPassword, err := hashing.HashPassword()
if err != nil {
return nil, nil, err
}
testUser.Password = hashedPassword
userStore.CreateUser(ctx, &testUser)
return &testUser, &unhashedPassword, nil
}