Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

more permissive verification process #4317

Merged
merged 12 commits into from Feb 2, 2017
Merged

Conversation

derhuerst
Copy link
Contributor

Hopefully addresses #4280. 😛

Let's assume you requested email verification using foo@bar and then aborted the process. The request has been sent to the contract, but the verification server hasn't issued any email.

Right now, the verification process assumes that in this case you will want to continue verifying foo@bar. Trying to verify foo@baz will fail, because the UI happily accepts it, but doesn't send a new request.

The PR makes the specific stores able to determine wether a new request shall be sent, using a method called shallRequestAgain . For email verification, it compares the emailHash of the past request and the values now entered in the UI.

For sms verification, we have no such information in the request tx, so it will always send another request. This may cost the user more money, but given that it fails otherwise, it seems like a reasonable tradeoff.

All of this goes along with commits at ethcore/sms-verification and at ethcore/email-verification to make sure the server really picks the latest Requested event to verify the emailHash.

@derhuerst derhuerst added A3-inprogress ⏳ Pull request is in progress. No review needed at this stage. M7-ui labels Jan 26, 2017
@derhuerst derhuerst added A0-pleasereview 🤓 Pull request needs code review. and removed A3-inprogress ⏳ Pull request is in progress. No review needed at this stage. labels Feb 1, 2017
@derhuerst derhuerst removed the request for review from gavofyork February 1, 2017 18:08
let subId = null;
let resolved = false;

return new Promise((resolve, reject) => {
contract
.subscribe('Requested', {
fromBlock: 0, toBlock: 'pending'
fromBlock: 0, toBlock: 'pending', limit: 1,
Copy link
Contributor

Choose a reason for hiding this comment

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

Always prefer single property per line.

defaultMessage='Your account is already verified.'
/>
</p>
</div>
);
} else if (isVerified === false) {
} else if (accountIsVerified === false) {
Copy link
Contributor

Choose a reason for hiding this comment

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

else should be sufficient - prop set as bool.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it's a nullable bool. i know this is ugly, but spamming the props didn't feel right either. not happy with this 😕

/>
</p>
</div>
);
} else if (hasRequested === false) {
} else if (accountHasRequested === false) {
Copy link
Contributor

Choose a reason for hiding this comment

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

else should be sufficient.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it's a nullable bool. i know this is ugly, but spamming the props didn't feel right either. not happy with this 😕


import EmailVerificationABI from '~/contracts/abi/email-verification.json';
import VerificationStore, {
LOADING, QUERY_DATA, QUERY_CODE, POSTED_CONFIRMATION, DONE
} from './store';
import { isServerRunning, hasReceivedCode, postToServer } from '~/3rdparty/email-verification';
const ZERO20 = '0x0000000000000000000000000000000000000000';
Copy link
Contributor

Choose a reason for hiding this comment

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

empty line before const.

if (address === ZERO20) {
this.isAbleToRequest = true;
} else {
this.isAbleToRequest = new Error('Another account has been verified using this e-mail.');
Copy link
Contributor

Choose a reason for hiding this comment

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

Would have preferred another way instead of a bool + Error type mixed. (e.g. set to bool in previous statement, as Error here)

this.isAbleToRequest = new Error('Another account has been verified using this e-mail.');
}
})
.catch((err) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not error? We are not gaining anything by not typing 2 letters.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's a common pattern in the Node.js ecosystem, from the Node.js docs to MDN to lots of well-known modules. I'm fine with moving to error if you mind.

@@ -67,6 +67,18 @@ export default class SMSVerificationStore extends VerificationStore {
return hasReceivedCode(this.number, this.account, this.isTestnet);
}

// SMS verification events don't contain the phone number, so we will have to
// send a new request every single time. See below.
@action checkIfAbleToRequest = () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

checkIf? Doesn't sound like something is being set? (Maybe switch or set?)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hm, don't like switch, setIfAbleToRequest is ok. isAbleToRequest sounds like it's fully pure, so check seemed like a compromise. will change.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

assert might also work.

this.isVerified = isVerified;
const accountIsVerified = checkIfVerified(contract, account)
.then((accountIsVerified) => {
this.accountIsVerified = accountIsVerified;
Copy link
Contributor

Choose a reason for hiding this comment

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

Just be aware that MobX will complain here (since it is async) as soon as switched to strict mode.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will mobx recognise load as an async action if we return the Promise.all below?

return request.postTransaction(options, values);
})
.then((handle) => {
// TODO: The "request rejected" error doesn't have any property to
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure why this is a TODO? Possibly rather a note?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We still need to find a better solution, although we're technically limited right now.

@@ -231,20 +231,22 @@ class Verification extends Component {
} else if (method === 'email') {
fields.push({
key: 'email',
label: 'email address',
label: 'e-mail address',
Copy link
Contributor

Choose a reason for hiding this comment

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

Would obviously have preferred FormattedMessage here - it is coming more and more to the fore.

@jacogr
Copy link
Contributor

jacogr commented Feb 2, 2017

Style & coding issues that detracts a bit from maintainability and ease of understanding, however nothing functional broken nor buggy.

@jacogr jacogr added A6-mustntgrumble 💦 Pull request has areas for improvement. The author need not address them before merging. and removed A0-pleasereview 🤓 Pull request needs code review. labels Feb 2, 2017
@gavofyork gavofyork merged commit 1547af1 into master Feb 2, 2017
@gavofyork gavofyork deleted the jr-permissive-verification branch February 2, 2017 15:01
@derhuerst derhuerst mentioned this pull request Feb 2, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A6-mustntgrumble 💦 Pull request has areas for improvement. The author need not address them before merging.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants