Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[be] Написать бекэнд для страницы регистрации #1

Merged
merged 10 commits into from
Sep 25, 2024

Conversation

JOJOSoderqvist
Copy link
Collaborator

feat: Добавлена регистрация
P.S. Санитайзер на уровне - что в голову пришло, позже будет исправлен в соответствии с общими требованиями к санитайзингу в т.ч. на фронте

@JOJOSoderqvist JOJOSoderqvist changed the title [be] Написать бекэнд для страницы рег/входа [be] Написать бекэнд для страницы регистрации Sep 20, 2024
@goriiin
Copy link
Collaborator

goriiin commented Sep 21, 2024

нужны тесты

custom_errors/custom_errors.go Outdated Show resolved Hide resolved
db/db.go Outdated Show resolved Hide resolved
api/signup.go Outdated Show resolved Hide resolved
api/signup.go Outdated
}
}

func sanitizeParams(signupRequest signupApiRequest) error {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

думаю стоит переименовать на validate

api/signup.go Outdated
Comment on lines 12 to 15
var signupRequest signupApiRequest
err := json.NewDecoder(r.Body).Decode(&signupRequest)

if err != nil {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

перенос строки после var,
убрать перенос после NewDecoder

db/db.go Outdated
"errors"
)

var users = make(map[string]User)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

лучше сделать отдельную структуру с sync.Mutex, так как при работе с мапой в горутинах -- неизбежная паника

api/signup.go Outdated
return
}

err = db.CreateUser(signupRequest.Email, signupRequest.User)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

нужно хэширование пароля, используй Argon2

api/signup.go Outdated
return ErrEmptyRequestParams
}

if len(signupRequest.Username) < 3 || len(signupRequest.Username) > 20 {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minUsernameLen, maxUsernameLen (понимаете про что я)

api/signup.go Outdated
return ErrWrongEmailFormat
}

if len(signupRequest.Password) < 5 {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

api/types.go Outdated

type signupApiRequest struct {
Email string `json:"email"`
db.User
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

явно назвать поле надо

cmd/main.go Outdated

r.HandleFunc("/signup", api.SignupHandler).Methods("POST")
http.Handle("/", r)
_ = http.ListenAndServe("127.0.0.1:8080", nil)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

если роняете сервак, лучше напишите об этом сообщение в консоль

fix: Изменены тесты для регистрации
improve: Изменена логика функции writeJSON()
@JOJOSoderqvist JOJOSoderqvist merged commit be57b44 into dev Sep 25, 2024
@JOJOSoderqvist JOJOSoderqvist deleted the OZO-12 branch October 1, 2024 11:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants