OAuth Login¶
Use this extension is used to add login functionality for 3rd party OAuth logins (i.e. Facebook, Google, Twitter, etc).
Prerequisites¶
Modules¶
- Miva OAuth Connector
- Set-up services in Miva OAuth Connector according to the documentation
- Currently Supported Services:
Packages¶
Installation¶
- Copy
optional-extensions/oauth-logintothemes/genesis/src/custom-extensions/oauth-login. -
Add
import {OauthLogin} from 'custom-extensions/oauth-login';tosrc/pages/Global.js.Alternatively, it is preferred to asynchronously load in the extension to improve page performance. This can be done by adding the following code to the
onReady()method in theGlobal.jsfile:(async () => { if (!document.getElementsByClassName('js-oauth-login')[0] && !document.getElementsByClassName('js-oauth-unlink')[0]) { return; } const {OauthLogin} = await import('custom-extensions/oauth-login'); new OauthLogin(); })();If you intend to have the OAuth login buttons only on specific pages or login forms (not available globally) the extension can also be installed within specific pages. For example in
src/pages/LOGN/LOGN.js. -
Add the
OAUTH_REDIRECTpage totheme.js- Copy the
OAUTH_REDIRECTfolder fromoptional-extensions/oauth-login/themes/genesis/src/pages/tothemes/genesis/src/pages. - Add
OAUTH_REDIRECT: () => import('pages/OAUTH_REDIRECT/OAUTH_REDIRECT.js')topageCodeImportsin thethemes/genesis/src/theme.jsfile.
- Copy the
- Create the following content sections in
Theme Component > Content Sectionsin the Miva admin:- OAuth Login
- Code: oauth_login
- Name: OAuth Login
- Content: Copy the content from
optional-extensions/oauth-login/miva-templates/properties/readytheme_contentsection/oauth_login.mvtfile into the content section. - Ensure the
Wrap in a <div> tagoption is unchecked
- OAuth Linked Accounts
- Code: oauth_linked
- Name: OAuth Linked Accounts
- Content: Copy the content from
optional-extensions/oauth-login/miva-templates/properties/readytheme_contentsection/oauth_linked.mvtfile into the content section. - Ensure the
Wrap in a <div> tagoption is unchecked
- Add the
<mvt:item name="readytheme" param="contentsection( 'oauth_login' )" />tag to any pages or content sections where you want the OAuth login buttons displayed (i.e.LOGN, checkout pages, etc). - Add the
<mvt:item name="readytheme" param="contentsection( 'oauth_linked' )" />tag to any pages or content sections where you want the OAuth link/unlink account buttons displayed (i.e.CEML,ACLN, etc).
- OAuth Login
- Configure the
linkPageCodevalue in the_settingsobject inthemes/genesis/src/custom-extensions/oauth-login/OauthRedirect.jswith the Page Code where you just placed theoauth_linkedcontent item in step 4. (default isCEML) - Add the styles to the
Global.scssfile@import "custom-extensions/oauth-login/index";
- Add the following page
User Interface > Templates > Page > OAuth Redirect:- OAuth Redirect
- Code: OAUTH_REDIRECT
- Name: OAuth Redirect
- Cache Page: Never Cache This Page
- Templates:
- Copy the content from the
optional-extensions/oauth-login/miva-templates/oauth_redirect.mvtfile to the Template section. - Copy the content from the
optional-extensions/oauth-login/miva-templates/oauth_redirect-content.mvtfile to the Content section.
- Copy the content from the
- Items
Assign the following items to the page under the Items tab:
- content
- global_minibasket
- hdft
- head
- html_profile
- oauth
- oauth_providers
- oauth_tokens
- prodctgy_meta
- readytheme
- ry_toolbelt
- store
- urls
- Update the page URL for the "Link/Unlink" email to match the code for the page where you placed the "unlink"
oauth_linkeditem in step 4 (i.e.&mvte:urls:CEML:secure;).
- OAuth Redirect
- Move the file for Oauth Email Juice template
optional-extensions/oauth-login/juice-email-templates/email_oauth.mvttosrc/juice-emails/emails/templates - Create the following Email Templates:
- Oauth Email
- Email Template options:
- Code:
OAUTH - Name:
Oauth Email - From:
&mvt:store:email; - Reply-To:
&mvt:store:email; - To:
Changes to your account - Subject:
Oauth Email - Mime Type:
text/html; charset=&mvt:store:charset; - Sending:
Manual
- Code:
- Alternatively you could run the following through Import Data and Settings in XML Provisioning Format
<Module code="templateorderemails" feature="fulfill"> <Email_Add> <Code>OAUTH</Code> <Name>Oauth Email</Name> <From>&mvt:store:email;</From> <ReplyTo>&mvt:store:email;</ReplyTo> <To>Changes to your account</To> <Subject>Oauth Email</Subject> <MimeType>text/html; charset=&mvt:store:charset;</MimeType> </Email_Add> </Module>
- Email Template options:
- Oauth Email
- Run
pnpm run buildsojuicebuilds theoauthemail template. - Paste the contents from
miva-templates/templates/email_oauth.mvt- Assign the following items to the page:
- readytheme
- store
- urls
- Assign the following items to the page:
- Assign the item
oauth_providersto all pages referencing your Oauth content Sections (if using globally, assign to all pages).