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

Sending an email to a user to confirm their email address #1045

Merged
merged 67 commits into from Sep 16, 2017

Conversation

Projects
None yet
3 participants
@natboehm
Contributor

natboehm commented Sep 6, 2017

This PR addresses issue #808, allow editing your own email address. Following the discussion on the issue, this implements the second of three parts, the ability to send a confirmation email to a user for verification. For a full explanation of the issue, see this comment I left which should fully explain the changes made, as well as parts 1 and 3.

In short, I added two tables to the database: one for the user's email, the other for a confirmation token associated with the email. Once the user clicks the link sent, the associated token is deleted from the token table and email_verified is set to true in the email table. It is indicated to the user if they have not verified their email on the account settings page, a message and email resend button being displayed. Sending emails requires Mailgun to be added to the crates.io Heroku account.

This has applications for issue #924 in that we should now be able to send an email to a user, if they have added their email. I know there was a lot of discussion on that issue regarding the ability to send users an email to be added as an owner.

@carols10cents

Overall this is great!! This is a lot of work with a whole bunch of pieces, and it's really close!! Just a few polishing things :)

Show outdated Hide outdated app/components/email-input.js Outdated
Show outdated Hide outdated app/templates/error.hbs Outdated
Show outdated Hide outdated src/lib.rs Outdated
Show outdated Hide outdated src/lib.rs Outdated
Show outdated Hide outdated src/user/mod.rs Outdated
Show outdated Hide outdated src/user/mod.rs Outdated
Err(_) => (None, false),
};
let user = User {

This comment has been minimized.

@carols10cents

carols10cents Sep 11, 2017

Member

wdyt about doing:

let user = User {
    email: email,
    ..user_info
};

here, to make it clearer that only the email is different? Does that work?

@carols10cents

carols10cents Sep 11, 2017

Member

wdyt about doing:

let user = User {
    email: email,
    ..user_info
};

here, to make it clearer that only the email is different? Does that work?

let user = users.filter(id.eq(user_id)).first::<User>(&*conn)?;
let user_info = users.filter(id.eq(u_id)).first::<User>(&*conn)?;
let email_result = emails.filter(user_id.eq(u_id)).first::<Email>(&*conn);

This comment has been minimized.

@carols10cents

carols10cents Sep 11, 2017

Member

I wonder if we can get the User and the Email in one query? Maybe not worth it...

@carols10cents

carols10cents Sep 11, 2017

Member

I wonder if we can get the User and the Email in one query? Maybe not worth it...

Show outdated Hide outdated src/user/mod.rs Outdated
}
fn generate_token() -> String {
let token: String = thread_rng().gen_ascii_chars().take(26).collect();

This comment has been minimized.

@carols10cents

carols10cents Sep 11, 2017

Member

cool!!

@carols10cents

carols10cents Sep 11, 2017

Member

cool!!

natboehm added some commits Aug 7, 2017

on create/update user, email field is added to new table and token is…
… generated, preliminary test for functionality added
beginnings of route to display success/error of user confirming email…
… - added confirm route that submits PUT request to backend with error handling
route to confirm user email token displays success when token found, …
…confirmed, deleted & displays error message when token not found
fixes bug where user model would not reload between confirming email …
…and navigating to account settings page.

Uses GET request to `/me` to get the latest version of the model upon returning successfully from the PUT request to `/confirm`.
separates into 'development' and 'production' parts
One part uses the env variables if found, the other
uses an email stub that prints to the env_logger.
For testing purposes when env variables not found `send_user_confirm_…
…email` will send output to a file named {message_id}.txt in user's `\tmp` directory
@carols10cents

This comment has been minimized.

Show comment
Hide comment
@carols10cents

carols10cents Sep 15, 2017

Member

bors: r+

Member

carols10cents commented Sep 15, 2017

bors: r+

bors-voyager bot added a commit that referenced this pull request Sep 15, 2017

Merge #1045
1045: Sending an email to a user to confirm their email address r=carols10cents

This PR addresses issue #808, allow editing your own email address. Following the discussion on the issue, this implements the second of three parts, the ability to send a confirmation email to a user for verification. For a full explanation of the issue, see [this comment](#808 (comment)) I left which should fully explain the changes made, as well as parts 1 and 3. 

In short, I added two tables to the database: one for the user's email, the other for a confirmation token associated with the email. Once the user clicks the link sent, the associated token is deleted from the token table and `email_verified` is set to `true` in the email table. It is indicated to the user if they have not verified their email on the account settings page, a message and email resend button being displayed. Sending emails requires Mailgun to be added to the crates.io Heroku account. 

This has applications for issue #924 in that we should now be able to send an email to a user, if they have added their email. I know there was a lot of discussion on that issue regarding the ability to send users an email to be added as an owner.
@bors-voyager

This comment has been minimized.

Show comment
Hide comment
@bors-voyager

bors-voyager bot Sep 15, 2017

Contributor

Timed out

Contributor

bors-voyager bot commented Sep 15, 2017

Timed out

@carols10cents

This comment has been minimized.

Show comment
Hide comment
@carols10cents

carols10cents Sep 15, 2017

Member

bors: r+

Member

carols10cents commented Sep 15, 2017

bors: r+

bors-voyager bot added a commit that referenced this pull request Sep 15, 2017

Merge #1045
1045: Sending an email to a user to confirm their email address r=carols10cents

This PR addresses issue #808, allow editing your own email address. Following the discussion on the issue, this implements the second of three parts, the ability to send a confirmation email to a user for verification. For a full explanation of the issue, see [this comment](#808 (comment)) I left which should fully explain the changes made, as well as parts 1 and 3. 

In short, I added two tables to the database: one for the user's email, the other for a confirmation token associated with the email. Once the user clicks the link sent, the associated token is deleted from the token table and `email_verified` is set to `true` in the email table. It is indicated to the user if they have not verified their email on the account settings page, a message and email resend button being displayed. Sending emails requires Mailgun to be added to the crates.io Heroku account. 

This has applications for issue #924 in that we should now be able to send an email to a user, if they have added their email. I know there was a lot of discussion on that issue regarding the ability to send users an email to be added as an owner.
@bors-voyager

This comment has been minimized.

Show comment
Hide comment
@bors-voyager

bors-voyager bot Sep 15, 2017

Contributor

Timed out

Contributor

bors-voyager bot commented Sep 15, 2017

Timed out

@carols10cents

This comment has been minimized.

Show comment
Hide comment
@carols10cents

carols10cents Sep 15, 2017

Member

bors: r+

Member

carols10cents commented Sep 15, 2017

bors: r+

bors-voyager bot added a commit that referenced this pull request Sep 15, 2017

Merge #1045
1045: Sending an email to a user to confirm their email address r=carols10cents

This PR addresses issue #808, allow editing your own email address. Following the discussion on the issue, this implements the second of three parts, the ability to send a confirmation email to a user for verification. For a full explanation of the issue, see [this comment](#808 (comment)) I left which should fully explain the changes made, as well as parts 1 and 3. 

In short, I added two tables to the database: one for the user's email, the other for a confirmation token associated with the email. Once the user clicks the link sent, the associated token is deleted from the token table and `email_verified` is set to `true` in the email table. It is indicated to the user if they have not verified their email on the account settings page, a message and email resend button being displayed. Sending emails requires Mailgun to be added to the crates.io Heroku account. 

This has applications for issue #924 in that we should now be able to send an email to a user, if they have added their email. I know there was a lot of discussion on that issue regarding the ability to send users an email to be added as an owner.
@bors-voyager

This comment has been minimized.

Show comment
Hide comment
@bors-voyager
Contributor

bors-voyager bot commented Sep 16, 2017

Build succeeded

@bors-voyager bors-voyager bot merged commit 26254f4 into rust-lang:master Sep 16, 2017

2 checks passed

bors Build succeeded
continuous-integration/travis-ci/pr The Travis CI build passed
Details

@natboehm natboehm deleted the natboehm:confirm-user-email branch Sep 25, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment