forked from rGiladi/accounts-react
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add suport for resending verification email
- Tighten security overriding unused methods - Disable rendering of unused routes - Add option to disable unsecure method configureLoginService (meteor/meteor#7745) - Fix .eslintrc json syntax - Update docs with new features - Still missing tests
- Loading branch information
Showing
11 changed files
with
278 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
lib/AccountsReactComponent/methods/ARResendVerificationEmail.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { Accounts } from 'meteor/accounts-base' | ||
import { ValidatedMethod } from 'meteor/mdg:validated-method' | ||
import { check } from 'meteor/check' | ||
import AccountsReact from '../../AccountsReact' | ||
|
||
// Based on https://github.com/meteor-useraccounts/core/blob/2e8986813b51f321f908d2f6211f6f81f76cd627/lib/server_methods.js#L124 | ||
const ARResendVerificationEmail = new ValidatedMethod({ | ||
name: 'ARResendVerificationEmail', | ||
validate: ({ email }) => { | ||
/* This validation runs on both client and server */ | ||
|
||
if (Meteor.userId()) { | ||
throw new Meteor.Error('Error', 'Already logged in') | ||
} | ||
|
||
check(email, String); | ||
}, | ||
run ({ email }) { | ||
if (Meteor.isServer) { | ||
var user = Meteor.users.findOne({ "emails.address": email }); | ||
|
||
// Send the standard error back to the client if no user exist with this e-mail | ||
if (!user) { | ||
throw new Meteor.Error('UserNotFound', AccountsReact.config.texts.errors.userNotFound); | ||
} | ||
|
||
try { | ||
Accounts.sendVerificationEmail(user._id); | ||
} catch (error) { | ||
if (error.error === 'disabled') { | ||
throw error; | ||
} else { | ||
// Handle error when email already verified | ||
// https://github.com/dwinston/send-verification-email-bug | ||
throw new Meteor.Error('UserAlreadyVerified', AccountsReact.config.texts.errors.userAlreadyVerified); | ||
} | ||
} | ||
} | ||
} | ||
}) | ||
|
||
export default ARResendVerificationEmail |
Oops, something went wrong.