Skip to content

Removed Result<> from auth handlers#14

Open
ProstoLive wants to merge 1 commit into
mainfrom
arudiak/remove_result_handlers
Open

Removed Result<> from auth handlers#14
ProstoLive wants to merge 1 commit into
mainfrom
arudiak/remove_result_handlers

Conversation

@ProstoLive

Copy link
Copy Markdown
Contributor

No description provided.

@ProstoLive ProstoLive self-assigned this Oct 16, 2024
@ProstoLive ProstoLive linked an issue Oct 16, 2024 that may be closed by this pull request

@evgenymng evgenymng left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I didn't see any glaring issues with these changes, although personally I am not a fan of the boilerplate code that was added (explicit error handling), and I would much prefer a more elegant (and uniform) solution, like custom errors.

Comment thread src/auth/handlers.rs
Comment on lines +76 to +80
Ok(hash) => hash,
Err(_) => {
return HttpResponse::InternalServerError().body("Decoding password hash error")
}
};

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is the formatting fine? Please, confirm by running cargo fmt.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@ProstoLive Ты можешь просто rebase сделать теперь, чтобы проверить форматирование.

@evgenymng Давай будем на русском общаться в PR-ах, пока не будет необходимости делать иначе.

Comment thread src/auth/handlers.rs
user.password = match bcrypt::hash(user.password, bcrypt::DEFAULT_COST) {
Ok(hashed_password) => hashed_password,
Err(_) => {
return HttpResponse::BadRequest().body("Hashing password error");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

В функции login ошибка bcrypt::hash интерпретируется как InternalServerError, так что надо выбрать что-то одно. Считаю, что это должно быть ISE, потому что фильтрацией ввода должен заниматься не бэкенд.

Suggested change
return HttpResponse::BadRequest().body("Hashing password error");
return HttpResponse::InternalServerError().body("Hashing password error");

@evgenymng

evgenymng commented Oct 24, 2024

Copy link
Copy Markdown
Contributor

Предлагаю закрыть этот PR, так как Issue создавалась до смещения фокуса разработки.

P.S: К тому же у @t3m8ch на подходе PR с обработкой ошибок.

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.

Remove Result<> from handlers

4 participants