-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move calls for email magic link to data-layer (#38866)
* Add data-layer hander for email login * update send-login-email usage in get-apps * update usage to sendMobileEmailLogin * try removing dialog * add option to toggle global notices and add option for custom success and error events * remove custom error and success dispatches * Fix no undefined types linter issue * Use globalThis on jsdoc * Try dispatching all the actions! * move recordTracksEventWithClientId calls to data-layer handler * make sure the right type of email is sent * refactor to make usage clear between mobile app and normal email login * add jsdoc Co-authored-by: Miguel Torres <miguelmariatorresrojas@gmail.com>
- Loading branch information
Showing
9 changed files
with
221 additions
and
139 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/** | ||
* Internal dependencies | ||
*/ | ||
import { LOGIN_EMAIL_SEND } from 'state/action-types'; | ||
import { getLanguage, getLocaleSlug } from 'lib/i18n-utils'; | ||
import 'state/data-layer/wpcom/auth/send-login-email'; | ||
|
||
/** | ||
* Sends an email with a link that allows a user to login WordPress.com or the native apps | ||
* | ||
* @param {string} email - email to send to | ||
* @param {object} options object: | ||
* {string} redirectTo - url to redirect to after login | ||
* {boolean} loginFormFlow - if true, dispatches actions associated with passwordless login | ||
* {boolean} requestLoginEmailFormFlow - if true, dispatches actions associated with email me login | ||
* {boolean} isMobileAppLogin - if true, will send an email that allows login to the native apps | ||
* {boolean} showGlobalNotices - if true, displays global notices to user about the email | ||
* | ||
* @returns {object} action object | ||
*/ | ||
export const sendEmailLogin = ( | ||
email, | ||
{ | ||
redirectTo, | ||
showGlobalNotices = false, | ||
loginFormFlow = false, | ||
requestLoginEmailFormFlow = false, | ||
isMobileAppLogin = false, | ||
} | ||
) => { | ||
//Kind of weird usage, but this is a straight port from undocumented.js for now. | ||
//I can move this to the caller, if there's equivalent info in the state tree | ||
const locale = getLocaleSlug(); | ||
const lang_id = getLanguage( locale ).value; | ||
|
||
return { | ||
type: LOGIN_EMAIL_SEND, | ||
email, | ||
locale, | ||
lang_id, | ||
redirect_to: redirectTo, | ||
isMobileAppLogin, | ||
showGlobalNotices, | ||
loginFormFlow, | ||
requestLoginEmailFormFlow, | ||
}; | ||
}; |
Oops, something went wrong.