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

set SMS send code for login optional #414

Merged
merged 1 commit into from
Dec 20, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion web/api/phone_login.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,19 @@ func (ar *Router) RequestVerificationCode() http.HandlerFunc {
return
}

// TODO: add limiter here. Check frequency of requests.
//// TODO: add limiter here. Check frequency of requests.
// TODO: rate limiter is a function of network infrastructure. Better to use AWS WAF or similar solution.
_, err := ar.server.Storages().User.UserByPhone(authData.PhoneNumber)
if err == model.ErrUserNotFound {
if !ar.server.Settings().Login.AllowRegisterMissing {
ar.Error(w, locale, http.StatusUnauthorized, l.ErrorAPIAPPRegistrationForbidden)
return
}
} else if err != nil {
ar.Error(w, locale, http.StatusInternalServerError, l.ErrorStorageFindUserPhoneError, err)
return
}

code := randStringBytes(phoneVerificationCodeLength)
if err := ar.server.Storages().Verification.CreateVerificationCode(authData.PhoneNumber, code); err != nil {
ar.Error(w, locale, http.StatusInternalServerError, l.ErrorStorageVerificationCreateError, err)
Expand Down
Loading