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

feat: implement put-users/me/email #30

Merged
merged 5 commits into from
Sep 19, 2024
Merged

Conversation

Eraxyso
Copy link
Collaborator

@Eraxyso Eraxyso commented Sep 19, 2024

close #12

post-/signup/requestとほぼ同じ機能

Copy link
Collaborator

@PonponJuice PonponJuice left a comment

Choose a reason for hiding this comment

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

mail_verificationsput_mail_verifications を使い分けてくれると助かります

let jwt = state
.save_email_varifications(&body.email)
.await
.map_err(|_| StatusCode::INTERNAL_SERVER_ERROR)?;
Copy link
Collaborator

Choose a reason for hiding this comment

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

put email のdatabaseがあるからそっち側に保存する関数を作った方が良い

) -> anyhow::Result<StatusCode, StatusCode> {
if !crate::utils::mail::is_valid_email(&body.email) {
return Err(StatusCode::BAD_REQUEST);
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

validかどうか確かめる関数作ったのなら

#[derive(Deserialize, Validate)]
pub struct EmailUpdate {
    #[validate(custom(function = "is_valid_email"))]
    email: String,
}

にして
body.validate().map_err(|_| StatusCode::BAD_REQUEST)?;
としてもいいかも

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

よく考えるとsend_emailでエラーがなければ問題ないため、削除しました

Copy link
Collaborator

@PonponJuice PonponJuice left a comment

Choose a reason for hiding this comment

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

BADREQUESTを返すところだけ

src/handler/users.rs Outdated Show resolved Hide resolved
Copy link
Collaborator

@PonponJuice PonponJuice left a comment

Choose a reason for hiding this comment

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

良さげ

@Eraxyso Eraxyso merged commit 7c50f3e into develop Sep 19, 2024
1 check passed
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.

PUT /users/me/email を実装する
2 participants