diff --git a/drupal-10/package/customer_identity_and_access_management.tar b/drupal-10/package/customer_identity_and_access_management.tar new file mode 100644 index 0000000..199db88 Binary files /dev/null and b/drupal-10/package/customer_identity_and_access_management.tar differ diff --git a/drupal-10/src/customer_identity_and_access_management/LICENCE.txt b/drupal-10/src/customer_identity_and_access_management/LICENCE.txt new file mode 100644 index 0000000..d159169 --- /dev/null +++ b/drupal-10/src/customer_identity_and_access_management/LICENCE.txt @@ -0,0 +1,339 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Lesser General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. diff --git a/drupal-10/src/customer_identity_and_access_management/README.md b/drupal-10/src/customer_identity_and_access_management/README.md new file mode 100644 index 0000000..9da1c8f --- /dev/null +++ b/drupal-10/src/customer_identity_and_access_management/README.md @@ -0,0 +1,206 @@ +# CIAM LoginRadius + +--- + +## SUMMARY + +Fully managed registration service including Email Registration, Social Login, password management, and data collection. + + +## REQUIREMENTS + LoginRadius PHP SDK library. Follow the installation instructions to add require php sdk library. + +## INSTALLATION + +1. Install as usual, see https://www.drupal.org/docs/extending-drupal/installing-modules for further information. +2. After successfully installing, you will see CIAM LoginRadius module in modules list in your site's admin account but do NOT enable the module yet because the required LoginRadius PHP SDK library is not installed. +3. Module comes with a file loginradius/composer.json. This file contains the dependency to LoginRadius PHP SDK so that Composer will know to download the SDK library in the next step. +4. Download and initialize Composer Manager to the /modules directory. +5. Let Composer download LoginRadius PHP SDK library for you. On command line of your server: + 1. Go to the root directory of your Drupal installation. + 2. Execute the following command to install PHP SDK + ```PHP + composer require loginradius/php-sdk:11.3.0 + ``` +6. After Successfully install LoginRadius PHP SDK, Enable CIAM Module. +7. Click on configuration link shown in CIAM or click on + configuration tab, Then go to people block and click on CIAM LoginRadius +8. On configuration page, you will see config option for CIAM module. + + +## CHANGE LOG + +### 5.1.2 + * Added Compatibility with Drupal 10 . + * Minor Enhancement + +### 5.1.1 + * Fixed the issue with the redirection after login. + +### 5.1.0 + * Replaced the getSocialUserProfile API with getProfileByAccessToken API as getSocialUserProfile API is deprecated in PHP-SDK version 11.2.0 or above. + * Fixed the issue with the redirection to the profile page. + * Added Compatibility with our latest PHP SDK 11.3.0 + +### 5.0.0 + * Added compatibility with Drupal-9.x + * Compatible with our latest PHP SDK 11.0.0 + +### 8.x-4.1 + * Added option - Do you want to delete the customer profile from the LoginRadius database on account delete in Drupal. + +### 8.x-4.0 + * Compatible with our latest PHP SDK 10.0.0. + * Added custom domain option for the IEF page. + * Added registration form schema option. + * Standardize the naming convention of labels and text of the plugin. + * Separate file for all notification messages for easy maintenance. + * Standardize the debug log logging method. + * Replaced Hosted page module name with Identity Experience Framework Module. + +### 8.x-3.16 + * Removed page attachments hook from admin pages. + * Removed Session which was storing all the user profile data. + * Removed anonymous user session from database. + * Add option to not store email/username in drupal. + * Fixed some bugs. + +### 8.x-3.15 + * Handled API Request Signing feature. + * Standardize the code as per Drupal coding standard reported. + +### 8.x-3.14 + * Capitalised HTTP Method Names. + +### 8.x-3.13 + * SSO related bug fixed. + +### 8.x-3.12 + * Bug Fixed: Admin logout when SSO is enabled. + +### 8.x-3.11 + * Fixed SSO logout related bug on iOS. + +### 8.x-3.10 + * Autologout if SSO is enabled. + * Standardise usage of global variables. + +### 8.x-3.9 + * Removed "lr_ciam_preprocess" hook from lr_ciam module. + +### 8.x-3.8 + * Added cache contexts of user roles in SSO module to improve performance. + * Added loading image variable to the required pages. + * Added functionality to logout user from drupal after lr access token expired. + +### 8.x-3.7 + * Removed some API calls and managed it with session to improve performance. + +### 8.x-3.6 + * Fixed Config files naming bug. + * Fixed User name collision bug. + +### 8.x-3.5 + * Removed some Advance options from backend and they are directly handled by Cloud API. + * Implemented custom login, registration & forgot password blocks. + * Implemented set password functionality for social users. + * Added Fallback JS. + +### 8.x-3.4 + * Replaced LR Auth module with LR Simple OAuth module to authenticate the user using LR API. + +### 3.3.0 + * Fixed bug related to user change password access. + +### 3.2.0 + * Added lr auth module to generate access token of simple oauth module. + +### 3.1.0 + * Added google v2 recaptcha feature. + * Added One Click Sign In feature. + * Added login with phone number feature. + * Added two factor authentication feature. + * Added hosted page module to login, registration, forgot password etc via loginradius hosted page. + +### 3.0.0 + * Migrated plugin on V2 APIs. + * Removed social login, social Profile Data, social sharing from package. + * Added remember me option. + * Added ask required field on traditional login option. + * Added add/remove email functionality for frontend users. + +### 2.2.1 + * Added readme and license files in module directory. + +### 2.2.0 + * SSO related minor issue if hosted page is enabled + * mapping related issue if type id email and date + * Correct error message + +### 2.1.0 + * Fixed all known bugs. + * Moduler approch with all features in plugin. + * Add a submodule for Hosted page enable functionality + * Log system for all success/error API in db and show it on admin panel. + * Show total number of user logged on website in extended user profile. + * user can verify in login/notlogin both case. + +### 2.0.0 + * Added following options in module:- + 1. Email verification url + 2. Forgot password url + 3. In form validation message + 4. Terms and condition html + 5. Form render delay + 6. Password length + 7. V2 recaptcha + 8. V2 recaptcha site key + 9. Enable login on email verification + 10. Prompt password on social login + 11. Enable login with username + 12. Forgot password template + 13. Email verification template + + + + +## LIVE DEMO +http://demo.loginradius.com + +## FAQ + + Q: What is LoginRadius? + + A: LoginRadius is a Software As A Service (SAAS) which allows users to log in + to a third party website via + popular open IDs/oAuths such as Google, Facebook, Yahoo, AOL and over 20 more. + +Q: How long can I keep my account? + +A: How long you use LoginRadius is completely up to you. You may remove +LoginRadius +from your website and delete your account at any time. + +Q: What is the best way to reach the LoginRadius Team? + +A: If you have any questions or concerns regarding LoginRadius, +please write us at hello@loginradius.com. + +Q: How much you charge for this service? + +A: It is FREE and will remain free, but for advanced features and customized +solutions, +there are various packages available. Please contact us for further +details. + +Q: Do you have a live demo site? + +A: Yes, please visit our Drupal live demo site at +http://demo.loginradius.com + + +## CONTACT + + Current maintainers: + * LoginRadius - http://www.loginradius.com + * Email: hello [at] loginradius [dot] com diff --git a/drupal-10/src/customer_identity_and_access_management/composer.json b/drupal-10/src/customer_identity_and_access_management/composer.json new file mode 100644 index 0000000..14a46da --- /dev/null +++ b/drupal-10/src/customer_identity_and_access_management/composer.json @@ -0,0 +1,9 @@ +{ + "name": "drupal/customer_identity_and_access_management", + "description": "The LoginRadius Customer Identity and Access Management", + "type": "drupal-module", + "require": { + "loginradius/php-sdk": "11.3.0" + }, + "license": "GPL-2.0+" +} diff --git a/drupal-10/src/customer_identity_and_access_management/lr_ciam/ciam_lang.php b/drupal-10/src/customer_identity_and_access_management/lr_ciam/ciam_lang.php new file mode 100644 index 0000000..b7cb974 --- /dev/null +++ b/drupal-10/src/customer_identity_and_access_management/lr_ciam/ciam_lang.php @@ -0,0 +1,26 @@ +img { + vertical-align: middle; +} + +input#loginradius-linksignin-email-me-a-link-to-sign-in:hover, +input#loginradius-linksignin-email-me-a-link-to-sign-in:active, +input#loginradius-linksignin-email-me-a-link-to-sign-in:focus { + border-bottom-style: outset; +} + +input#loginradius-linksignin-email-me-a-link-to-sign-in { + height: 31px; + color: #3b3b3b; +} + +#edit-phoneid { + background: #ededed; +} + +.ui-datepicker { + z-index: 9999999 !important; +} + +#edit-thanks-block { + background-color: #dfebf5; +} + +#edit-phone-warning-block { + background-color: rgb(255, 255, 224); +} + +ul.loginradiuscustomsso-idlinks { + list-style-type: none; +} + +div.loginradius-ciam-validation-message { + color: red; +} + +.ciam-lr-form.my-form-wrapper input[type=text], +.ciam-lr-form.my-form-wrapper input[type=email], +.ciam-lr-form.my-form-wrapper input[type=password] { + width: 363px; + color:black; +} + +#social-registration-container .loginradius-ciam--form-element-content input, +#social-registration-container .loginradius-ciam-option { + font-family: Arial, Helvetica, sans-serif; + color: #444; + font-size: 13px; + border: 1px solid #e2efe1; + width: 350px; + height: 27px; + margin-bottom: 5px !important; + padding-left: 10px; + border-radius: 0 12px; + background: #fff; +} + +.popupinner { + overflow: auto; + background: #fff; + padding: 15px 20px; +} + +#social-registration-container .loginradius-ciam-submit { + display: inline-block; + outline: 0; + cursor: pointer; + text-align: center; + text-decoration: none; + font: 14px/100% Arial, Helvetica, sans-serif; + padding: 5px 15px; + width: auto; + color: #6e6e6e !important; + border: 1px solid #ddd; + border-radius: 0 11px !important; + background: #efefef; + margin-top: 6px; +} + +.provideractive { + -webkit-box-shadow: inset 0 0 20px #c0dbf2; + -moz-box-shadow: inset 0 0 20px #c0dbf2; + -ms-box-shadow: inset 0 0 20px #c0dbf2; + box-shadow: inset 0 0 20px #c0dbf2; + -webkit-animation: glow 2s ease infinite; + -moz-animation: glow 2s ease infinite; + -ms-animation: glow 2s ease infinite; + animation: glow 2s ease infinite; +} + +@-webkit-keyframes glow { + 50% { + -webkit-box-shadow: inset 0 0 5px #c0dbf2; + -moz-box-shadow: inset 0 0 5px #c0dbf2; + -ms-box-shadow: inset 0 0 5px #c0dbf2; + box-shadow: inset 0 0 5px #c0dbf2; + } + + 100% { + -webkit-box-shadow: inset 0 0 20px #c0dbf2; + -moz-box-shadow: inset 0 0 20px #c0dbf2; + -ms-box-shadow: inset 0 0 20px #c0dbf2; + box-shadow: inset 0 0 20px #c0dbf2; + } +} + +@-moz-keyframes glow { + 50% { + -webkit-box-shadow: inset 0 0 5px #c0dbf2; + -moz-box-shadow: inset 0 0 5px #c0dbf2; + -ms-box-shadow: inset 0 0 5px #c0dbf2; + box-shadow: inset 0 0 5px #c0dbf2; + } + + 100% { + -webkit-box-shadow: inset 0 0 20px #c0dbf2; + -moz-box-shadow: inset 0 0 20px #c0dbf2; + -ms-box-shadow: inset 0 0 20px #c0dbf2; + box-shadow: inset 0 0 20px #c0dbf2; + } +} + +@-ms-keyframes glow { + 50% { + -webkit-box-shadow: inset 0 0 5px #c0dbf2; + -moz-box-shadow: inset 0 0 5px #c0dbf2; + -ms-box-shadow: inset 0 0 5px #c0dbf2; + box-shadow: inset 0 0 5px #c0dbf2; + } + + 100% { + -webkit-box-shadow: inset 0 0 20px #c0dbf2; + -moz-box-shadow: inset 0 0 20px #c0dbf2; + -ms-box-shadow: inset 0 0 20px #c0dbf2; + box-shadow: inset 0 0 20px #c0dbf2; + } +} + +@keyframes glow { + 50% { + -webkit-box-shadow: inset 0 0 5px #c0dbf2; + -moz-box-shadow: inset 0 0 5px #c0dbf2; + -ms-box-shadow: inset 0 0 5px #c0dbf2; + box-shadow: inset 0 0 5px #c0dbf2; + } + + 100% { + -webkit-box-shadow: inset 0 0 20px #c0dbf2; + -moz-box-shadow: inset 0 0 20px #c0dbf2; + -ms-box-shadow: inset 0 0 20px #c0dbf2; + box-shadow: inset 0 0 20px #c0dbf2; + } +} + +.lr_singleglider_200 { + background: 0 0; +} + +.lr_singleglider_200>h3 { + color: #666; + font-family: Arial, Helvetica, sans-serif; + font-size: 12px; + margin: 0; + padding: 10px 0 7px 3px; +} + +.lr_singleglider_200 .lr_icons_box { + float: left; + margin: 0 0 6px; +} + +.lr_singleglider_200 .lr_icons_box div { + float: left; + margin: 0 6px 0 0; +} + +.lr_singleglider_200 .lr_providericons { + width: 38px; + height: 38px; + background-image: url(../images/lr_provider_sprite.png); + cursor: pointer; + display: block; + position: relative; + z-index: 9998; + outline: 0; + margin: 0 auto; +} + +.lr_singleglider_200 .lr_aol { + width: 38px; + height: 38px; + background-position: 0 -950px; +} + +.lr_singleglider_200 .lr_facebook { + width: 38px; + height: 38px; + background-position: 0 -912px; +} + +.lr_singleglider_200 .lr_pinterest { + width: 38px; + height: 38px; + background-position: 0 74px; +} + +.lr_singleglider_200 .lr_line { + width: 38px; + height: 38px; + background-position: 0 36px; +} + +.lr_singleglider_200 .lr_foursquare { + width: 38px; + height: 38px; + background-position: 0 -874px; +} + +.lr_singleglider_200 .lr_github { + width: 38px; + height: 38px; + background-position: 0 -836px; +} + +.lr_singleglider_200 .lr_google { + width: 38px; + height: 38px; + background-position: 0 -798px; +} + +.lr_singleglider_200 .lr_hyves { + width: 38px; + height: 38px; + background-position: 0 -760px; +} + +.lr_singleglider_200 .lr_kaixin { + width: 38px; + height: 38px; + background-position: 0 -722px; +} + +.lr_singleglider_200 .lr_linkedin { + width: 38px; + height: 38px; + background-position: 0 -684px; +} + +.lr_singleglider_200 .lr_live { + width: 38px; + height: 38px; + background-position: 0 -646px; +} + +.lr_singleglider_200 .lr_livejournal { + width: 38px; + height: 38px; + background-position: 0 -608px; +} + +.lr_singleglider_200 .lr_mixi { + width: 38px; + height: 38px; + background-position: 0 -570px; +} + +.lr_singleglider_200 .lr_myopenid { + width: 38px; + height: 38px; + background-position: 0 -456px; +} + +.lr_singleglider_200 .lr_myspace { + width: 38px; + height: 38px; + background-position: 0 -494px; +} + +.lr_singleglider_200 .lr_openid { + width: 38px; + height: 38px; + background-position: 0 -532px; +} + +.lr_singleglider_200 .lr_orange { + width: 38px; + height: 38px; + background-position: 0 -418px; +} + +.lr_singleglider_200 .lr_persona { + width: 38px; + height: 38px; + background-position: 0 -380px; +} + +.lr_singleglider_200 .lr_qq { + width: 38px; + height: 38px; + background-position: 0 -342px; +} + +.lr_singleglider_200 .lr_renren { + width: 38px; + height: 38px; + background-position: 0 -304px; +} + +.lr_singleglider_200 .lr_stackexchange { + width: 38px; + height: 38px; + background-position: 0 -266px; +} + +.lr_singleglider_200 .lr_steamcommunity { + width: 38px; + height: 38px; + background-position: 0 -228px; +} + +.lr_singleglider_200 .lr_twitter { + width: 38px; + height: 38px; + background-position: 0 -190px; +} + +.lr_singleglider_200 .lr_verisign { + width: 38px; + height: 38px; + background-position: 0 -152px; +} + +.lr_singleglider_200 .lr_virgilio { + width: 38px; + height: 38px; + background-position: 0 -114px; +} + +.lr_singleglider_200 .lr_vkontakte { + width: 38px; + height: 38px; + background-position: 0 -76px; +} + +.lr_singleglider_200 .lr_wordpress { + width: 38px; + height: 38px; + background-position: 0 -38px; +} + +.lr_singleglider_200 .lr_yahoo { + width: 38px; + height: 38px; + background-position: 0 0; +} + +.lr_singleglider_200 .arrow_next { + width: 6px; + height: 12px; + background-position: -38px -10px; +} + +.lr_singleglider_200 .arrow_prev { + width: 5px; + height: 10px; + background-position: -38px 0; +} + +.lr_singleglider_200 .lr_disqus { + width: 38px; + height: 38px; + background-position: 0 -1254px; +} + +.lr_singleglider_200 .lr_instagram { + width: 38px; + height: 38px; + background-position: 0 -1178px; +} + +.lr_singleglider_200 .lr_sinaweibo { + width: 38px; + height: 38px; + background-position: 0 -1140px; +} + +.lr_singleglider_200 .lr_tumblr { + width: 38px; + height: 38px; + background-position: 0 -1216px; +} + +.lr_singleglider_200 .lr_amazon { + width: 38px; + height: 38px; + background-position: 0 -989px; +} + +.lr_singleglider_200 .lr_odnoklassniki { + width: 38px; + height: 38px; + background-position: 0 -1026px; +} + +.lr_singleglider_200 .lr_paypal { + width: 38px; + height: 38px; + background-position: 0 -1064px; +} + +.lr_singleglider_200 .lr_salesforce { + width: 38px; + height: 38px; + background-position: 0 -1102px; +} + +.lr_singleglider_200 .lr_xing { + width: 38px; + height: 38px; + background-position: 0 -1292px; +} + +.lr_singleglider_200 .lr_mailru { + width: 38px; + height: 38px; + background-position: 0 -1330px; +} + +.lr_powered_text { + text-align: left; + color: #21759b; + font-family: Arial, Helvetica, sans-serif; + font-size: 11px; + margin: 0; + padding: 0 3px 6px 15px; +} + +#lr_powered_text_link { + width: 130px; + height: 13px; + background-repeat: no-repeat; + display: block; +} + +.lr-linked-data.lr_singleglider_200 span { + float: left; +} + +.lr-linked-data.lr_singleglider_200 div { + clear: both; +} + +.lr-linked-data.lr_singleglider_200 span.lr_providericons { + margin: 0 6px 2px; +} + +.mymsg { + display: none; +} + +.loginradius-validation-message { + color: red; +} + +.socialRegistration { + background: no-repeat rgba(127, 127, 127, .6); + top: 0; + left: 0; + z-index: 100001; + width: 100%; + height: 100%; + position: fixed; + overflow: auto; +} + +.socialRegistration form[name=loginradius-socialRegistration] { + background: #fff; + width: 400px; + padding: 30px; + border: 1px solid #ddd; + border-radius: 0 11px !important; + margin: 10% auto; +} + +#showRemovePopup { + display: none; +} + +.LoginRadius_overlay { + background: #7f7f7f; + background: no-repeat rgba(127, 127, 127, .6); + top: 0; + left: 0; + z-index: 100001; + width: 100%; + height: 100%; + overflow: auto; + padding: 0; + position: fixed; + -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=90)"; + filter: alpha(opacity=90); +} + +#addemail-form .lr-popupheading, +#removeemail-form .lr-popupheading { + background: #efefef; + font-size: 17px; + font-weight: 400; + line-height: 20px; + padding: 15px; + border-radius: 0 20px 0 0; +} + +.closeRemove { + text-align: right; + cursor: pointer; + margin-top: -22px; +} + +.removeEmail { + cursor: pointer; + border-radius: 5px; + width: 70px; + text-align: center; + background-color: darkgray; +} + +.addEmail { + cursor: pointer; + border-radius: 5px; + width: 70px; + text-align: center; + background-color: darkgray; +} + +#addemail-form .popupmain, +#removeemail-form .popupmain { + background: #fff; + width: 506px; + left: 50%; + top: 45%; + margin-left: -250px; + margin-top: -250px; + position: absolute; + z-index: 999999; + font-family: Arial, Helvetica, sans-serif; + font-size: 13px; + border-radius: 0 23px; +} + +#addemail-form .lr-popup-footer, +#removeemail-form .lr-popup-footer { + background: #efefef; + border-radius: 0 0 0 20px; + color: #000; + font-family: Arial, Helvetica, sans-serif; + font-size: 18px; + font-weight: 400; + height: 45px; + padding: 7px 10px 0; + text-align: left; +} + +#addemail-container input[type=text], +#removeemail-container input[type=text] { + font-family: Arial, Helvetica, sans-serif; + color: #444; + border: 1px solid #e2efe1; + width: 250px; + height: 27px; + margin-bottom: 5px !important; + padding-left: 10px; + border-radius: 0 12px; + background: #fff; + margin-left: 80px; +} + +#addemail-container label, +#removeemail-container label { + margin-top: 5px; + margin-left: 80px; +} + +#addemail-container input[type=submit], +#removeemail-container input[type=submit] { + margin-left: 62%; +} + +#authentication-container input[type=button], +#authentication-container input[type=submit] { + background-color: darkseagreen; +} + +.loginradius-linksignin { + margin-left: 2px; +} + +#edit-reset .resetCode:hover { + background: #fff; + color: #29d; + border: 1px solid #29d; + cursor: pointer; +} + +#edit-reset .resetCode { + background: #29d; + float: right; + color: #fff; + padding: 6px 10px; +} + +.resetCode { + margin-right: 5px; +} + +#lr_ciam_reset_table { + clear: both; + margin-top: 45px; +} + +div#backupcode-table-body { + display: inline-block; +} + +#backupcode-table-body .form-item { + float: left; + margin-top: -8px !important; + width: 48%; + background: #eee; + border: 2px solid #fff; + padding: 5px; +} + +#resettable p { + border: 1px solid red; + padding: 5px; + border-radius: 5px; + background: hsla(0, 100%, 50%, 0.18); +} + +#resettable { + margin-right: 100px; +} + +.mybackupcopy { + width: 32px; + float: right; + background-image: url(../images/copy.png); + height: 40px; + background-size: 24px 24px; + background-repeat: no-repeat; + margin: 5px; + cursor: pointer; +} + +.copyMessage { + background-color: #eeeeee; + display: inline-block; + padding: 6px 12px 5px 10px; + color: #59b32c; + margin-left: 86%; + margin-bottom: -21px; +} + +#login-container .linksignin-loginradius-Send { + padding: 4px; +} + +.content-loginradius-stayLogin label { + margin-top: -22px; + margin-left: 20px; +} + +.loginType { + font-weight: bold; +} + +.loginTypeTooltip { + text-decoration: none !important; + cursor: pointer !important; +} + +.logintypeColor { + color: #3cf; +} + +div.form-item-ciam-welcome-email-template label, +div.form-item-ciam-email-verification-template label, +div.form-item-ciam-reset-password-email-template label, +div.form-item-ciam-instant-link-login-email-template label, +div.form-item-ciam-welcome-sms-template label, +div.form-item-ciam-sms-template-phone-verification label, +div.form-item-ciam-sms-template-one-time-passcode label, +div.form-item-ciam-sms-template-reset-password label, +div.form-item-ciam-sms-template-change-phone-no label, +div.form-item-ciam-sms-template-2fa label { + margin-top: 18px; + margin-bottom: -18px; + position: relative; +} + +#edit-ciam-welcome-email-template, +#edit-ciam-email-verification-template, +#edit-ciam-reset-password-email-template, +#edit-ciam-instant-link-login-email-template, +#edit-ciam-welcome-sms-template, +#edit-ciam-sms-template-phone-verification, +#edit-ciam-sms-template-reset-password, +#edit-ciam-sms-template-change-phone-no, +#edit-ciam-sms-template-one-time-passcode, +#edit-ciam-sms-template-2fa { + margin: 0px 0px 0px 440px; + clear: both; + width: 150px; +} + +#ciam_show_button { + left: 504px; + padding: 7px 8px; + background: #29d; + width: 40px; + color: #fff; + position: absolute; + text-align: center; + cursor: pointer; + margin-top: -40px; +} +#loginradius-submit-login, +#loginradius-submit-register, +#loginradius-submit-send{ + color: black; +} +.oneclick--errormsg{ + color: #a51b00; + background-color: #fcf4f2; + box-shadow: -8px 0 0 #e62600; + padding: 15px 20px 15px 35px; + border: 1px solid; + border-width: 1px 1px 1px 0; + margin-top: 15px; + border-radius: 2px; + overflow-wrap: break-word; +} +.user-form .field--type-boolean, +.user-form .field--type-string, +.user-form .field--type-list-string, +.user-form .field--type-entity-reference, +.user-form .field--type-datetime, +.user-form .field--type-email, +.user-form .field--type-timestamp, +.user-form .field--type-link, +.user-form .field--type-list-float, +.user-form .field--type-list-integer, +.user-form .field--type-decimal, +.user-form .field--type-float, +.user-form .field--type-integer, +.user-form .field--type-text +{ + display:none; +} diff --git a/drupal-10/src/customer_identity_and_access_management/lr_ciam/css/ciam.min.css b/drupal-10/src/customer_identity_and_access_management/lr_ciam/css/ciam.min.css new file mode 100644 index 0000000..6667d69 --- /dev/null +++ b/drupal-10/src/customer_identity_and_access_management/lr_ciam/css/ciam.min.css @@ -0,0 +1 @@ +.lr-linked-data div>img{vertical-align:middle}input#loginradius-linksignin-email-me-a-link-to-sign-in:active,input#loginradius-linksignin-email-me-a-link-to-sign-in:focus,input#loginradius-linksignin-email-me-a-link-to-sign-in:hover{border-bottom-style:outset}input#loginradius-linksignin-email-me-a-link-to-sign-in{height:31px;color:#3b3b3b}#edit-phoneid{background:#ededed}.ui-datepicker{z-index:9999999!important}#edit-thanks-block{background-color:#dfebf5}#edit-phone-warning-block{background-color:#ffffe0}ul.loginradiuscustomsso-idlinks{list-style-type:none}div.loginradius-ciam-validation-message{color:red}.ciam-lr-form.my-form-wrapper input[type=email],.ciam-lr-form.my-form-wrapper input[type=password],.ciam-lr-form.my-form-wrapper input[type=text]{width:363px;color:#000}#social-registration-container .loginradius-ciam--form-element-content input,#social-registration-container .loginradius-ciam-option{font-family:Arial,Helvetica,sans-serif;color:#444;font-size:13px;border:1px solid #e2efe1;width:350px;height:27px;margin-bottom:5px!important;padding-left:10px;border-radius:0 12px;background:#fff}.popupinner{overflow:auto;background:#fff;padding:15px 20px}#social-registration-container .loginradius-ciam-submit{display:inline-block;outline:0;cursor:pointer;text-align:center;text-decoration:none;font:14px/100% Arial,Helvetica,sans-serif;padding:5px 15px;width:auto;color:#6e6e6e!important;border:1px solid #ddd;border-radius:0 11px!important;background:#efefef;margin-top:6px}.provideractive{-webkit-box-shadow:inset 0 0 20px #c0dbf2;-moz-box-shadow:inset 0 0 20px #c0dbf2;-ms-box-shadow:inset 0 0 20px #c0dbf2;box-shadow:inset 0 0 20px #c0dbf2;-webkit-animation:glow 2s ease infinite;-moz-animation:glow 2s ease infinite;-ms-animation:glow 2s ease infinite;animation:glow 2s ease infinite}@-webkit-keyframes glow{50%{-webkit-box-shadow:inset 0 0 5px #c0dbf2;-moz-box-shadow:inset 0 0 5px #c0dbf2;-ms-box-shadow:inset 0 0 5px #c0dbf2;box-shadow:inset 0 0 5px #c0dbf2}100%{-webkit-box-shadow:inset 0 0 20px #c0dbf2;-moz-box-shadow:inset 0 0 20px #c0dbf2;-ms-box-shadow:inset 0 0 20px #c0dbf2;box-shadow:inset 0 0 20px #c0dbf2}}@-moz-keyframes glow{50%{-webkit-box-shadow:inset 0 0 5px #c0dbf2;-moz-box-shadow:inset 0 0 5px #c0dbf2;-ms-box-shadow:inset 0 0 5px #c0dbf2;box-shadow:inset 0 0 5px #c0dbf2}100%{-webkit-box-shadow:inset 0 0 20px #c0dbf2;-moz-box-shadow:inset 0 0 20px #c0dbf2;-ms-box-shadow:inset 0 0 20px #c0dbf2;box-shadow:inset 0 0 20px #c0dbf2}}@-ms-keyframes glow{50%{-webkit-box-shadow:inset 0 0 5px #c0dbf2;-moz-box-shadow:inset 0 0 5px #c0dbf2;-ms-box-shadow:inset 0 0 5px #c0dbf2;box-shadow:inset 0 0 5px #c0dbf2}100%{-webkit-box-shadow:inset 0 0 20px #c0dbf2;-moz-box-shadow:inset 0 0 20px #c0dbf2;-ms-box-shadow:inset 0 0 20px #c0dbf2;box-shadow:inset 0 0 20px #c0dbf2}}@keyframes glow{50%{-webkit-box-shadow:inset 0 0 5px #c0dbf2;-moz-box-shadow:inset 0 0 5px #c0dbf2;-ms-box-shadow:inset 0 0 5px #c0dbf2;box-shadow:inset 0 0 5px #c0dbf2}100%{-webkit-box-shadow:inset 0 0 20px #c0dbf2;-moz-box-shadow:inset 0 0 20px #c0dbf2;-ms-box-shadow:inset 0 0 20px #c0dbf2;box-shadow:inset 0 0 20px #c0dbf2}}.lr_singleglider_200{background:0 0}.lr_singleglider_200>h3{color:#666;font-family:Arial,Helvetica,sans-serif;font-size:12px;margin:0;padding:10px 0 7px 3px}.lr_singleglider_200 .lr_icons_box{float:left;margin:0 0 6px}.lr_singleglider_200 .lr_icons_box div{float:left;margin:0 6px 0 0}.lr_singleglider_200 .lr_providericons{width:38px;height:38px;background-image:url(../images/lr_provider_sprite.png);cursor:pointer;display:block;position:relative;z-index:9998;outline:0;margin:0 auto}.lr_singleglider_200 .lr_aol{width:38px;height:38px;background-position:0 -950px}.lr_singleglider_200 .lr_facebook{width:38px;height:38px;background-position:0 -912px}.lr_singleglider_200 .lr_pinterest{width:38px;height:38px;background-position:0 74px}.lr_singleglider_200 .lr_line{width:38px;height:38px;background-position:0 36px}.lr_singleglider_200 .lr_foursquare{width:38px;height:38px;background-position:0 -874px}.lr_singleglider_200 .lr_github{width:38px;height:38px;background-position:0 -836px}.lr_singleglider_200 .lr_google{width:38px;height:38px;background-position:0 -798px}.lr_singleglider_200 .lr_hyves{width:38px;height:38px;background-position:0 -760px}.lr_singleglider_200 .lr_kaixin{width:38px;height:38px;background-position:0 -722px}.lr_singleglider_200 .lr_linkedin{width:38px;height:38px;background-position:0 -684px}.lr_singleglider_200 .lr_live{width:38px;height:38px;background-position:0 -646px}.lr_singleglider_200 .lr_livejournal{width:38px;height:38px;background-position:0 -608px}.lr_singleglider_200 .lr_mixi{width:38px;height:38px;background-position:0 -570px}.lr_singleglider_200 .lr_myopenid{width:38px;height:38px;background-position:0 -456px}.lr_singleglider_200 .lr_myspace{width:38px;height:38px;background-position:0 -494px}.lr_singleglider_200 .lr_openid{width:38px;height:38px;background-position:0 -532px}.lr_singleglider_200 .lr_orange{width:38px;height:38px;background-position:0 -418px}.lr_singleglider_200 .lr_persona{width:38px;height:38px;background-position:0 -380px}.lr_singleglider_200 .lr_qq{width:38px;height:38px;background-position:0 -342px}.lr_singleglider_200 .lr_renren{width:38px;height:38px;background-position:0 -304px}.lr_singleglider_200 .lr_stackexchange{width:38px;height:38px;background-position:0 -266px}.lr_singleglider_200 .lr_steamcommunity{width:38px;height:38px;background-position:0 -228px}.lr_singleglider_200 .lr_twitter{width:38px;height:38px;background-position:0 -190px}.lr_singleglider_200 .lr_verisign{width:38px;height:38px;background-position:0 -152px}.lr_singleglider_200 .lr_virgilio{width:38px;height:38px;background-position:0 -114px}.lr_singleglider_200 .lr_vkontakte{width:38px;height:38px;background-position:0 -76px}.lr_singleglider_200 .lr_wordpress{width:38px;height:38px;background-position:0 -38px}.lr_singleglider_200 .lr_yahoo{width:38px;height:38px;background-position:0 0}.lr_singleglider_200 .arrow_next{width:6px;height:12px;background-position:-38px -10px}.lr_singleglider_200 .arrow_prev{width:5px;height:10px;background-position:-38px 0}.lr_singleglider_200 .lr_disqus{width:38px;height:38px;background-position:0 -1254px}.lr_singleglider_200 .lr_instagram{width:38px;height:38px;background-position:0 -1178px}.lr_singleglider_200 .lr_sinaweibo{width:38px;height:38px;background-position:0 -1140px}.lr_singleglider_200 .lr_tumblr{width:38px;height:38px;background-position:0 -1216px}.lr_singleglider_200 .lr_amazon{width:38px;height:38px;background-position:0 -989px}.lr_singleglider_200 .lr_odnoklassniki{width:38px;height:38px;background-position:0 -1026px}.lr_singleglider_200 .lr_paypal{width:38px;height:38px;background-position:0 -1064px}.lr_singleglider_200 .lr_salesforce{width:38px;height:38px;background-position:0 -1102px}.lr_singleglider_200 .lr_xing{width:38px;height:38px;background-position:0 -1292px}.lr_singleglider_200 .lr_mailru{width:38px;height:38px;background-position:0 -1330px}.lr_powered_text{text-align:left;color:#21759b;font-family:Arial,Helvetica,sans-serif;font-size:11px;margin:0;padding:0 3px 6px 15px}#lr_powered_text_link{width:130px;height:13px;background-repeat:no-repeat;display:block}.lr-linked-data.lr_singleglider_200 span{float:left}.lr-linked-data.lr_singleglider_200 div{clear:both}.lr-linked-data.lr_singleglider_200 span.lr_providericons{margin:0 6px 2px}.mymsg{display:none}.loginradius-validation-message{color:red}.socialRegistration{background:no-repeat rgba(127,127,127,.6);top:0;left:0;z-index:100001;width:100%;height:100%;position:fixed;overflow:auto}.socialRegistration form[name=loginradius-socialRegistration]{background:#fff;width:400px;padding:30px;border:1px solid #ddd;border-radius:0 11px!important;margin:10% auto}#showRemovePopup{display:none}.LoginRadius_overlay{background:#7f7f7f;background:no-repeat rgba(127,127,127,.6);top:0;left:0;z-index:100001;width:100%;height:100%;overflow:auto;padding:0;position:fixed}#addemail-form .lr-popupheading,#removeemail-form .lr-popupheading{background:#efefef;font-size:17px;font-weight:400;line-height:20px;padding:15px;border-radius:0 20px 0 0}.closeRemove{text-align:right;cursor:pointer;margin-top:-22px}.removeEmail{cursor:pointer;border-radius:5px;width:70px;text-align:center;background-color:#a9a9a9}.addEmail{cursor:pointer;border-radius:5px;width:70px;text-align:center;background-color:#a9a9a9}#addemail-form .popupmain,#removeemail-form .popupmain{background:#fff;width:506px;left:50%;top:45%;margin-left:-250px;margin-top:-250px;position:absolute;z-index:999999;font-family:Arial,Helvetica,sans-serif;font-size:13px;border-radius:0 23px}#addemail-form .lr-popup-footer,#removeemail-form .lr-popup-footer{background:#efefef;border-radius:0 0 0 20px;color:#000;font-family:Arial,Helvetica,sans-serif;font-size:18px;font-weight:400;height:45px;padding:7px 10px 0;text-align:left}#addemail-container input[type=text],#removeemail-container input[type=text]{font-family:Arial,Helvetica,sans-serif;color:#444;border:1px solid #e2efe1;width:250px;height:27px;margin-bottom:5px!important;padding-left:10px;border-radius:0 12px;background:#fff;margin-left:80px}#addemail-container label,#removeemail-container label{margin-top:5px;margin-left:80px}#addemail-container input[type=submit],#removeemail-container input[type=submit]{margin-left:62%}#authentication-container input[type=button],#authentication-container input[type=submit]{background-color:#8fbc8f}.loginradius-linksignin{margin-left:2px}#edit-reset .resetCode:hover{background:#fff;color:#29d;border:1px solid #29d;cursor:pointer}#edit-reset .resetCode{background:#29d;float:right;color:#fff;padding:6px 10px}.resetCode{margin-right:5px}#lr_ciam_reset_table{clear:both;margin-top:45px}div#backupcode-table-body{display:inline-block}#backupcode-table-body .form-item{float:left;margin-top:-8px!important;width:48%;background:#eee;border:2px solid #fff;padding:5px}#resettable p{border:1px solid red;padding:5px;border-radius:5px;background:hsla(0,100%,50%,.18)}#resettable{margin-right:100px}.mybackupcopy{width:32px;float:right;background-image:url(../images/copy.png);height:40px;background-size:24px 24px;background-repeat:no-repeat;margin:5px;cursor:pointer}.copyMessage{background-color:#eee;display:inline-block;padding:6px 12px 5px 10px;color:#59b32c;margin-left:86%;margin-bottom:-21px}#login-container .linksignin-loginradius-Send{padding:4px}.content-loginradius-stayLogin label{margin-top:-22px;margin-left:20px}.loginType{font-weight:700}.loginTypeTooltip{text-decoration:none!important;cursor:pointer!important}.logintypeColor{color:#3cf}div.form-item-ciam-email-verification-template label,div.form-item-ciam-instant-link-login-email-template label,div.form-item-ciam-reset-password-email-template label,div.form-item-ciam-sms-template-2fa label,div.form-item-ciam-sms-template-change-phone-no label,div.form-item-ciam-sms-template-one-time-passcode label,div.form-item-ciam-sms-template-phone-verification label,div.form-item-ciam-sms-template-reset-password label,div.form-item-ciam-welcome-email-template label,div.form-item-ciam-welcome-sms-template label{margin-top:18px;margin-bottom:-18px;position:relative}#edit-ciam-email-verification-template,#edit-ciam-instant-link-login-email-template,#edit-ciam-reset-password-email-template,#edit-ciam-sms-template-2fa,#edit-ciam-sms-template-change-phone-no,#edit-ciam-sms-template-one-time-passcode,#edit-ciam-sms-template-phone-verification,#edit-ciam-sms-template-reset-password,#edit-ciam-welcome-email-template,#edit-ciam-welcome-sms-template{margin:0 0 0 440px;clear:both;width:150px}#ciam_show_button{left:504px;padding:7px 8px;background:#29d;width:40px;color:#fff;position:absolute;text-align:center;cursor:pointer;margin-top:-40px}#loginradius-submit-login,#loginradius-submit-register,#loginradius-submit-send{color:#000}.oneclick--errormsg{color:#a51b00;background-color:#fcf4f2;box-shadow:-8px 0 0 #e62600;padding:15px 20px 15px 35px;border:1px solid;border-width:1px 1px 1px 0;margin-top:15px;border-radius:2px;overflow-wrap:break-word}.user-form .field--type-boolean,.user-form .field--type-datetime,.user-form .field--type-decimal,.user-form .field--type-email,.user-form .field--type-entity-reference,.user-form .field--type-float,.user-form .field--type-integer,.user-form .field--type-link,.user-form .field--type-list-float,.user-form .field--type-list-integer,.user-form .field--type-list-string,.user-form .field--type-string,.user-form .field--type-text,.user-form .field--type-timestamp{display:none} \ No newline at end of file diff --git a/drupal-10/src/customer_identity_and_access_management/lr_ciam/css/login_frontend.css b/drupal-10/src/customer_identity_and_access_management/lr_ciam/css/login_frontend.css new file mode 100644 index 0000000..fdfdd1e --- /dev/null +++ b/drupal-10/src/customer_identity_and_access_management/lr_ciam/css/login_frontend.css @@ -0,0 +1,454 @@ +#edit-social-linked { + background: #fff; + border: 1px solid #ccc; + border-radius: 4px; + margin-bottom: 32px; + margin-top: 10px; + padding: 20px; + position: relative; + top: 12px; +} + +.interface_error { + color: red; +} + +#loginRadiusError { + padding-bottom: 15px; +} + +.interface_block { + background-color: #e7ffe0; + border: 1px solid #bfe7b0; +} + +.LoginRadius_overlay { + background: #7f7f7f; + background: no-repeat rgba(127, 127, 127, .6); + top: 0; + left: 0; + z-index: 9999; + width: 100%; + height: 100%; + overflow: auto; + padding: 0; + position: fixed; + -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=90)"; + filter: alpha(opacity=90); +} + +#popupinner { + overflow: auto; + background: #fff; + padding: 15px 20px; +} + +.lr-popupheading { + background: #efefef; + font-size: 17px; + font-weight: 400; + line-height: 20px; + padding: 15px; + text-align: center; + border-radius: 0 20px 0 0; +} + +.inputtxt { + font-family: Arial, Helvetica, sans-serif; + color: #444; + font-size: 13px; + border: 1px solid #e2efe1; + height: 27px; + margin-bottom: 5px !important; + padding-left: 10px; + border-radius: 0 12px; + background: #fff; +} + +#textmatter { + background-color: #a8d32e; + border: 1px solid #90b203; + border-radius: 5px; + color: #fff; + font-family: Arial, Helvetica, sans-serif; + font-size: 12px; + margin: 10px 0; + padding: 10px; + text-align: justify; +} + +#textdivpopup { + font-family: Arial, Helvetica, sans-serif; + font-size: 11px; + color: #000; + text-align: right; + margin-left: 216px; +} + +.spanpopup { + color: #0cf; + font-family: Arial, Helvetica, sans-serif; + font-size: 11px; +} + +.span1 { + color: #333; + font-family: Arial, Helvetica, sans-serif; + font-size: 11px; +} + +.inputtxt { + width: 100%; +} + +.inputimg { + width: 42px; + height: 42px; +} + +.ui-tabs-nav.ui-helper-reset.ui-helper-clearfix.ui-widget-header.ui-corner-all { + font-size: 11px; +} + +.inputtxtarea { + width: 457px; + height: 81px; + overflow-y: auto; + margin: 0 0 10px; + padding: 10px; + line-height: 21px; +} + +.popupmain { + background: #fff; + width: 506px; + left: 50%; + top: 45%; + margin-left: -250px; + margin-top: -250px; + position: absolute; + z-index: 999999; + font-family: Arial, Helvetica, sans-serif; + font-size: 13px; + border-radius: 0 23px; +} + +.lr-popup-header { + background: #efefef; + height: 45px; + float: left; + text-align: left; + width: 100%; + font-family: Arial, Helvetica, sans-serif; + font-size: 18px; + font-weight: 400; + padding: 7px 0 0; + border-radius: 0 20px 0 0; +} + +.lr-error { + text-align: left; + background-color: #ffebe8; + margin-bottom: 12px; + padding: 12px; +} + +.lr-noerror { + text-align: left; + background-color: #e1eabc; + margin-bottom: 12px; + padding: 12px; +} + +.lr-popup-footer { + background: #efefef; + border-radius: 0 0 0 20px; + color: #000; + font-family: Arial, Helvetica, sans-serif; + font-size: 18px; + font-weight: 400; + height: 45px; + padding: 7px 10px 0; + text-align: left; +} + +.spantext { + float: left; + padding: 0 0 0 15px; + margin-left: 0; + line-height: 40px; +} + +.lr_footerbox { + width: 100%; + float: left; + margin-left: 0; + text-align: right; +} + +#loginRadiusMiddiv { + margin: 0 auto; + width: 94%; + clear: both; + overflow-y: auto; + overflow-x: none; + height: 394px; +} + +#loginRadiusMiddiv .lr-popupbox { + width: 99%; + float: left; + font-weight: 400; + background-color: #fff; + border-bottom: 1px solid #e7e7e7; + height: 53px; +} + +.lr-popupbox input[type=checkbox] { + float: left; + margin-top: 19px; + margin-left: 8px; + margin-right: 10px; + padding: 4px; +} + +.lr-imgbox { + width: 70px; + float: left; + margin: 0; + display: block; + padding-top: 6px; + padding-right: 20px; +} + +.lr-nameemailbox { + width: 210px; + float: left; + line-height: 52px; +} + +.lr-popupbox label { + width: 100%; + float: left; + margin: 0; + padding: 0; +} + +.middiv p { + padding-bottom: 0; + padding-top: 10px; + margin: 0; +} + +.button { + -webkit-border-radius: 0; + display: inline-block; + outline: 0; + cursor: pointer; + text-align: center; + text-decoration: none; + font: 14px/100% Arial, Helvetica, sans-serif; + padding: 5px 15px; + width: auto; + border: none; + color: #6e6e6e !important; +} + +.lr_feedbackbutton a { + display: inline-block; + outline: 0; + cursor: pointer !important; + text-align: center !important; + text-decoration: none; + font: 14px/100% Arial, Helvetica, sans-serif; + padding: 5px 15px !important; + width: auto; + background: #fff !important; + border: 1px solid #ddd !important; + border-radius: 0 10px !important; + margin-top: 0; +} + +.lr_feedbackbutton a:hover { + text-decoration: none !important; + border: 1px solid #f2f2f2 !important; + background: #ccc !important; +} + +.blue { + background: #444; + color: #fff; + border: 1px solid #ddd; + border-radius: 0 11px !important; +} + +.blue:hover { + background: #00b0f0; + border: 1px solid #00b0f0; +} + +.colorless { + border: 1px solid #ddd; + border-radius: 0 11px !important; + background: #efefef; + margin-top: 6px; +} + +.colorless:hover { + text-decoration: none; + color: #000 !important; +} + +.lr_popupmidtop { + float: left; + width: 100%; + height: 6px; +} + +.lr_contact_search { + width: 47%; + float: right; + color: #fff; + margin-left: 0; +} + +.lr_contact_searchbox { + float: right; + margin-right: 10px; + margin-top: 5px; + border: 1px solid #0574aa; + border-radius: 0; +} + +.lr_feedbackbutton { + float: left; + text-align: right; + margin-top: 13px; +} + +.facegoolabel { + width: 50%; + float: left; + margin: 3px 10px 10px 0; + display: block; +} + +.search_icon { + background-position: right center; + background-repeat: no-repeat; + border: none; + color: #a1a1a1; + float: right; + font-size: 12px; + height: 25px; + margin: 8px 12px 0 0; + outline: 0; + padding: 5px 30px 5px 5px; + border-radius: 0 8px; +} + +.lr_footerbox .selectbox { + border: 1px solid #ddd; + border-radius: 0 11px; + float: left; + height: auto; + margin-top: 6px; + padding: 4px 12px; +} + +.lr_footerbox .selectbox input[type=checkbox] { + float: left; + margin-top: 1px; +} + +.lr_footerbox .selectbox label { + float: left; + font: 14px/100% Arial, Helvetica, sans-serif; + height: auto; + padding-left: 8px; + padding-top: 2px; +} + +@media (max-width: 769px) { + .popupmain { + width: 400px; + border-radius: 0 21px; + left: 0; + top: 0; + position: static; + z-index: 999999; + margin: 10% auto 0; + } + + .lr-imgbox { + width: 53px; + } + + .lr-nameemailbox { + width: 167px; + font-size: 12px; + padding-top: 17px; + line-height: 17px; + } + + .button { + padding: 5px 3px; + } + + .lr_footerbox { + text-align: right; + width: 100%; + } + + .lr_footerbox .selectbox { + padding: 4px 9px; + } +} + +@media (max-width: 480px) { + .popupmain { + width: 300px; + border-radius: 0 21px; + left: 0; + top: 0; + position: static; + z-index: 999999; + margin: 10% auto 0; + } + + .lr-nameemailbox { + width: 119px; + padding-top: 17px; + line-height: 17px; + } + + .lr-imgbox { + width: 42px; + padding-right: 10px; + } + + .button { + padding: 5px 3px; + } + + .lr_footerbox { + text-align: right; + width: 100%; + } + + .lr_feedbackbutton { + float: left; + text-align: left; + margin-top: 10px; + width: 90px; + border-radius: 0 !important; + } + + .lr_feedbackbutton a { + margin-top: 0; + } + + .lr_footerbox .selectbox { + padding: 4px 6px; + } +} diff --git a/drupal-10/src/customer_identity_and_access_management/lr_ciam/css/login_frontend.min.css b/drupal-10/src/customer_identity_and_access_management/lr_ciam/css/login_frontend.min.css new file mode 100644 index 0000000..29fc96a --- /dev/null +++ b/drupal-10/src/customer_identity_and_access_management/lr_ciam/css/login_frontend.min.css @@ -0,0 +1 @@ +#textdivpopup,#textmatter,.inputtxt,.popupmain,.span1,.spanpopup{font-family:Arial,Helvetica,sans-serif}#edit-social-linked{background:#fff;border:1px solid #ccc;border-radius:4px;margin-bottom:32px;margin-top:10px;padding:20px;position:relative;top:12px}.interface_error{color:red}#loginRadiusError{padding-bottom:15px}.interface_block{background-color:#e7ffe0;border:1px solid #bfe7b0}.LoginRadius_overlay{background:#7f7f7f;background:no-repeat rgba(127,127,127,.6);top:0;left:0;z-index:9999;width:100%;height:100%;overflow:auto;padding:0;position:fixed;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=90)";filter:alpha(opacity=90)}#popupinner{overflow:auto;background:#fff;padding:15px 20px}.lr-popupheading{background:#efefef;font-size:17px;font-weight:400;line-height:20px;padding:15px;text-align:center;border-radius:0 20px 0 0}.inputtxt{color:#444;font-size:13px;border:1px solid #e2efe1;height:27px;margin-bottom:5px!important;padding-left:10px;border-radius:0 12px;background:#fff;width:100%}#textmatter{background-color:#a8d32e;border:1px solid #90b203;border-radius:5px;color:#fff;font-size:12px;margin:10px 0;padding:10px;text-align:justify}#textdivpopup,.span1,.spanpopup,.ui-tabs-nav.ui-helper-reset.ui-helper-clearfix.ui-widget-header.ui-corner-all{font-size:11px}#textdivpopup{color:#000;text-align:right;margin-left:216px}.spanpopup{color:#0cf}.span1{color:#333}.inputimg{width:42px;height:42px}.inputtxtarea{width:457px;height:81px;overflow-y:auto;margin:0 0 10px;padding:10px;line-height:21px}.popupmain{background:#fff;width:506px;left:50%;top:45%;margin-left:-250px;margin-top:-250px;position:absolute;z-index:999999;font-size:13px;border-radius:0 23px}.lr_footerbox,.spantext{margin-left:0;float:left}.lr-popup-footer,.lr-popup-header{font-family:Arial,Helvetica,sans-serif;font-size:18px;height:45px;font-weight:400}.lr-popup-header{background:#efefef;float:left;text-align:left;width:100%;padding:7px 0 0;border-radius:0 20px 0 0}.lr-error,.lr-noerror{margin-bottom:12px;padding:12px;text-align:left}.lr-error{background-color:#ffebe8}.lr-noerror{background-color:#e1eabc}.lr-popup-footer{background:#efefef;border-radius:0 0 0 20px;color:#000;padding:7px 10px 0;text-align:left}.spantext{padding:0 0 0 15px;line-height:40px}.lr_footerbox{width:100%;text-align:right}#loginRadiusMiddiv{margin:0 auto;width:94%;clear:both;overflow-y:auto;overflow-x:none;height:394px}#loginRadiusMiddiv .lr-popupbox{width:99%;float:left;font-weight:400;background-color:#fff;border-bottom:1px solid #e7e7e7;height:53px}.lr-popupbox input[type=checkbox]{float:left;margin-top:19px;margin-left:8px;margin-right:10px;padding:4px}.lr-imgbox{width:70px;float:left;margin:0;display:block;padding-top:6px;padding-right:20px}.lr-nameemailbox{width:210px;float:left;line-height:52px}.lr-popupbox label{width:100%;float:left;margin:0;padding:0}.button,.lr_feedbackbutton a{display:inline-block;text-decoration:none;font:14px/100% Arial,Helvetica,sans-serif;width:auto;outline:0}.middiv p{padding-bottom:0;padding-top:10px;margin:0}.button{-webkit-border-radius:0;cursor:pointer;text-align:center;padding:5px 15px;border:none;color:#6e6e6e!important}.lr_feedbackbutton a{cursor:pointer!important;text-align:center!important;padding:5px 15px!important;background:#fff!important;border:1px solid #ddd!important;border-radius:0 10px!important;margin-top:0}.lr_feedbackbutton a:hover{text-decoration:none!important;border:1px solid #f2f2f2!important;background:#ccc!important}.blue{background:#444;color:#fff;border:1px solid #ddd;border-radius:0 11px!important}.blue:hover{background:#00b0f0;border:1px solid #00b0f0}.colorless{border:1px solid #ddd;border-radius:0 11px!important;background:#efefef;margin-top:6px}.colorless:hover{text-decoration:none;color:#000!important}.lr_popupmidtop{float:left;width:100%;height:6px}.lr_contact_search{width:47%;float:right;color:#fff;margin-left:0}.lr_contact_searchbox{float:right;margin-right:10px;margin-top:5px;border:1px solid #0574aa;border-radius:0}.lr_feedbackbutton{float:left;text-align:right;margin-top:13px}.facegoolabel{width:50%;float:left;margin:3px 10px 10px 0;display:block}.search_icon{background-position:right center;background-repeat:no-repeat;border:none;color:#a1a1a1;float:right;font-size:12px;height:25px;margin:8px 12px 0 0;outline:0;padding:5px 30px 5px 5px;border-radius:0 8px}.lr_footerbox .selectbox{border:1px solid #ddd;border-radius:0 11px;float:left;height:auto;margin-top:6px;padding:4px 12px}.lr_footerbox .selectbox input[type=checkbox]{float:left;margin-top:1px}.lr_footerbox .selectbox label{float:left;font:14px/100% Arial,Helvetica,sans-serif;height:auto;padding-left:8px;padding-top:2px}@media (max-width:769px){.popupmain{width:400px;border-radius:0 21px;left:0;top:0;position:static;z-index:999999;margin:10% auto 0}.lr-imgbox{width:53px}.lr-nameemailbox{width:167px;font-size:12px;padding-top:17px;line-height:17px}.button{padding:5px 3px}.lr_footerbox{text-align:right;width:100%}.lr_footerbox .selectbox{padding:4px 9px}}@media (max-width:480px){.popupmain{width:300px;border-radius:0 21px;left:0;top:0;position:static;z-index:999999;margin:10% auto 0}.lr-nameemailbox{width:119px;padding-top:17px;line-height:17px}.lr-imgbox{width:42px;padding-right:10px}.button{padding:5px 3px}.lr_footerbox{text-align:right;width:100%}.lr_feedbackbutton{float:left;text-align:left;margin-top:10px;width:90px;border-radius:0!important}.lr_feedbackbutton a{margin-top:0}.lr_footerbox .selectbox{padding:4px 6px}} \ No newline at end of file diff --git a/drupal-10/src/customer_identity_and_access_management/lr_ciam/css/lr_loading.css b/drupal-10/src/customer_identity_and_access_management/lr_ciam/css/lr_loading.css new file mode 100644 index 0000000..9e95047 --- /dev/null +++ b/drupal-10/src/customer_identity_and_access_management/lr_ciam/css/lr_loading.css @@ -0,0 +1,98 @@ +.overlay { + text-align: center; + position: fixed; + top: 0; + bottom: 60%; + left: 0; + right: 0; + height: 100%; + position: fixed; + width: 100%; + top: 0; + z-index: 99999; + background: rgb(127, 127, 127); + /* The Fallback */ + background: none no-repeat scroll 0 0 rgba(127, 127, 127, 0.6); +} + +.overlay:before { + content: ''; + display: inline-block; + height: 100%; + vertical-align: middle; + margin-right: -0.25em; + /* Adjusts for spacing */ +} + +.lr_loading_screen { + background: rgba(0, 0, 0, .5); + height: 100vh; + position: relative; + z-index: 10000; +} + +.lr_loading_screen_center { + position: absolute; + left: 50%; + top: 50%; + width: 500px; + margin-left: -250px; + margin-top: -26px; +} + +.lr_loading_screen_spinner { + height: 52px; + width: 52px; + margin: 0 auto; + display: block; + background-image: url(../images/loading.png); + animation: lr_loading_screen_animation_spinning .8s linear infinite; + background-size: 52px 52px; + background-repeat: no-repeat; +} + +.lr_loading_phrase, +.lr_loading_screen_spinner { + backface-visibility: hidden; + perspective: 1000; +} + +@-moz-keyframes lr_loading_screen_animation_spinning { + 0% { + transform: rotate(0); + } + + 100% { + transform: rotate(360deg); + } +} + +@-webkit-keyframes lr_loading_screen_animation_spinning { + 0% { + transform: rotate(0); + } + + 100% { + transform: rotate(360deg); + } +} + +@-o-keyframes lr_loading_screen_animation_spinning { + 0% { + transform: rotate(0); + } + + 100% { + transform: rotate(360deg); + } +} + +@keyframes lr_loading_screen_animation_spinning { + 0% { + transform: rotate(0); + } + + 100% { + transform: rotate(360deg); + } +} diff --git a/drupal-10/src/customer_identity_and_access_management/lr_ciam/css/lr_loading.min.css b/drupal-10/src/customer_identity_and_access_management/lr_ciam/css/lr_loading.min.css new file mode 100644 index 0000000..058d132 --- /dev/null +++ b/drupal-10/src/customer_identity_and_access_management/lr_ciam/css/lr_loading.min.css @@ -0,0 +1 @@ +.overlay{text-align:center;bottom:60%;left:0;right:0;height:100%;position:fixed;width:100%;top:0;z-index:99999;background:#7f7f7f;background:no-repeat rgba(127,127,127,.6)}.overlay:before{content:'';display:inline-block;height:100%;vertical-align:middle;margin-right:-.25em}.lr_loading_screen{background:rgba(0,0,0,.5);height:100vh;position:relative;z-index:10000}.lr_loading_screen_center{position:absolute;left:50%;top:50%;width:500px;margin-left:-250px;margin-top:-26px}.lr_loading_screen_spinner{height:52px;width:52px;margin:0 auto;display:block;background-image:url(../images/loading.png);animation:lr_loading_screen_animation_spinning .8s linear infinite;background-size:52px 52px;background-repeat:no-repeat}.lr_loading_phrase,.lr_loading_screen_spinner{backface-visibility:hidden;perspective:1000}@-moz-keyframes lr_loading_screen_animation_spinning{0%{transform:rotate(0)}100%{transform:rotate(360deg)}}@-webkit-keyframes lr_loading_screen_animation_spinning{0%{transform:rotate(0)}100%{transform:rotate(360deg)}}@-o-keyframes lr_loading_screen_animation_spinning{0%{transform:rotate(0)}100%{transform:rotate(360deg)}}@keyframes lr_loading_screen_animation_spinning{0%{transform:rotate(0)}100%{transform:rotate(360deg)}} \ No newline at end of file diff --git a/drupal-10/src/customer_identity_and_access_management/lr_ciam/customhttpclient.php b/drupal-10/src/customer_identity_and_access_management/lr_ciam/customhttpclient.php new file mode 100644 index 0000000..c903e90 --- /dev/null +++ b/drupal-10/src/customer_identity_and_access_management/lr_ciam/customhttpclient.php @@ -0,0 +1,256 @@ +curlApiMethod($requestUrl, $options); + } elseif (ini_get('allow_url_fopen')) { + $response = $this->fsockopenApiMethod($requestUrl, $options); + } else { + throw new LoginRadiusException('cURL or FSOCKOPEN is not enabled, enable cURL or FSOCKOPEN to get response from LoginRadius API.'); + } + + $requestedData = [ + 'GET' => $queryArray, + 'POST' => (isset($options['post_data']) ? $options['post_data'] : []), + ]; + + $config = \Drupal::config('lr_ciam.settings'); + $error_level = ''; + $error_level = \Drupal::config('system.logging')->get('error_level'); + if (isset($error_level) && ($error_level == 'all' || $error_level == 'verbose')) { + $response_type = 'error'; + if (!empty($response)) { + $res = $response['response'] != "" ? json_decode($response['response']) : ""; + if (!isset($res->errorCode)) { + $response_type = 'success'; + } + } + + if (array_key_exists("apisecret",$requestedData['GET'])){ + unset($requestedData['GET']['apisecret']); + } + $logData['endpoint'] = $endpoint; + $logData['method'] = $method; + $logData['data'] = !empty($requestedData) ? json_encode($requestedData) : ''; + $logData['response'] = json_encode($response); + $logData['response_type'] = ucfirst($response_type); + $logData['created_date'] = \Drupal::time()->getRequestTime(); + + if ($response_type != 'success') { + \Drupal::logger('ciam')->error(serialize($logData)); + } + else { + \Drupal::logger('ciam')->info(serialize($logData)); + } + } + + if (!empty($response)) { + $result = $response['response'] != "" ? json_decode($response['response']) : ""; + if ((isset($result->ErrorCode) && !empty($result->ErrorCode)) || (isset($result->errorCode) && !empty($result->errorCode)) || (isset($response['statuscode']) && $response['statuscode'] != 200)) { + + if(isset($result->description)){ + return $response['response']; + } elseif (isset($result->Description)) { + throw new LoginRadiusException($result->Description, $result); + } else { + throw new LoginRadiusException("The request responded with ". $response['statuscode'] . " status code", $response['response']); + } + } + } + return $response['response']; + } + + /** + * Access LoginRadius API server by curl method. + * + * @param string $requestUrl + * @param array $options + * + * @return json data + */ + private function curlApiMethod($requestUrl, $options = array()) + { + $sslVerify = isset($options['ssl_verify']) ? $options['ssl_verify'] : false; + $method = isset($options['method']) ? strtoupper($options['method']) : 'GET'; + $data = isset($options['post_data']) ? $options['post_data'] : array(); + $contentType = isset($options['content_type']) ? trim($options['content_type']) : 'x-www-form-urlencoded'; + $authAccessToken = isset($options['access-token']) ? trim($options['access-token']) : ''; + $sottHeaderContent = isset($options['X-LoginRadius-Sott']) ? trim($options['X-LoginRadius-Sott']) : ''; + $secretHeaderContent = isset($options['X-LoginRadius-ApiSecret']) ? trim($options['X-LoginRadius-ApiSecret']) : ''; + $expiryTime = isset($options['X-Request-Expires']) ? trim($options['X-Request-Expires']) : ''; + $digest = isset($options['digest']) ? trim($options['digest']) : ''; + + $curlHandle = curl_init(); + curl_setopt($curlHandle, CURLOPT_URL, $requestUrl); + curl_setopt($curlHandle, CURLOPT_CONNECTTIMEOUT, 15); + curl_setopt($curlHandle, CURLOPT_TIMEOUT, 50); + curl_setopt($curlHandle, CURLOPT_ENCODING, "gzip"); + curl_setopt($curlHandle, CURLOPT_SSL_VERIFYPEER, $sslVerify); + $optionsArray = array('Content-type: application/' . $contentType); + if ($authAccessToken != '') { + $optionsArray[] = 'Authorization:' . $authAccessToken; + } + if ($sottHeaderContent != '') { + $optionsArray[] = 'X-LoginRadius-Sott:' . $sottHeaderContent; + } + if ($secretHeaderContent != '') { + $optionsArray[] = 'X-LoginRadius-ApiSecret:' . $secretHeaderContent; + } + if ($expiryTime != '') { + $optionsArray[] = 'X-Request-Expires:' . $expiryTime; + } + if ($digest != '') { + $optionsArray[] = 'digest:' . $digest; + } + curl_setopt($curlHandle, CURLOPT_HTTPHEADER, $optionsArray); + if(defined('PROTOCOL') && PROTOCOL != "" && defined('HOST') && HOST != "" && defined('PORT') && PORT != "" && defined('USER') && USER != "" && defined('PASSWORD') && PASSWORD != "") { + curl_setopt($curlHandle, CURLOPT_PROXY, PROTOCOL . '://' . USER . ':' . PASSWORD . '@' . HOST . ':' . PORT); + } + + if (!empty($data)) { + if (($contentType == 'json') && (is_array($data) || is_object($data))) { + $data = json_encode($data); + } + } + if (in_array($method, array('POST', 'PUT', 'DELETE'))) { + curl_setopt($curlHandle, CURLOPT_POSTFIELDS, (($contentType == 'json') ? $data : Functions::queryBuild($data))); + curl_setopt($curlHandle, CURLOPT_CUSTOMREQUEST, $method); + } + curl_setopt($curlHandle, CURLOPT_FOLLOWLOCATION, 1); + curl_setopt($curlHandle, CURLOPT_RETURNTRANSFER, true); + $output = array(); + $output['response'] = curl_exec($curlHandle); + $output['statuscode'] = curl_getinfo($curlHandle, CURLINFO_HTTP_CODE); + + if (curl_error($curlHandle)) { + $output['response'] = curl_error($curlHandle); + } + curl_close($curlHandle); + + return $output; + } + + /** + * Access LoginRadius API server by fsockopen method. + * + * @param string $requestUrl + * @param array $options + * + * @return json data + */ + private function fsockopenApiMethod($requestUrl, $options = array()){ + $sslVerify = isset($options['ssl_verify']) ? $options['ssl_verify'] : false; + $method = isset($options['method']) ? strtoupper($options['method']) : 'GET'; + $data = isset($options['post_data']) ? $options['post_data'] : array(); + $contentType = isset($options['content_type']) ? $options['content_type'] : 'form_params'; + $authAccessToken = isset($options['access-token']) ? trim($options['access-token']) : ''; + $sottHeaderContent = isset($options['X-LoginRadius-Sott']) ? trim($options['X-LoginRadius-Sott']) : ''; + $secretHeaderContent = isset($options['X-LoginRadius-ApiSecret']) ? trim($options['X-LoginRadius-ApiSecret']) : ''; + $expiryTime = isset($options['X-Request-Expires']) ? trim($options['X-Request-Expires']) : ''; + $digest = isset($options['digest']) ? trim($options['digest']) : ''; + + $optionsArray = array('http' => + array( + 'method' => strtoupper($method), + 'timeout' => 50, + 'ignore_errors' => true, + 'header' => 'Content-Type: application/' . $contentType + ), + "ssl" => array( + "verify_peer" => $sslVerify + ) + ); + if (!empty($data) || $data === true) { + if (($contentType == 'json') && (is_array($data) || is_object($data))) { + $data = json_encode($data); + } + $optionsArray['http']['header'] .= "\r\n" . 'Content-Length:' . (($data === true) ? '0' : strlen($data)); + $optionsArray['http']['header'] .= "\r\n" . 'Accept-Encoding: gzip'; + $optionsArray['http']['content'] = (($contentType == 'json') ? $data : Functions::queryBuild($data)); + } + if ($authAccessToken != '') { + $optionsArray['http']['header'] .= "\r\n" . 'Authorization: ' . $authAccessToken; + } + if ($sottHeaderContent != '') { + $optionsArray['http']['header'] .= "\r\n" . 'X-LoginRadius-Sott: ' . $sottHeaderContent; + } + if ($secretHeaderContent != '') { + $optionsArray['http']['header'] .= "\r\n" . 'X-LoginRadius-ApiSecret: ' . $secretHeaderContent; + } + if ($expiryTime != '') { + $optionsArray['http']['header'] .= "\r\n" . 'X-Request-Expires: ' . $expiryTime; + } + if ($digest != '') { + $optionsArray['http']['header'] .= "\r\n" . 'digest: ' . $digest; + } + + $context = stream_context_create($optionsArray); + $jsonResponse['response'] = file_get_contents($requestUrl, false, $context); + $jsonResponse['statuscode'] = $http_response_header[0]; + if (!$jsonResponse) { + throw new LoginRadiusException('file_get_contents error'); + } + return $jsonResponse; + } + +} diff --git a/drupal-10/src/customer_identity_and_access_management/lr_ciam/images/Virgilio.png b/drupal-10/src/customer_identity_and_access_management/lr_ciam/images/Virgilio.png new file mode 100644 index 0000000..84c569b Binary files /dev/null and b/drupal-10/src/customer_identity_and_access_management/lr_ciam/images/Virgilio.png differ diff --git a/drupal-10/src/customer_identity_and_access_management/lr_ciam/images/amazon.png b/drupal-10/src/customer_identity_and_access_management/lr_ciam/images/amazon.png new file mode 100644 index 0000000..7f8717d Binary files /dev/null and b/drupal-10/src/customer_identity_and_access_management/lr_ciam/images/amazon.png differ diff --git a/drupal-10/src/customer_identity_and_access_management/lr_ciam/images/aol.png b/drupal-10/src/customer_identity_and_access_management/lr_ciam/images/aol.png new file mode 100644 index 0000000..1146402 Binary files /dev/null and b/drupal-10/src/customer_identity_and_access_management/lr_ciam/images/aol.png differ diff --git a/drupal-10/src/customer_identity_and_access_management/lr_ciam/images/cg.gif b/drupal-10/src/customer_identity_and_access_management/lr_ciam/images/cg.gif new file mode 100644 index 0000000..d0bce15 Binary files /dev/null and b/drupal-10/src/customer_identity_and_access_management/lr_ciam/images/cg.gif differ diff --git a/drupal-10/src/customer_identity_and_access_management/lr_ciam/images/classmates.png b/drupal-10/src/customer_identity_and_access_management/lr_ciam/images/classmates.png new file mode 100644 index 0000000..f4cebbd Binary files /dev/null and b/drupal-10/src/customer_identity_and_access_management/lr_ciam/images/classmates.png differ diff --git a/drupal-10/src/customer_identity_and_access_management/lr_ciam/images/copy.png b/drupal-10/src/customer_identity_and_access_management/lr_ciam/images/copy.png new file mode 100644 index 0000000..995dc7c Binary files /dev/null and b/drupal-10/src/customer_identity_and_access_management/lr_ciam/images/copy.png differ diff --git a/drupal-10/src/customer_identity_and_access_management/lr_ciam/images/disqus.png b/drupal-10/src/customer_identity_and_access_management/lr_ciam/images/disqus.png new file mode 100644 index 0000000..ba080eb Binary files /dev/null and b/drupal-10/src/customer_identity_and_access_management/lr_ciam/images/disqus.png differ diff --git a/drupal-10/src/customer_identity_and_access_management/lr_ciam/images/facebook.png b/drupal-10/src/customer_identity_and_access_management/lr_ciam/images/facebook.png new file mode 100644 index 0000000..78102aa Binary files /dev/null and b/drupal-10/src/customer_identity_and_access_management/lr_ciam/images/facebook.png differ diff --git a/drupal-10/src/customer_identity_and_access_management/lr_ciam/images/foursquare.png b/drupal-10/src/customer_identity_and_access_management/lr_ciam/images/foursquare.png new file mode 100644 index 0000000..c9d9bb0 Binary files /dev/null and b/drupal-10/src/customer_identity_and_access_management/lr_ciam/images/foursquare.png differ diff --git a/drupal-10/src/customer_identity_and_access_management/lr_ciam/images/github.png b/drupal-10/src/customer_identity_and_access_management/lr_ciam/images/github.png new file mode 100644 index 0000000..88bcb70 Binary files /dev/null and b/drupal-10/src/customer_identity_and_access_management/lr_ciam/images/github.png differ diff --git a/drupal-10/src/customer_identity_and_access_management/lr_ciam/images/google.png b/drupal-10/src/customer_identity_and_access_management/lr_ciam/images/google.png new file mode 100644 index 0000000..aa0d31a Binary files /dev/null and b/drupal-10/src/customer_identity_and_access_management/lr_ciam/images/google.png differ diff --git a/drupal-10/src/customer_identity_and_access_management/lr_ciam/images/hyves.png b/drupal-10/src/customer_identity_and_access_management/lr_ciam/images/hyves.png new file mode 100644 index 0000000..4a01efd Binary files /dev/null and b/drupal-10/src/customer_identity_and_access_management/lr_ciam/images/hyves.png differ diff --git a/drupal-10/src/customer_identity_and_access_management/lr_ciam/images/instagram.png b/drupal-10/src/customer_identity_and_access_management/lr_ciam/images/instagram.png new file mode 100644 index 0000000..9aed7e7 Binary files /dev/null and b/drupal-10/src/customer_identity_and_access_management/lr_ciam/images/instagram.png differ diff --git a/drupal-10/src/customer_identity_and_access_management/lr_ciam/images/kaixin.png b/drupal-10/src/customer_identity_and_access_management/lr_ciam/images/kaixin.png new file mode 100644 index 0000000..fcfc320 Binary files /dev/null and b/drupal-10/src/customer_identity_and_access_management/lr_ciam/images/kaixin.png differ diff --git a/drupal-10/src/customer_identity_and_access_management/lr_ciam/images/line.png b/drupal-10/src/customer_identity_and_access_management/lr_ciam/images/line.png new file mode 100644 index 0000000..c4cf7be Binary files /dev/null and b/drupal-10/src/customer_identity_and_access_management/lr_ciam/images/line.png differ diff --git a/drupal-10/src/customer_identity_and_access_management/lr_ciam/images/linkedin.png b/drupal-10/src/customer_identity_and_access_management/lr_ciam/images/linkedin.png new file mode 100644 index 0000000..e8b0806 Binary files /dev/null and b/drupal-10/src/customer_identity_and_access_management/lr_ciam/images/linkedin.png differ diff --git a/drupal-10/src/customer_identity_and_access_management/lr_ciam/images/live.png b/drupal-10/src/customer_identity_and_access_management/lr_ciam/images/live.png new file mode 100644 index 0000000..1c532f2 Binary files /dev/null and b/drupal-10/src/customer_identity_and_access_management/lr_ciam/images/live.png differ diff --git a/drupal-10/src/customer_identity_and_access_management/lr_ciam/images/livejournal.png b/drupal-10/src/customer_identity_and_access_management/lr_ciam/images/livejournal.png new file mode 100644 index 0000000..e37a9d5 Binary files /dev/null and b/drupal-10/src/customer_identity_and_access_management/lr_ciam/images/livejournal.png differ diff --git a/drupal-10/src/customer_identity_and_access_management/lr_ciam/images/loading.png b/drupal-10/src/customer_identity_and_access_management/lr_ciam/images/loading.png new file mode 100644 index 0000000..84333e4 Binary files /dev/null and b/drupal-10/src/customer_identity_and_access_management/lr_ciam/images/loading.png differ diff --git a/drupal-10/src/customer_identity_and_access_management/lr_ciam/images/lr_provider_sprite.png b/drupal-10/src/customer_identity_and_access_management/lr_ciam/images/lr_provider_sprite.png new file mode 100644 index 0000000..af7a08b Binary files /dev/null and b/drupal-10/src/customer_identity_and_access_management/lr_ciam/images/lr_provider_sprite.png differ diff --git a/drupal-10/src/customer_identity_and_access_management/lr_ciam/images/mixi.png b/drupal-10/src/customer_identity_and_access_management/lr_ciam/images/mixi.png new file mode 100644 index 0000000..86e293c Binary files /dev/null and b/drupal-10/src/customer_identity_and_access_management/lr_ciam/images/mixi.png differ diff --git a/drupal-10/src/customer_identity_and_access_management/lr_ciam/images/myopenid.png b/drupal-10/src/customer_identity_and_access_management/lr_ciam/images/myopenid.png new file mode 100644 index 0000000..70878bc Binary files /dev/null and b/drupal-10/src/customer_identity_and_access_management/lr_ciam/images/myopenid.png differ diff --git a/drupal-10/src/customer_identity_and_access_management/lr_ciam/images/myspace.png b/drupal-10/src/customer_identity_and_access_management/lr_ciam/images/myspace.png new file mode 100644 index 0000000..acf9719 Binary files /dev/null and b/drupal-10/src/customer_identity_and_access_management/lr_ciam/images/myspace.png differ diff --git a/drupal-10/src/customer_identity_and_access_management/lr_ciam/images/odnoklassniki.png b/drupal-10/src/customer_identity_and_access_management/lr_ciam/images/odnoklassniki.png new file mode 100644 index 0000000..2a7f3d9 Binary files /dev/null and b/drupal-10/src/customer_identity_and_access_management/lr_ciam/images/odnoklassniki.png differ diff --git a/drupal-10/src/customer_identity_and_access_management/lr_ciam/images/openid.png b/drupal-10/src/customer_identity_and_access_management/lr_ciam/images/openid.png new file mode 100644 index 0000000..ece969a Binary files /dev/null and b/drupal-10/src/customer_identity_and_access_management/lr_ciam/images/openid.png differ diff --git a/drupal-10/src/customer_identity_and_access_management/lr_ciam/images/orange.png b/drupal-10/src/customer_identity_and_access_management/lr_ciam/images/orange.png new file mode 100644 index 0000000..bb3622a Binary files /dev/null and b/drupal-10/src/customer_identity_and_access_management/lr_ciam/images/orange.png differ diff --git a/drupal-10/src/customer_identity_and_access_management/lr_ciam/images/paypal.png b/drupal-10/src/customer_identity_and_access_management/lr_ciam/images/paypal.png new file mode 100644 index 0000000..5a66e15 Binary files /dev/null and b/drupal-10/src/customer_identity_and_access_management/lr_ciam/images/paypal.png differ diff --git a/drupal-10/src/customer_identity_and_access_management/lr_ciam/images/persona.png b/drupal-10/src/customer_identity_and_access_management/lr_ciam/images/persona.png new file mode 100644 index 0000000..6af96d5 Binary files /dev/null and b/drupal-10/src/customer_identity_and_access_management/lr_ciam/images/persona.png differ diff --git a/drupal-10/src/customer_identity_and_access_management/lr_ciam/images/qq.png b/drupal-10/src/customer_identity_and_access_management/lr_ciam/images/qq.png new file mode 100644 index 0000000..4103fc8 Binary files /dev/null and b/drupal-10/src/customer_identity_and_access_management/lr_ciam/images/qq.png differ diff --git a/drupal-10/src/customer_identity_and_access_management/lr_ciam/images/renren.png b/drupal-10/src/customer_identity_and_access_management/lr_ciam/images/renren.png new file mode 100644 index 0000000..108f6c1 Binary files /dev/null and b/drupal-10/src/customer_identity_and_access_management/lr_ciam/images/renren.png differ diff --git a/drupal-10/src/customer_identity_and_access_management/lr_ciam/images/salesforce.png b/drupal-10/src/customer_identity_and_access_management/lr_ciam/images/salesforce.png new file mode 100644 index 0000000..d33c10f Binary files /dev/null and b/drupal-10/src/customer_identity_and_access_management/lr_ciam/images/salesforce.png differ diff --git a/drupal-10/src/customer_identity_and_access_management/lr_ciam/images/searchBG.jpg b/drupal-10/src/customer_identity_and_access_management/lr_ciam/images/searchBG.jpg new file mode 100644 index 0000000..e513a3a Binary files /dev/null and b/drupal-10/src/customer_identity_and_access_management/lr_ciam/images/searchBG.jpg differ diff --git a/drupal-10/src/customer_identity_and_access_management/lr_ciam/images/sinaweibo.png b/drupal-10/src/customer_identity_and_access_management/lr_ciam/images/sinaweibo.png new file mode 100644 index 0000000..7354e26 Binary files /dev/null and b/drupal-10/src/customer_identity_and_access_management/lr_ciam/images/sinaweibo.png differ diff --git a/drupal-10/src/customer_identity_and_access_management/lr_ciam/images/stackexchange.png b/drupal-10/src/customer_identity_and_access_management/lr_ciam/images/stackexchange.png new file mode 100644 index 0000000..df2a059 Binary files /dev/null and b/drupal-10/src/customer_identity_and_access_management/lr_ciam/images/stackexchange.png differ diff --git a/drupal-10/src/customer_identity_and_access_management/lr_ciam/images/steamcommunity.png b/drupal-10/src/customer_identity_and_access_management/lr_ciam/images/steamcommunity.png new file mode 100644 index 0000000..371094b Binary files /dev/null and b/drupal-10/src/customer_identity_and_access_management/lr_ciam/images/steamcommunity.png differ diff --git a/drupal-10/src/customer_identity_and_access_management/lr_ciam/images/twitter.png b/drupal-10/src/customer_identity_and_access_management/lr_ciam/images/twitter.png new file mode 100644 index 0000000..6960e98 Binary files /dev/null and b/drupal-10/src/customer_identity_and_access_management/lr_ciam/images/twitter.png differ diff --git a/drupal-10/src/customer_identity_and_access_management/lr_ciam/images/verisign.png b/drupal-10/src/customer_identity_and_access_management/lr_ciam/images/verisign.png new file mode 100644 index 0000000..5c55529 Binary files /dev/null and b/drupal-10/src/customer_identity_and_access_management/lr_ciam/images/verisign.png differ diff --git a/drupal-10/src/customer_identity_and_access_management/lr_ciam/images/vkontakte.png b/drupal-10/src/customer_identity_and_access_management/lr_ciam/images/vkontakte.png new file mode 100644 index 0000000..cf7caa5 Binary files /dev/null and b/drupal-10/src/customer_identity_and_access_management/lr_ciam/images/vkontakte.png differ diff --git a/drupal-10/src/customer_identity_and_access_management/lr_ciam/images/wordpress.png b/drupal-10/src/customer_identity_and_access_management/lr_ciam/images/wordpress.png new file mode 100644 index 0000000..e027b1c Binary files /dev/null and b/drupal-10/src/customer_identity_and_access_management/lr_ciam/images/wordpress.png differ diff --git a/drupal-10/src/customer_identity_and_access_management/lr_ciam/images/yahoo.png b/drupal-10/src/customer_identity_and_access_management/lr_ciam/images/yahoo.png new file mode 100644 index 0000000..a4581ac Binary files /dev/null and b/drupal-10/src/customer_identity_and_access_management/lr_ciam/images/yahoo.png differ diff --git a/drupal-10/src/customer_identity_and_access_management/lr_ciam/js/LoginRadiusFrontEnd.js b/drupal-10/src/customer_identity_and_access_management/lr_ciam/js/LoginRadiusFrontEnd.js new file mode 100644 index 0000000..98752b8 --- /dev/null +++ b/drupal-10/src/customer_identity_and_access_management/lr_ciam/js/LoginRadiusFrontEnd.js @@ -0,0 +1,801 @@ +jQuery(document).ready(function () { + + jQuery("#lr-loading").click(function () { + jQuery('#lr-loading').hide(); + }); + + window.addEventListener( "pageshow", function ( event ) { + var historyTraversal = event.persisted || + ( typeof window.performance != "undefined" && + window.performance.navigation.type === 2 ); + if ( historyTraversal ) { + // Handle page restore. + window.location.reload(); + } + }); + + showOrHideCustomRedirection(jQuery('input:radio[name="login_redirection"]:checked').val()); + jQuery('input:radio[name="login_redirection"]').change(function () { + showOrHideCustomRedirection(jQuery(this).val()); + }); + + showOrHidePasswordlessTemplate(jQuery('input:radio[name="ciam_instant_link_login"]:checked').val()); + jQuery('input:radio[name="ciam_instant_link_login"]').change(function () { + showOrHidePasswordlessTemplate(jQuery(this).val()); + }); + + showOrHidePasswordlessOTPTemplate(jQuery('input:radio[name="ciam_instant_otp_login"]:checked').val()); + jQuery('input:radio[name="ciam_instant_otp_login"]').change(function () { + showOrHidePasswordlessOTPTemplate(jQuery(this).val()); + }); + + if (window.location.href == window.location.origin + domainName + 'admin/people/create') { + jQuery('.form-item-mail label').attr('class', 'js-form-required form-required'); + jQuery('#edit-mail').attr('required', 'required'); + } else { + jQuery('#edit-mail').attr('disabled', 'disabled'); + jQuery('#edit-mail').attr('style', 'background:#ededed'); + } + + dropemailvalue = ''; + jQuery('.removeEmail').each(function () { + jQuery(this).click(function () { + jQuery('form[name="loginradius-removeemail"]').remove(); + var html = jQuery(this).parents('tr'); + dropemailvalue = jQuery(this).parents('tr').find('.form-email').val(); + showRemoveEmailPopup(html); + }); + }); + + jQuery('#addEmail').attr('onClick', 'showAddEmailPopup()'); +}); + +function showOrHidePasswordlessTemplate(option) { + if ('false' === option || '' === option) { + jQuery('.form-item-ciam-instant-link-login-email-template').hide(); + } else { + jQuery('.form-item-ciam-instant-link-login-email-template').show(); + } +} + +function showOrHidePasswordlessOTPTemplate(option) { + if ('false' === option || '' === option) { + jQuery('.form-item-ciam-sms-template-one-time-passcode').hide(); + } else { + jQuery('.form-item-ciam-sms-template-one-time-passcode').show(); + } +} + +function showOrHideCustomRedirection(option) { + if ('0' === option || '1' === option || '' === option) { + jQuery('.form-item-custom-login-url').hide(); + } else { + jQuery('.form-item-custom-login-url').show(); + } +} + +if (typeof LoginRadiusV2 === 'undefined') { + var e = document.createElement('script'); + e.src = 'https://auth.lrcontent2.com/v2/js/LoginRadiusV2.js'; + e.type = 'text/javascript'; + document.getElementsByTagName("head")[0].appendChild(e); +} + +var lrloadInterval = setInterval(function () { + if (typeof LoginRadiusV2 != 'undefined') { + clearInterval(lrloadInterval); + LRObject = new LoginRadiusV2(commonOptions); + } +}, 1); + +function showRemoveEmailPopup(html) { + jQuery('#removeemail-form').show(); + initializeRemoveEmailCiamForms(html); +} + +function showAddEmailPopup() { + jQuery('#addemail-form').show(); + initializeAddEmailCiamForms(); +} + +function lrCloseRemovePopup() { + jQuery('form[name="loginradius-removeemail"]').remove(); + jQuery('#removeemail-form').hide(); +} + +function lrCloseAddEmailPopup() { + jQuery('#addemail-form').hide(); +} + +function show_birthdate_date_block() { + var maxYear = new Date().getFullYear(); + var minYear = maxYear - 100; + if (jQuery('body').on) { + jQuery('body').on('focus', '.loginradius-birthdate', function () { + jQuery('.loginradius-birthdate').datepicker({ + dateFormat: 'mm-dd-yy', + maxDate: new Date(), + minDate: "-100y", + changeMonth: true, + changeYear: true, + yearRange: (minYear + ":" + maxYear) + }); + }); + } else { + jQuery(".loginradius-birthdate").live("focus", function () { + jQuery('.loginradius-birthdate').datepicker({ + dateFormat: 'mm-dd-yy', + maxDate: new Date(), + minDate: "-100y", + changeMonth: true, + changeYear: true, + yearRange: (minYear + ":" + maxYear) + }); + }); + } +} + +function handleResponse(isSuccess, message, show, status) { + status = status ? 'messages--' + status : "messages--status"; + if (isSuccess) { + jQuery('form').each(function () { + this.reset(); + }); + } + if (message != null && message != "") { + jQuery('#lr-loading').hide(); + jQuery('.messages').text(message); + jQuery(".messages__wrapper").show(); + jQuery(".messages").show(); + + jQuery(".messages").removeClass("messages--error messages--status showmsg"); + jQuery(".messages").addClass(status); + jQuery(".messages").addClass(show); + if (autoHideTime != "" && autoHideTime != "0") { + setTimeout(fade_out, autoHideTime * 1000); + } + } else { + jQuery(".messages__wrapper").hide(); + jQuery('.messages').hide(); + jQuery('.messages').text(""); + } +} + +function showErrorMsgForOneClickSignIn(isSuccess, message) { + if (isSuccess) { + jQuery('form').each(function () { + this.reset(); + }); + } + if (message != null && message != "") { + jQuery('#lr-loading').hide(); + jQuery('div[data-drupal-messages-fallback]').text(message); + jQuery("div[data-drupal-messages-fallback]").show(); + jQuery("div[data-drupal-messages-fallback]").removeClass("oneclick--errormsg"); + jQuery("div[data-drupal-messages-fallback]").addClass("oneclick--errormsg"); + if (autoHideTime != "" && autoHideTime != "0") { + setTimeout(fade_out, autoHideTime * 1000); + } + } else { + jQuery(".div[data-drupal-messages-fallback]").hide(); + jQuery('.div[data-drupal-messages-fallback]').text(""); + } +} + +function fade_out() { + jQuery(".messages").hide(); +} + +var setButtonInterval = setInterval(function () { + if (typeof LRObject !== 'undefined') + { + clearInterval(setButtonInterval); + LRObject.$hooks.register('startProcess', function () { + jQuery('#lr-loading').show(); + }); + + LRObject.$hooks.register('endProcess', function () { + if (LRObject.options.twoFactorAuthentication === true || LRObject.options.optionalTwoFactorAuthentication === true) + { + jQuery('#authentication-container').show(); + } + jQuery('#edit-account-phone').hide(); + if (LRObject.options.phoneLogin === true) + { + jQuery('#updatephone-container').show(); + jQuery('#edit-account-phone').show(); + } + jQuery('#lr-loading').hide(); + }); + + LRObject.$hooks.call('setButtonsName', { + removeemail: "Remove" + }); + + LRObject.registrationFormSchema = registrationSchema; + + LRObject.$hooks.register('socialLoginFormRender', function () { + //on social login form render + jQuery('#lr-loading').hide(); + jQuery('#social-registration-form').show(); + show_birthdate_date_block(); + }); + + LRObject.$hooks.register('afterFormRender', function (name) { + if (name == "socialRegistration") { + jQuery('#login-container').find('form[name=loginradius-socialRegistration]').parent().addClass('socialRegistration'); + } + if (name == "updatePhone") { + if(phoneId == "") { + jQuery('#updatephone-container').find('#loginradius-submit-update').attr('value', 'Add'); + } + } + if (name == "removeemail") { + jQuery('#loginradius-removeemail-emailid').val(dropemailvalue); + } + }); + } +}, 1); + +function getBackupCodes() { + var lrGetBackupInterval = setInterval(function () { + if (typeof LRObject !== 'undefined') + { + clearInterval(lrGetBackupInterval); + LRObject.api.getBackupCode(accessToken, + function (response) { + jQuery('#backupcode-table-body').empty(); + for (var i = 0; i < response.BackUpCodes.length; i++) { + var html = ''; + jQuery('#resettable').hide(); + jQuery('#lr_ciam_reset_table').show(); + + html += '
'; + html += '' + response.BackUpCodes[i] + ''; + html += '
'; + + jQuery('#backupcode-table-body').append(html); + } + jQuery('.mybackupcopy').click(function () { + setClipboard(jQuery(this).parent('.form-item').find('span').text()); + }); + }, function (errors) { + jQuery('#resettable').show(); + }); + } + }, 1); +} + +function resetBackupCodes() { + var lrResetBackupInterval = setInterval(function () { + if (typeof LRObject !== 'undefined') + { + clearInterval(lrResetBackupInterval); + LRObject.api.resetBackupCode(accessToken, + function (response) { + jQuery('#backupcode-table-body').empty(); + for (var i = 0; i < response.BackUpCodes.length; i++) { + var html = ''; + jQuery('#resettable').hide(); + jQuery('#lr_ciam_reset_table').show(); + + html += '
'; + html += '' + response.BackUpCodes[i] + ''; + html += '
'; + + jQuery('#backupcode-table-body').append(html); + } + jQuery('.mybackupcopy').click(function () { + setClipboard(jQuery(this).parent('.form-item').find('span').text()); + }); + }, function (errors) { + }); + } + }, 1); +} + +function callSocialInterface() { + var custom_interface_option = {}; + custom_interface_option.templateName = 'loginradiuscustom_tmpl'; + var lrSocialInterval = setInterval(function () { + if (typeof LRObject !== 'undefined') + { + clearInterval(lrSocialInterval); + LRObject.customInterface(".interfacecontainerdiv", custom_interface_option); + } + }, 1); + jQuery('#lr-loading').hide(); +} + +function initializeSocialRegisterCiamForm() { + var sl_options = {}; + sl_options.onSuccess = function (response) { + if (response.access_token != null && response.access_token != "") { + handleResponse(true, ""); + ciamRedirect(response.access_token); + jQuery('#lr-loading').hide(); + } else if (response.IsPosted) { + handleResponse(true, commonOptions.messagesList.SOCIAL_LOGIN_MSG); + jQuery('#social-registration-form').hide(); + jQuery('#lr-loading').hide(); + } + }; + sl_options.onError = function (response) { + if (response[0].Description != null) { + handleResponse(false, response[0].Description, "", "error"); + jQuery('#social-registration-form').hide(); + jQuery('#lr-loading').hide(); + } + }; + sl_options.container = "social-registration-container"; + var lrSocialLoginInterval = setInterval(function () { + if (typeof LRObject !== 'undefined') + { + clearInterval(lrSocialLoginInterval); + LRObject.init('socialLogin', sl_options); + } + }, 1); + +} + +function initializeLoginCiamForm() { + //initialize Login form + var login_options = {}; + login_options.onSuccess = function (response) { + if (response.IsPosted == true && typeof response.access_token !== 'undefined') { + if (jQuery('#loginradius-login-username').length !== 0 || jQuery('#loginradius-login-emailid').length !== 0) { + handleResponse(true, commonOptions.messagesList.LOGIN_BY_EMAIL_MSG); + } + } + else if( typeof response.Data !== 'undefined' && typeof response.Data.Sid !== 'undefined') + { + handleResponse(true, commonOptions.messagesList.OTP_SEND_ON_PHONE_SUCCESS_MSG); + } + else if( typeof response.Data !== 'undefined') + { + handleResponse(true, commonOptions.messagesList.EMAIL_VERIFICATION_SUCCESS_MSG); + }else if(response.IsPosted == true) { + handleResponse(true, commonOptions.messagesList.LOGIN_BY_EMAIL_MSG); + }else if (response.access_token) { + handleResponse(true); + ciamRedirect(response.access_token); + } + }; + login_options.onError = function (response) { + handleResponse(false, response[0].Description, "", "error"); + }; + login_options.container = "login-container"; + + var lrLoginInterval = setInterval(function () { + if (typeof LRObject !== 'undefined') + { + clearInterval(lrLoginInterval); + LRObject.init("login", login_options); + } + }, 1); + jQuery('#lr-loading').hide(); +} + +function initializeRegisterCiamForm() { + var registration_options = {} + registration_options.onSuccess = function (response) { + var optionalemailverification = ''; + var disableemailverification = ''; + if (typeof LRObject.options.optionalEmailVerification != 'undefined') { + optionalemailverification = LRObject.options.optionalEmailVerification; + } + if (typeof LRObject.options.disabledEmailVerification != 'undefined') { + disableemailverification = LRObject.options.disabledEmailVerification; + } + if (response.IsPosted && response.Data == null) { + if ((typeof (optionalemailverification) == 'undefined' || optionalemailverification !== true) && (typeof (disableemailverification) == 'undefined' || disableemailverification !== true)) { + handleResponse(true, commonOptions.messagesList.REGISTRATION_SUCCESS_MSG); + jQuery('html, body').animate({scrollTop: 0}, 1000); + } + }else if (response.access_token != null && response.access_token != "") { + handleResponse(true, ""); + ciamRedirect(response.access_token); + } else if(response.IsPosted && typeof response.Data !== 'undefined' && response.Data!==null && typeof response.Data.Sid !== 'undefined') + { + handleResponse(true, commonOptions.messagesList.OTP_SEND_ON_PHONE_SUCCESS_MSG); + } else if(LRObject.options.otpEmailVerification==true && response.Data==null) { + handleResponse(true, commonOptions.messagesList.VERIFICATION_OTP_SEND_ON_EMAIL_MSG); + } else { + handleResponse(true, commonOptions.messagesList.REGISTRATION_SUCCESS_MSG); + } + }; + registration_options.onError = function (response) { + if (response[0].Description != null) { + handleResponse(false, response[0].Description, "", "error"); + }else if (response[0] != null) { + handleResponse(false, response[0], "", "error"); + } + jQuery('html, body').animate({scrollTop: 0}, 1000); + }; + registration_options.container = "registration-container"; + var lrRegisterInterval = setInterval(function () { + if (typeof LRObject !== 'undefined') + { + clearInterval(lrRegisterInterval); + LRObject.init("registration", registration_options); + } + }, 1); + + jQuery('#lr-loading').hide(); +} + +function initializeResetPasswordCiamForm(commonOptions) { + //initialize reset password form and handel email verifaction + var resetpasswordInterval = setInterval(function () { + if (typeof LRObject !== 'undefined') + { + clearInterval(resetpasswordInterval); + var vtype = LRObject.util.getQueryParameterByName("vtype"); + if (vtype != null && vtype != "") { + if (vtype == "reset") { + var resetpassword_options = {}; + resetpassword_options.container = "resetpassword-container"; + jQuery('#login-container').hide(); + jQuery('.interfacecontainerdiv').hide(); + jQuery('.page-title').text('Reset Password'); + jQuery('#interfaceLabel').hide(); + resetpassword_options.onSuccess = function (response) { + handleResponse(true, commonOptions.messagesList.FORGOT_PASSWORD_SUCCESS_MSG); + window.setTimeout(function () { + window.location.replace(commonOptions.verificationUrl); + }, 3000); + }; + resetpassword_options.onError = function (errors) { + handleResponse(false, errors[0].Description, "", "error"); + } + + LRObject.init("resetPassword", resetpassword_options); + + } else if (vtype == "emailverification") { + var verifyemail_options = {}; + verifyemail_options.onSuccess = function (response) { + if (typeof response != 'undefined') { + if (!loggedIn && typeof response.access_token != "undefined" && response.access_token != null && response.access_token != "") { + ciamRedirect(response.access_token); + } else if (!loggedIn && response.Data != null && response.Data.access_token != null && response.Data.access_token != "") { + ciamRedirect(response.Data.access_token); + } else { + lrSetCookie('lr_message', commonOptions.messagesList.EMAIL_VERIFICATION_SUCCESS_MSG); + window.location.href = window.location.href.split('?')[0] + '?lrresponse=true'; + } + } + }; + verifyemail_options.onError = function (errors) { + lrSetCookie('lr_message', errors[0].Description); + window.location.href = window.location.href.split('?')[0] + '?lrresponse=false'; + } + + LRObject.init("verifyEmail", verifyemail_options); + + + } else if (vtype == "oneclicksignin") { + var options = {}; + options.onSuccess = function (response) { + ciamRedirect(response.access_token); + }; + options.onError = function (errors) { + if (!loggedIn){ + showErrorMsgForOneClickSignIn(false, errors[0].Description); + }else{ + window.location.href = homeDomain; + } + }; + + LRObject.init("instantLinkLogin", options); + } + } + } + }, 1); + jQuery('#lr-loading').hide(); +} + +function initializeForgotPasswordCiamForms() { + //initialize forgot password form + var forgotpassword_options = {}; + forgotpassword_options.container = "forgotpassword-container"; + forgotpassword_options.onSuccess = function (response) { + if(response.IsPosted == true && typeof response.Data !== 'undefined' && response.Data!==null) + { + handleResponse(true, commonOptions.messagesList.OTP_SEND_ON_PHONE_SUCCESS_MSG); + }else if(LRObject.options.otpEmailVerification==true && typeof response.Data==='undefined') + { + handleResponse(true, commonOptions.messagesList.VERIFICATION_OTP_SEND_ON_EMAIL_MSG); + } else if (response.IsPosted == true && typeof (response.Data) === "object") { + if(jQuery('form[name="loginradius-resetpassword"]').length > 0) { + handleResponse(true, commonOptions.messagesList.FORGOT_PASSWORD_SUCCESS_MSG); + window.setTimeout(function () { + window.location.replace(commonOptions.verificationUrl); + }, 3000); + } + }else if (response.IsPosted == true && typeof (response.Data) === "undefined") { + if(jQuery('form[name="loginradius-resetpassword"]').length > 0) { + handleResponse(true, commonOptions.messagesList.FORGOT_PASSWORD_SUCCESS_MSG); + window.setTimeout(function () { + window.location.replace(commonOptions.verificationUrl); + }, 3000); + } else { + handleResponse(true, commonOptions.messagesList.FORGOT_PASSWORD_MSG); + } + } + }; + forgotpassword_options.onError = function (response) { + if (response[0].Description != null) { + handleResponse(false, response[0].Description, "", "error"); + } + } + + var lrForgotInterval = setInterval(function () { + if (typeof LRObject !== 'undefined') + { + clearInterval(lrForgotInterval); + LRObject.init("forgotPassword", forgotpassword_options); + } + }, 1); + + jQuery('#lr-loading').hide(); +} + +function initializeAccountLinkingCiamForms() { + var la_options = {}; + la_options.container = "interfacecontainerdiv"; + la_options.templateName = 'loginradiuscustom_tmpl_link'; + la_options.onSuccess = function (response) { + if (response.IsPosted != true) { + handleResponse(true, ""); + ciamRedirect(response); + } else { + handleResponse(true, commonOptions.messagesList.ACCOUNT_LINKING_MSG, "showmsg"); + window.setTimeout(function () { + window.location.reload(); + }, 3000); + } + }; + la_options.onError = function (errors) { + handleResponse(false, errors[0].Description, "showmsg", "error"); + } + + var unlink_options = {}; + unlink_options.onSuccess = function (response) { + if (response.IsDeleted == true) { + handleResponse(true, commonOptions.messagesList.ACCOUNT_UNLINKING_MSG, "showmsg"); + window.setTimeout(function () { + window.location.reload(); + }, 3000); + } + }; + unlink_options.onError = function (errors) { + handleResponse(false, errors[0].Description, "showmsg", "error"); + } + + + var lrLinkingInterval = setInterval(function () { + var localaccesstoken = LRObject.storage.getBrowserStorage('LRTokenKey'); + if (typeof LRObject !== 'undefined' && localaccesstoken) + { + clearInterval(lrLinkingInterval); + LRObject.init("linkAccount", la_options); + LRObject.init("unLinkAccount", unlink_options); + } + }, 1); + jQuery('#lr-loading').hide(); +} + +function initializeTwoFactorAuthenticator() { + //initialize two factor authenticator button + var authentication_options = {}; + authentication_options.container = "authentication-container"; + authentication_options.onSuccess = function (response) { + if(response.Sid){ + handleResponse(true, commonOptions.messagesList.OTP_SEND_ON_PHONE_SUCCESS_MSG); + } if (response.IsDeleted == true) { + handleResponse(true, commonOptions.messagesList.TWO_FA_DISABLED_MSG, "showmsg"); + jQuery('html, body').animate({scrollTop: 0}, 1000); + window.setTimeout(function () { + window.location.reload(); + }, 3000); + } else if(typeof response.Uid != 'undefined'){ + handleResponse(true, commonOptions.messagesList.TWO_FA_ENABLED_MSG, "showmsg"); + jQuery('html, body').animate({scrollTop: 0}, 1000); + window.setTimeout(function () { + window.location.reload(); + }, 3000); + } + }; + authentication_options.onError = function (errors) { + if (errors[0].Description != null) { + handleResponse(false, errors[0].Description, "showmsg", "error"); + } + } + var lrTwoFAInterval = setInterval(function () { + var localaccesstoken = LRObject.storage.getBrowserStorage('LRTokenKey'); + if (typeof LRObject !== 'undefined' && localaccesstoken) + { + clearInterval(lrTwoFAInterval); + LRObject.init("createTwoFactorAuthentication", authentication_options); + + } + }, 1); +} + +function initializeProfileUpdate() { + var profileeditor_options = {}; + profileeditor_options.container = "profileeditor-container"; + profileeditor_options.onSuccess = function(response) { + handleResponse(true, commonOptions.messagesList.UPDATE_USER_PROFILE, 'showmsg'); + lrSetCookie('lr_profile_update', 'true'); + window.location.href = window.location.href; + + }; + profileeditor_options.onError = function(errors) { + if (errors[0].Description != null) { + handleResponse(false, errors[0].Description, "showmsg", "error"); + } + }; + var lrUpdateInterval = setInterval(function () { + var localaccesstoken = LRObject.storage.getBrowserStorage('LRTokenKey'); + if (typeof LRObject !== 'undefined' && localaccesstoken) + { + clearInterval(lrUpdateInterval); + LRObject.init("profileEditor",profileeditor_options); + } + }, 1); +} + +function initializePhoneUpdate() { + var updatephone_options = {}; + updatephone_options.container = "updatephone-container"; + updatephone_options.onSuccess = function (response) { + if(typeof response.Data !== 'undefined'){ + handleResponse(true, commonOptions.messagesList.OTP_SEND_ON_PHONE_SUCCESS_MSG, 'showmsg'); + } + else if(response.IsPosted == true) { + handleResponse(true, commonOptions.messagesList.UPDATE_PHONE_SUCCESS_MSG, 'showmsg'); + window.setTimeout(function () { + window.location.reload(); + }, 3000); + } + }; + updatephone_options.onError = function (errors) { + if (errors[0].Description != null) { + handleResponse(false, errors[0].Description, "showmsg", "error"); + } + }; + var lrUpdateInterval = setInterval(function () { + var localaccesstoken = LRObject.storage.getBrowserStorage('LRTokenKey'); + if (typeof LRObject !== 'undefined' && localaccesstoken) + { + clearInterval(lrUpdateInterval); + LRObject.init("updatePhone", updatephone_options); + } + }, 1); +} + +function initializeAddEmailCiamForms() { + var addemail_options = {}; + addemail_options.container = "addemail-container"; + addemail_options.onSuccess = function (response) { + jQuery('#addemail-form').hide(); + handleResponse(true, commonOptions.messagesList.ADD_EMAIL_MSG, 'showmsg'); + jQuery('html, body').animate({scrollTop: 0}, 1000); + }; + addemail_options.onError = function (errors) { + jQuery('#addemail-form').hide(); + handleResponse(false, errors[0].Description, "showmsg", "error"); + jQuery('html, body').animate({scrollTop: 0}, 1000); + }; + + var lrAddInterval = setInterval(function () { + var localaccesstoken = LRObject.storage.getBrowserStorage('LRTokenKey'); + if (typeof LRObject !== 'undefined' && localaccesstoken) + { + clearInterval(lrAddInterval); + LRObject.init("addEmail", addemail_options); + jQuery('#lr-loading').hide(); + } + }, 1); +} + +function initializeRemoveEmailCiamForms(divhtml) { + var removeemail_options = {}; + removeemail_options.container = "removeemail-container"; + removeemail_options.onSuccess = function (response) { + jQuery('#removeemail-form').hide(); + handleResponse(true, commonOptions.messagesList.REMOVE_EMAIL_MSG, 'showmsg'); + divhtml.remove(); + jQuery('html, body').animate({scrollTop: 0}, 1000); + }; + removeemail_options.onError = function (errors) { + jQuery('#removeemail-form').hide(); + handleResponse(false, errors[0].Description, "showmsg", "error"); + jQuery('html, body').animate({scrollTop: 0}, 1000); + + }; + var lrRemoveInterval = setInterval(function () { + var localaccesstoken = LRObject.storage.getBrowserStorage('LRTokenKey'); + if (typeof LRObject !== 'undefined' && localaccesstoken) + { + clearInterval(lrRemoveInterval); + LRObject.init("removeEmail", removeemail_options); + jQuery('#lr-loading').hide(); + } + }, 1); +} + +function initializeChangePasswordCiamForms() { + var changepassword_options = {}; + changepassword_options.container = "changepassword-container"; + changepassword_options.onSuccess = function (response) { + handleResponse(true, commonOptions.messagesList.CHANGE_PASSWORD_SUCCESS_MSG); + }; + changepassword_options.onError = function (errors) { + handleResponse(false, errors[0].Description, "", "error"); + }; + + var lrChangeInterval = setInterval(function () { + var localaccesstoken = LRObject.storage.getBrowserStorage('LRTokenKey'); + if (typeof LRObject !== 'undefined' && localaccesstoken) + { + clearInterval(lrChangeInterval); + LRObject.init("changePassword", changepassword_options); + jQuery('#lr-loading').hide(); + } + }, 1); +} + +function ciamRedirect(token, name) { + if (window.redirect) { + redirect(token, name); + } else { + var token_name = name ? name : 'token'; + + var form = document.createElement('form'); + form.action = LocalDomain; + form.method = 'POST'; + + var hiddenToken = document.createElement('input'); + hiddenToken.type = 'hidden'; + hiddenToken.value = token; + hiddenToken.name = token_name; + form.appendChild(hiddenToken); + + document.body.appendChild(form); + form.submit(); + } +} + +function setClipboard() { + var value = ''; + jQuery('.code-list').find('span').each(function () { + value += jQuery(this).html() + "\n"; + }); + var tempInput = document.createElement("textarea"); + tempInput.style = "position: absolute; left: -1000px; top: -1000px"; + tempInput.value = value; + document.body.appendChild(tempInput); + tempInput.select(); + document.execCommand("copy"); + document.body.removeChild(tempInput); + jQuery('.copyMessage').show(); + setTimeout(removeCodeCss, 5000); +} + +function removeCodeCss() { + jQuery('.code-list').find('span').removeAttr('style'); + jQuery('.copyMessage').hide(); +} + +function changeIconColor() { + jQuery('.code-list').find('span').css({'background-color': '#29d', 'color': '#fff'}); +} + +function lrSetCookie(cname, cvalue, exdays) { + var d = new Date(); + d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000)); + var expires = "expires=" + d.toUTCString(); + document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/"; +} diff --git a/drupal-10/src/customer_identity_and_access_management/lr_ciam/js/LoginRadiusFrontEnd.min.js b/drupal-10/src/customer_identity_and_access_management/lr_ciam/js/LoginRadiusFrontEnd.min.js new file mode 100644 index 0000000..e6b75a4 --- /dev/null +++ b/drupal-10/src/customer_identity_and_access_management/lr_ciam/js/LoginRadiusFrontEnd.min.js @@ -0,0 +1 @@ +function showOrHidePasswordlessTemplate(e){"false"===e||""===e?jQuery(".form-item-ciam-instant-link-login-email-template").hide():jQuery(".form-item-ciam-instant-link-login-email-template").show()}function showOrHidePasswordlessOTPTemplate(e){"false"===e||""===e?jQuery(".form-item-ciam-sms-template-one-time-passcode").hide():jQuery(".form-item-ciam-sms-template-one-time-passcode").show()}function showOrHideCustomRedirection(e){"0"===e||"1"===e||""===e?jQuery(".form-item-custom-login-url").hide():jQuery(".form-item-custom-login-url").show()}if(jQuery(document).ready(function(){jQuery("#lr-loading").click(function(){jQuery("#lr-loading").hide()}),window.addEventListener("pageshow",function(e){(e.persisted||void 0!==window.performance&&2===window.performance.navigation.type)&&window.location.reload()}),showOrHideCustomRedirection(jQuery('input:radio[name="login_redirection"]:checked').val()),jQuery('input:radio[name="login_redirection"]').change(function(){showOrHideCustomRedirection(jQuery(this).val())}),showOrHidePasswordlessTemplate(jQuery('input:radio[name="ciam_instant_link_login"]:checked').val()),jQuery('input:radio[name="ciam_instant_link_login"]').change(function(){showOrHidePasswordlessTemplate(jQuery(this).val())}),showOrHidePasswordlessOTPTemplate(jQuery('input:radio[name="ciam_instant_otp_login"]:checked').val()),jQuery('input:radio[name="ciam_instant_otp_login"]').change(function(){showOrHidePasswordlessOTPTemplate(jQuery(this).val())}),window.location.href==window.location.origin+domainName+"admin/people/create"?(jQuery(".form-item-mail label").attr("class","js-form-required form-required"),jQuery("#edit-mail").attr("required","required")):(jQuery("#edit-mail").attr("disabled","disabled"),jQuery("#edit-mail").attr("style","background:#ededed")),dropemailvalue="",jQuery(".removeEmail").each(function(){jQuery(this).click(function(){jQuery('form[name="loginradius-removeemail"]').remove();var e=jQuery(this).parents("tr");dropemailvalue=jQuery(this).parents("tr").find(".form-email").val(),showRemoveEmailPopup(e)})}),jQuery("#addEmail").attr("onClick","showAddEmailPopup()")}),"undefined"==typeof LoginRadiusV2){var e=document.createElement("script");e.src="https://auth.lrcontent2.com/v2/js/LoginRadiusV2.js",e.type="text/javascript",document.getElementsByTagName("head")[0].appendChild(e)}var lrloadInterval=setInterval(function(){"undefined"!=typeof LoginRadiusV2&&(clearInterval(lrloadInterval),LRObject=new LoginRadiusV2(commonOptions))},1);function showRemoveEmailPopup(e){jQuery("#removeemail-form").show(),initializeRemoveEmailCiamForms(e)}function showAddEmailPopup(){jQuery("#addemail-form").show(),initializeAddEmailCiamForms()}function lrCloseRemovePopup(){jQuery('form[name="loginradius-removeemail"]').remove(),jQuery("#removeemail-form").hide()}function lrCloseAddEmailPopup(){jQuery("#addemail-form").hide()}function show_birthdate_date_block(){var e=(new Date).getFullYear(),o=e-100;jQuery("body").on?jQuery("body").on("focus",".loginradius-birthdate",function(){jQuery(".loginradius-birthdate").datepicker({dateFormat:"mm-dd-yy",maxDate:new Date,minDate:"-100y",changeMonth:!0,changeYear:!0,yearRange:o+":"+e})}):jQuery(".loginradius-birthdate").live("focus",function(){jQuery(".loginradius-birthdate").datepicker({dateFormat:"mm-dd-yy",maxDate:new Date,minDate:"-100y",changeMonth:!0,changeYear:!0,yearRange:o+":"+e})})}function handleResponse(e,o,n,i){i=i?"messages--"+i:"messages--status",e&&jQuery("form").each(function(){this.reset()}),null!=o&&""!=o?(jQuery("#lr-loading").hide(),jQuery(".messages").text(o),jQuery(".messages__wrapper").show(),jQuery(".messages").show(),jQuery(".messages").removeClass("messages--error messages--status showmsg"),jQuery(".messages").addClass(i),jQuery(".messages").addClass(n),""!=autoHideTime&&"0"!=autoHideTime&&setTimeout(fade_out,1e3*autoHideTime)):(jQuery(".messages__wrapper").hide(),jQuery(".messages").hide(),jQuery(".messages").text(""))}function showErrorMsgForOneClickSignIn(e,o){e&&jQuery("form").each(function(){this.reset()}),null!=o&&""!=o?(jQuery("#lr-loading").hide(),jQuery("div[data-drupal-messages-fallback]").text(o),jQuery("div[data-drupal-messages-fallback]").show(),jQuery("div[data-drupal-messages-fallback]").removeClass("oneclick--errormsg"),jQuery("div[data-drupal-messages-fallback]").addClass("oneclick--errormsg"),""!=autoHideTime&&"0"!=autoHideTime&&setTimeout(fade_out,1e3*autoHideTime)):(jQuery(".div[data-drupal-messages-fallback]").hide(),jQuery(".div[data-drupal-messages-fallback]").text(""))}function fade_out(){jQuery(".messages").hide()}var setButtonInterval=setInterval(function(){"undefined"!=typeof LRObject&&(clearInterval(setButtonInterval),LRObject.$hooks.register("startProcess",function(){jQuery("#lr-loading").show()}),LRObject.$hooks.register("endProcess",function(){!0!==LRObject.options.twoFactorAuthentication&&!0!==LRObject.options.optionalTwoFactorAuthentication||jQuery("#authentication-container").show(),jQuery("#edit-account-phone").hide(),!0===LRObject.options.phoneLogin&&(jQuery("#updatephone-container").show(),jQuery("#edit-account-phone").show()),jQuery("#lr-loading").hide()}),LRObject.$hooks.call("setButtonsName",{removeemail:"Remove"}),LRObject.registrationFormSchema=registrationSchema,LRObject.$hooks.register("socialLoginFormRender",function(){jQuery("#lr-loading").hide(),jQuery("#social-registration-form").show(),show_birthdate_date_block()}),LRObject.$hooks.register("afterFormRender",function(e){"socialRegistration"==e&&jQuery("#login-container").find("form[name=loginradius-socialRegistration]").parent().addClass("socialRegistration"),"updatePhone"==e&&""==phoneId&&jQuery("#updatephone-container").find("#loginradius-submit-update").attr("value","Add"),"removeemail"==e&&jQuery("#loginradius-removeemail-emailid").val(dropemailvalue)}))},1);function getBackupCodes(){var e=setInterval(function(){"undefined"!=typeof LRObject&&(clearInterval(e),LRObject.api.getBackupCode(accessToken,function(e){jQuery("#backupcode-table-body").empty();for(var o=0;o',n+=''+e.BackUpCodes[o]+"",n+="",jQuery("#backupcode-table-body").append(n)}jQuery(".mybackupcopy").click(function(){setClipboard(jQuery(this).parent(".form-item").find("span").text())})},function(e){jQuery("#resettable").show()}))},1)}function resetBackupCodes(){var e=setInterval(function(){"undefined"!=typeof LRObject&&(clearInterval(e),LRObject.api.resetBackupCode(accessToken,function(e){jQuery("#backupcode-table-body").empty();for(var o=0;o',n+=''+e.BackUpCodes[o]+"",n+="",jQuery("#backupcode-table-body").append(n)}jQuery(".mybackupcopy").click(function(){setClipboard(jQuery(this).parent(".form-item").find("span").text())})},function(e){}))},1)}function callSocialInterface(){var e={templateName:"loginradiuscustom_tmpl"},o=setInterval(function(){"undefined"!=typeof LRObject&&(clearInterval(o),LRObject.customInterface(".interfacecontainerdiv",e))},1);jQuery("#lr-loading").hide()}function initializeSocialRegisterCiamForm(){var e={onSuccess:function(e){null!=e.access_token&&""!=e.access_token?(handleResponse(!0,""),ciamRedirect(e.access_token),jQuery("#lr-loading").hide()):e.IsPosted&&(handleResponse(!0,commonOptions.messagesList.SOCIAL_LOGIN_MSG),jQuery("#social-registration-form").hide(),jQuery("#lr-loading").hide())},onError:function(e){null!=e[0].Description&&(handleResponse(!1,e[0].Description,"","error"),jQuery("#social-registration-form").hide(),jQuery("#lr-loading").hide())},container:"social-registration-container"},o=setInterval(function(){"undefined"!=typeof LRObject&&(clearInterval(o),LRObject.init("socialLogin",e))},1)}function initializeLoginCiamForm(){var e={onSuccess:function(e){1==e.IsPosted&&void 0!==e.access_token?0===jQuery("#loginradius-login-username").length&&0===jQuery("#loginradius-login-emailid").length||handleResponse(!0,commonOptions.messagesList.LOGIN_BY_EMAIL_MSG):void 0!==e.Data&&void 0!==e.Data.Sid?handleResponse(!0,commonOptions.messagesList.OTP_SEND_ON_PHONE_SUCCESS_MSG):void 0!==e.Data?handleResponse(!0,commonOptions.messagesList.EMAIL_VERIFICATION_SUCCESS_MSG):1==e.IsPosted?handleResponse(!0,commonOptions.messagesList.LOGIN_BY_EMAIL_MSG):e.access_token&&(handleResponse(!0),ciamRedirect(e.access_token))},onError:function(e){handleResponse(!1,e[0].Description,"","error")},container:"login-container"},o=setInterval(function(){"undefined"!=typeof LRObject&&(clearInterval(o),LRObject.init("login",e))},1);jQuery("#lr-loading").hide()}function initializeRegisterCiamForm(){var e={onSuccess:function(e){var o="",n="";void 0!==LRObject.options.optionalEmailVerification&&(o=LRObject.options.optionalEmailVerification),void 0!==LRObject.options.disabledEmailVerification&&(n=LRObject.options.disabledEmailVerification),e.IsPosted&&null==e.Data?void 0!==o&&!0===o||void 0!==n&&!0===n||(handleResponse(!0,commonOptions.messagesList.REGISTRATION_SUCCESS_MSG),jQuery("html, body").animate({scrollTop:0},1e3)):null!=e.access_token&&""!=e.access_token?(handleResponse(!0,""),ciamRedirect(e.access_token)):e.IsPosted&&void 0!==e.Data&&null!==e.Data&&void 0!==e.Data.Sid?handleResponse(!0,commonOptions.messagesList.OTP_SEND_ON_PHONE_SUCCESS_MSG):1==LRObject.options.otpEmailVerification&&null==e.Data?handleResponse(!0,commonOptions.messagesList.VERIFICATION_OTP_SEND_ON_EMAIL_MSG):handleResponse(!0,commonOptions.messagesList.REGISTRATION_SUCCESS_MSG)},onError:function(e){null!=e[0].Description?handleResponse(!1,e[0].Description,"","error"):null!=e[0]&&handleResponse(!1,e[0],"","error"),jQuery("html, body").animate({scrollTop:0},1e3)},container:"registration-container"},o=setInterval(function(){"undefined"!=typeof LRObject&&(clearInterval(o),LRObject.init("registration",e))},1);jQuery("#lr-loading").hide()}function initializeResetPasswordCiamForm(e){var o=setInterval(function(){if("undefined"!=typeof LRObject){clearInterval(o);var n=LRObject.util.getQueryParameterByName("vtype");if(null!=n&&""!=n)if("reset"==n){var i={container:"resetpassword-container"};jQuery("#login-container").hide(),jQuery(".interfacecontainerdiv").hide(),jQuery(".page-title").text("Reset Password"),jQuery("#interfaceLabel").hide(),i.onSuccess=function(o){handleResponse(!0,e.messagesList.FORGOT_PASSWORD_SUCCESS_MSG),window.setTimeout(function(){window.location.replace(e.verificationUrl)},3e3)},i.onError=function(e){handleResponse(!1,e[0].Description,"","error")},LRObject.init("resetPassword",i)}else if("emailverification"==n){var t={onSuccess:function(o){void 0!==o&&(loggedIn||void 0===o.access_token||null==o.access_token||""==o.access_token?loggedIn||null==o.Data||null==o.Data.access_token||""==o.Data.access_token?(lrSetCookie("lr_message",e.messagesList.EMAIL_VERIFICATION_SUCCESS_MSG),window.location.href=window.location.href.split("?")[0]+"?lrresponse=true"):ciamRedirect(o.Data.access_token):ciamRedirect(o.access_token))},onError:function(e){lrSetCookie("lr_message",e[0].Description),window.location.href=window.location.href.split("?")[0]+"?lrresponse=false"}};LRObject.init("verifyEmail",t)}else if("oneclicksignin"==n){var a={onSuccess:function(e){ciamRedirect(e.access_token)},onError:function(e){loggedIn?window.location.href=homeDomain:showErrorMsgForOneClickSignIn(!1,e[0].Description)}};LRObject.init("instantLinkLogin",a)}}},1);jQuery("#lr-loading").hide()}function initializeForgotPasswordCiamForms(){var e={container:"forgotpassword-container",onSuccess:function(e){1==e.IsPosted&&void 0!==e.Data&&null!==e.Data?handleResponse(!0,commonOptions.messagesList.OTP_SEND_ON_PHONE_SUCCESS_MSG):1==LRObject.options.otpEmailVerification&&void 0===e.Data?handleResponse(!0,commonOptions.messagesList.VERIFICATION_OTP_SEND_ON_EMAIL_MSG):1==e.IsPosted&&"object"==typeof e.Data?jQuery('form[name="loginradius-resetpassword"]').length>0&&(handleResponse(!0,commonOptions.messagesList.FORGOT_PASSWORD_SUCCESS_MSG),window.setTimeout(function(){window.location.replace(commonOptions.verificationUrl)},3e3)):1==e.IsPosted&&void 0===e.Data&&(jQuery('form[name="loginradius-resetpassword"]').length>0?(handleResponse(!0,commonOptions.messagesList.FORGOT_PASSWORD_SUCCESS_MSG),window.setTimeout(function(){window.location.replace(commonOptions.verificationUrl)},3e3)):handleResponse(!0,commonOptions.messagesList.FORGOT_PASSWORD_MSG))},onError:function(e){null!=e[0].Description&&handleResponse(!1,e[0].Description,"","error")}},o=setInterval(function(){"undefined"!=typeof LRObject&&(clearInterval(o),LRObject.init("forgotPassword",e))},1);jQuery("#lr-loading").hide()}function initializeAccountLinkingCiamForms(){var e={container:"interfacecontainerdiv",templateName:"loginradiuscustom_tmpl_link",onSuccess:function(e){1!=e.IsPosted?(handleResponse(!0,""),ciamRedirect(e)):(handleResponse(!0,commonOptions.messagesList.ACCOUNT_LINKING_MSG,"showmsg"),window.setTimeout(function(){window.location.reload()},3e3))},onError:function(e){handleResponse(!1,e[0].Description,"showmsg","error")}},o={onSuccess:function(e){1==e.IsDeleted&&(handleResponse(!0,commonOptions.messagesList.ACCOUNT_UNLINKING_MSG,"showmsg"),window.setTimeout(function(){window.location.reload()},3e3))},onError:function(e){handleResponse(!1,e[0].Description,"showmsg","error")}},n=setInterval(function(){var i=LRObject.storage.getBrowserStorage("LRTokenKey");"undefined"!=typeof LRObject&&i&&(clearInterval(n),LRObject.init("linkAccount",e),LRObject.init("unLinkAccount",o))},1);jQuery("#lr-loading").hide()}function initializeTwoFactorAuthenticator(){var e={container:"authentication-container",onSuccess:function(e){e.Sid&&handleResponse(!0,commonOptions.messagesList.OTP_SEND_ON_PHONE_SUCCESS_MSG),1==e.IsDeleted?(handleResponse(!0,commonOptions.messagesList.TWO_FA_DISABLED_MSG,"showmsg"),jQuery("html, body").animate({scrollTop:0},1e3),window.setTimeout(function(){window.location.reload()},3e3)):void 0!==e.Uid&&(handleResponse(!0,commonOptions.messagesList.TWO_FA_ENABLED_MSG,"showmsg"),jQuery("html, body").animate({scrollTop:0},1e3),window.setTimeout(function(){window.location.reload()},3e3))},onError:function(e){null!=e[0].Description&&handleResponse(!1,e[0].Description,"showmsg","error")}},o=setInterval(function(){var n=LRObject.storage.getBrowserStorage("LRTokenKey");"undefined"!=typeof LRObject&&n&&(clearInterval(o),LRObject.init("createTwoFactorAuthentication",e))},1)}function initializeProfileUpdate(){var e={container:"profileeditor-container",onSuccess:function(e){handleResponse(!0,commonOptions.messagesList.UPDATE_USER_PROFILE,"showmsg"),lrSetCookie("lr_profile_update","true"),window.location.href=window.location.href},onError:function(e){null!=e[0].Description&&handleResponse(!1,e[0].Description,"showmsg","error")}},o=setInterval(function(){var n=LRObject.storage.getBrowserStorage("LRTokenKey");"undefined"!=typeof LRObject&&n&&(clearInterval(o),LRObject.init("profileEditor",e))},1)}function initializePhoneUpdate(){var e={container:"updatephone-container",onSuccess:function(e){void 0!==e.Data?handleResponse(!0,commonOptions.messagesList.OTP_SEND_ON_PHONE_SUCCESS_MSG,"showmsg"):1==e.IsPosted&&(handleResponse(!0,commonOptions.messagesList.UPDATE_PHONE_SUCCESS_MSG,"showmsg"),window.setTimeout(function(){window.location.reload()},3e3))},onError:function(e){null!=e[0].Description&&handleResponse(!1,e[0].Description,"showmsg","error")}},o=setInterval(function(){var n=LRObject.storage.getBrowserStorage("LRTokenKey");"undefined"!=typeof LRObject&&n&&(clearInterval(o),LRObject.init("updatePhone",e))},1)}function initializeAddEmailCiamForms(){var e={container:"addemail-container",onSuccess:function(e){jQuery("#addemail-form").hide(),handleResponse(!0,commonOptions.messagesList.ADD_EMAIL_MSG,"showmsg"),jQuery("html, body").animate({scrollTop:0},1e3)},onError:function(e){jQuery("#addemail-form").hide(),handleResponse(!1,e[0].Description,"showmsg","error"),jQuery("html, body").animate({scrollTop:0},1e3)}},o=setInterval(function(){var n=LRObject.storage.getBrowserStorage("LRTokenKey");"undefined"!=typeof LRObject&&n&&(clearInterval(o),LRObject.init("addEmail",e),jQuery("#lr-loading").hide())},1)}function initializeRemoveEmailCiamForms(e){var o={container:"removeemail-container",onSuccess:function(o){jQuery("#removeemail-form").hide(),handleResponse(!0,commonOptions.messagesList.REMOVE_EMAIL_MSG,"showmsg"),e.remove(),jQuery("html, body").animate({scrollTop:0},1e3)},onError:function(e){jQuery("#removeemail-form").hide(),handleResponse(!1,e[0].Description,"showmsg","error"),jQuery("html, body").animate({scrollTop:0},1e3)}},n=setInterval(function(){var e=LRObject.storage.getBrowserStorage("LRTokenKey");"undefined"!=typeof LRObject&&e&&(clearInterval(n),LRObject.init("removeEmail",o),jQuery("#lr-loading").hide())},1)}function initializeChangePasswordCiamForms(){var e={container:"changepassword-container",onSuccess:function(e){handleResponse(!0,commonOptions.messagesList.CHANGE_PASSWORD_SUCCESS_MSG)},onError:function(e){handleResponse(!1,e[0].Description,"","error")}},o=setInterval(function(){var n=LRObject.storage.getBrowserStorage("LRTokenKey");"undefined"!=typeof LRObject&&n&&(clearInterval(o),LRObject.init("changePassword",e),jQuery("#lr-loading").hide())},1)}function ciamRedirect(e,o){if(window.redirect)redirect(e,o);else{var n=o||"token",i=document.createElement("form");i.action=LocalDomain,i.method="POST";var t=document.createElement("input");t.type="hidden",t.value=e,t.name=n,i.appendChild(t),document.body.appendChild(i),i.submit()}}function setClipboard(){var e="";jQuery(".code-list").find("span").each(function(){e+=jQuery(this).html()+"\n"});var o=document.createElement("textarea");o.style="position: absolute; left: -1000px; top: -1000px",o.value=e,document.body.appendChild(o),o.select(),document.execCommand("copy"),document.body.removeChild(o),jQuery(".copyMessage").show(),setTimeout(removeCodeCss,5e3)}function removeCodeCss(){jQuery(".code-list").find("span").removeAttr("style"),jQuery(".copyMessage").hide()}function changeIconColor(){jQuery(".code-list").find("span").css({"background-color":"#29d",color:"#fff"})}function lrSetCookie(e,o,n){var i=new Date;i.setTime(i.getTime()+24*n*60*60*1e3);var t="expires="+i.toUTCString();document.cookie=e+"="+o+";"+t+";path=/"} \ No newline at end of file diff --git a/drupal-10/src/customer_identity_and_access_management/lr_ciam/js/account_linking.js b/drupal-10/src/customer_identity_and_access_management/lr_ciam/js/account_linking.js new file mode 100644 index 0000000..2df9cc1 --- /dev/null +++ b/drupal-10/src/customer_identity_and_access_management/lr_ciam/js/account_linking.js @@ -0,0 +1,4 @@ +jQuery(document).ready(function () { + initializeAccountLinkingCiamForms(); +}); + diff --git a/drupal-10/src/customer_identity_and_access_management/lr_ciam/js/ciam_admin.js b/drupal-10/src/customer_identity_and_access_management/lr_ciam/js/ciam_admin.js new file mode 100644 index 0000000..493f83d --- /dev/null +++ b/drupal-10/src/customer_identity_and_access_management/lr_ciam/js/ciam_admin.js @@ -0,0 +1,72 @@ +jQuery(document).ready(function () { + if(jQuery("#secret").prop("type") == 'password') { + jQuery("#secret").prop("type",'text'); + } else { + jQuery("#secret").prop("type",'password'); + } + + jQuery("#ciam_show_button").click(function () { + if(jQuery("#secret").prop("type") == 'password'){ + jQuery("#secret").prop("type",'text'); + jQuery("#ciam_show_button").text("Hide"); + }else{ + jQuery("#secret").prop("type",'password'); + jQuery("#ciam_show_button").text("Show"); + } + }); + + + jQuery("#edit-submit").on('click',function(){ + var profile = jQuery('#ciam_registration_schema').val(); + var response = ''; + try + { + if (profile != "" && typeof profile !== 'undefined') { + response = jQuery.parseJSON(profile); + if (response != true && response != false) { + var validjson = JSON.stringify(response, null, '\t').replace(/Please enter a valid Json. '+e.message+''); + return false; + } + }); +}); + +function lrCheckValidJson() { + jQuery('#ciam_custom_options').change(function () { + var profile = jQuery('#ciam_custom_options').val(); + var response = ''; + try + { + response = jQuery.parseJSON(profile); + if (response != true && response != false) { + var validjson = JSON.stringify(response, null, '\t').replace(/ -1)) { + initializeChangePasswordCiamForms(); + initializeTwoFactorAuthenticator(); + initializeAddEmailCiamForms(); + initializeRemoveEmailCiamForms(); + getBackupCodes(); + initializePhoneUpdate(); + initializeProfileUpdate(); + } +}); + diff --git a/drupal-10/src/customer_identity_and_access_management/lr_ciam/js/ciam_interface.js b/drupal-10/src/customer_identity_and_access_management/lr_ciam/js/ciam_interface.js new file mode 100644 index 0000000..190a8b7 --- /dev/null +++ b/drupal-10/src/customer_identity_and_access_management/lr_ciam/js/ciam_interface.js @@ -0,0 +1,101 @@ +//initialize ciam options +var commonOptions = {}; +var LocalDomain = drupalSettings.ciam.callback; +var homeDomain = drupalSettings.ciam.home; +var accessToken = drupalSettings.ciam.accessToken; +var phoneId = drupalSettings.ciam.phoneId; +var autoHideTime = drupalSettings.ciam.autoHideTime; +var loggedIn = drupalSettings.ciam.loggedIn; +var domainName = drupalSettings.ciam.appPath; +var registrationSchema = drupalSettings.ciam.registrationSchema; +commonOptions.apiKey = drupalSettings.ciam.apiKey; +commonOptions.appName = drupalSettings.ciam.appName; +commonOptions.appPath = drupalSettings.ciam.appPath; +commonOptions.sott = drupalSettings.ciam.sott; +commonOptions.verificationUrl = drupalSettings.ciam.verificationUrl; +commonOptions.resetPasswordUrl = drupalSettings.ciam.resetPasswordUrl; +commonOptions.callbackUrl = drupalSettings.ciam.callback; +commonOptions.hashTemplate = true; +commonOptions.formValidationMessage = true; +commonOptions.messagesList = JSON.parse(drupalSettings.ciam.commonMessages); + +if (drupalSettings.ciam.termsAndConditionHtml) { + commonOptions.termsAndConditionHtml = drupalSettings.ciam.termsAndConditionHtml; +} +if (drupalSettings.ciam.displayPasswordStrength) { + commonOptions.displayPasswordStrength = drupalSettings.ciam.displayPasswordStrength; +} +if (drupalSettings.ciam.askRequiredFieldForTraditionalLogin) { + commonOptions.askRequiredFieldForTraditionalLogin = drupalSettings.ciam.askRequiredFieldForTraditionalLogin; +} +else { + commonOptions.askRequiredFieldForTraditionalLogin = false; +} +if (drupalSettings.ciam.askEmailForUnverifiedProfileAlways) { + commonOptions.askEmailForUnverifiedProfileAlways = drupalSettings.ciam.askEmailForUnverifiedProfileAlways; +} +else { + commonOptions.askEmailForUnverifiedProfileAlways = false; +} +if (drupalSettings.ciam.usernameLogin) { + commonOptions.usernameLogin = drupalSettings.ciam.usernameLogin; +} else { + commonOptions.usernameLogin = false; +} +if (drupalSettings.ciam.promptPasswordOnSocialLogin) { + commonOptions.promptPasswordOnSocialLogin = drupalSettings.ciam.promptPasswordOnSocialLogin; +}else { + commonOptions.promptPasswordOnSocialLogin = false; +} +if(drupalSettings.ciam.instantLinkLogin){ + commonOptions.instantLinkLogin = drupalSettings.ciam.instantLinkLogin; +}else { + commonOptions.instantLinkLogin = false; +} +if(drupalSettings.ciam.instantOTPLogin){ + commonOptions.instantOTPLogin = drupalSettings.ciam.instantOTPLogin; +}else { + commonOptions.instantOTPLogin = false; +} +if (drupalSettings.ciam.existPhoneNumber) { + commonOptions.existPhoneNumber = drupalSettings.ciam.existPhoneNumber; +} +if (drupalSettings.ciam.welcomeEmailTemplate) { + commonOptions.welcomeEmailTemplate = drupalSettings.ciam.welcomeEmailTemplate; +} +if (drupalSettings.ciam.verificationEmailTemplate) { + commonOptions.verificationEmailTemplate = drupalSettings.ciam.verificationEmailTemplate; +} +if (drupalSettings.ciam.resetPasswordEmailTemplate) { + commonOptions.resetPasswordEmailTemplate = drupalSettings.ciam.resetPasswordEmailTemplate; +} +if (drupalSettings.ciam.instantLinkLoginEmailTemplate) { + commonOptions.instantLinkLoginEmailTemplate = drupalSettings.ciam.instantLinkLoginEmailTemplate; +} +if (drupalSettings.ciam.smsTemplateWelcome) { + commonOptions.smsTemplateWelcome = drupalSettings.ciam.smsTemplateWelcome; +} +if (drupalSettings.ciam.smsTemplatePhoneVerification) { + commonOptions.smsTemplatePhoneVerification = drupalSettings.ciam.smsTemplatePhoneVerification; +} +if (drupalSettings.ciam.smsTemplateForgot) { + commonOptions.smsTemplateForgot = drupalSettings.ciam.smsTemplateForgot; +} +if (drupalSettings.ciam.smsTemplateChangePhoneNo) { + commonOptions.smsTemplateUpdatePhone = drupalSettings.ciam.smsTemplateChangePhoneNo; +} +if (drupalSettings.ciam.smsTemplateInstantOTPLogin) { + commonOptions.smsTemplateInstantOTPLogin = drupalSettings.ciam.smsTemplateInstantOTPLogin; +} +if (drupalSettings.ciam.smsTemplate2FA) { + commonOptions.smsTemplate2FA = drupalSettings.ciam.smsTemplate2FA; +} +if (drupalSettings.ciam.debugMode) { + commonOptions.debugMode = drupalSettings.ciam.debugMode; +} +if (drupalSettings.ciam.customScript) { + eval(drupalSettings.ciam.customScript); +} +jQuery(document).ready(function () { + initializeResetPasswordCiamForm(commonOptions); +}); \ No newline at end of file diff --git a/drupal-10/src/customer_identity_and_access_management/lr_ciam/js/ciam_interface.min.js b/drupal-10/src/customer_identity_and_access_management/lr_ciam/js/ciam_interface.min.js new file mode 100644 index 0000000..7e26b51 --- /dev/null +++ b/drupal-10/src/customer_identity_and_access_management/lr_ciam/js/ciam_interface.min.js @@ -0,0 +1 @@ +var commonOptions={},LocalDomain=drupalSettings.ciam.callback,homeDomain=drupalSettings.ciam.home,accessToken=drupalSettings.ciam.accessToken,phoneId=drupalSettings.ciam.phoneId,autoHideTime=drupalSettings.ciam.autoHideTime,loggedIn=drupalSettings.ciam.loggedIn,domainName=drupalSettings.ciam.appPath,registrationSchema=drupalSettings.ciam.registrationSchema;commonOptions.apiKey=drupalSettings.ciam.apiKey,commonOptions.appName=drupalSettings.ciam.appName,commonOptions.appPath=drupalSettings.ciam.appPath,commonOptions.sott=drupalSettings.ciam.sott,commonOptions.verificationUrl=drupalSettings.ciam.verificationUrl,commonOptions.resetPasswordUrl=drupalSettings.ciam.resetPasswordUrl,commonOptions.callbackUrl=drupalSettings.ciam.callback,commonOptions.hashTemplate=!0,commonOptions.formValidationMessage=!0,commonOptions.messagesList=JSON.parse(drupalSettings.ciam.commonMessages),drupalSettings.ciam.termsAndConditionHtml&&(commonOptions.termsAndConditionHtml=drupalSettings.ciam.termsAndConditionHtml),drupalSettings.ciam.displayPasswordStrength&&(commonOptions.displayPasswordStrength=drupalSettings.ciam.displayPasswordStrength),drupalSettings.ciam.askRequiredFieldForTraditionalLogin?commonOptions.askRequiredFieldForTraditionalLogin=drupalSettings.ciam.askRequiredFieldForTraditionalLogin:commonOptions.askRequiredFieldForTraditionalLogin=!1,drupalSettings.ciam.askEmailForUnverifiedProfileAlways?commonOptions.askEmailForUnverifiedProfileAlways=drupalSettings.ciam.askEmailForUnverifiedProfileAlways:commonOptions.askEmailForUnverifiedProfileAlways=!1,drupalSettings.ciam.usernameLogin?commonOptions.usernameLogin=drupalSettings.ciam.usernameLogin:commonOptions.usernameLogin=!1,drupalSettings.ciam.promptPasswordOnSocialLogin?commonOptions.promptPasswordOnSocialLogin=drupalSettings.ciam.promptPasswordOnSocialLogin:commonOptions.promptPasswordOnSocialLogin=!1,drupalSettings.ciam.instantLinkLogin?commonOptions.instantLinkLogin=drupalSettings.ciam.instantLinkLogin:commonOptions.instantLinkLogin=!1,drupalSettings.ciam.instantOTPLogin?commonOptions.instantOTPLogin=drupalSettings.ciam.instantOTPLogin:commonOptions.instantOTPLogin=!1,drupalSettings.ciam.existPhoneNumber&&(commonOptions.existPhoneNumber=drupalSettings.ciam.existPhoneNumber),drupalSettings.ciam.welcomeEmailTemplate&&(commonOptions.welcomeEmailTemplate=drupalSettings.ciam.welcomeEmailTemplate),drupalSettings.ciam.verificationEmailTemplate&&(commonOptions.verificationEmailTemplate=drupalSettings.ciam.verificationEmailTemplate),drupalSettings.ciam.resetPasswordEmailTemplate&&(commonOptions.resetPasswordEmailTemplate=drupalSettings.ciam.resetPasswordEmailTemplate),drupalSettings.ciam.instantLinkLoginEmailTemplate&&(commonOptions.instantLinkLoginEmailTemplate=drupalSettings.ciam.instantLinkLoginEmailTemplate),drupalSettings.ciam.smsTemplateWelcome&&(commonOptions.smsTemplateWelcome=drupalSettings.ciam.smsTemplateWelcome),drupalSettings.ciam.smsTemplatePhoneVerification&&(commonOptions.smsTemplatePhoneVerification=drupalSettings.ciam.smsTemplatePhoneVerification),drupalSettings.ciam.smsTemplateForgot&&(commonOptions.smsTemplateForgot=drupalSettings.ciam.smsTemplateForgot),drupalSettings.ciam.smsTemplateChangePhoneNo&&(commonOptions.smsTemplateUpdatePhone=drupalSettings.ciam.smsTemplateChangePhoneNo),drupalSettings.ciam.smsTemplateInstantOTPLogin&&(commonOptions.smsTemplateInstantOTPLogin=drupalSettings.ciam.smsTemplateInstantOTPLogin),drupalSettings.ciam.smsTemplate2FA&&(commonOptions.smsTemplate2FA=drupalSettings.ciam.smsTemplate2FA),drupalSettings.ciam.debugMode&&(commonOptions.debugMode=drupalSettings.ciam.debugMode),drupalSettings.ciam.customScript&&eval(drupalSettings.ciam.customScript),jQuery(document).ready(function(){initializeResetPasswordCiamForm(commonOptions)}); \ No newline at end of file diff --git a/drupal-10/src/customer_identity_and_access_management/lr_ciam/js/social_interface.js b/drupal-10/src/customer_identity_and_access_management/lr_ciam/js/social_interface.js new file mode 100644 index 0000000..61ef984 --- /dev/null +++ b/drupal-10/src/customer_identity_and_access_management/lr_ciam/js/social_interface.js @@ -0,0 +1,6 @@ +jQuery(document).ready(function () { + if(!(window.location.href.indexOf("admin") > -1)) { + callSocialInterface(); + } +}); + diff --git a/drupal-10/src/customer_identity_and_access_management/lr_ciam/js/user_login.js b/drupal-10/src/customer_identity_and_access_management/lr_ciam/js/user_login.js new file mode 100644 index 0000000..139167a --- /dev/null +++ b/drupal-10/src/customer_identity_and_access_management/lr_ciam/js/user_login.js @@ -0,0 +1,15 @@ +jQuery(document).ready(function () { + if(!(window.location.href.indexOf("admin") > -1)) { + initializeLoginCiamForm(); + initializeSocialRegisterCiamForm(); + var isClear = 1; + var formIntval; + setTimeout(show_birthdate_date_block, 1000); + formIntval = setInterval(function(){ jQuery('#lr-loading').hide(); + if (isClear > 0) { + clearInterval(formIntval); + } + }, 1000); + } +}); + diff --git a/drupal-10/src/customer_identity_and_access_management/lr_ciam/js/user_pass.js b/drupal-10/src/customer_identity_and_access_management/lr_ciam/js/user_pass.js new file mode 100644 index 0000000..60a19da --- /dev/null +++ b/drupal-10/src/customer_identity_and_access_management/lr_ciam/js/user_pass.js @@ -0,0 +1,5 @@ +jQuery(document).ready(function () { + jQuery('#content .tabs').attr('style', 'display:none'); + initializeForgotPasswordCiamForms(); +}); + diff --git a/drupal-10/src/customer_identity_and_access_management/lr_ciam/js/user_register.js b/drupal-10/src/customer_identity_and_access_management/lr_ciam/js/user_register.js new file mode 100644 index 0000000..71467eb --- /dev/null +++ b/drupal-10/src/customer_identity_and_access_management/lr_ciam/js/user_register.js @@ -0,0 +1,15 @@ +jQuery(document).ready(function () { + if(!(window.location.href.indexOf("admin") > -1)) { + initializeRegisterCiamForm(); + initializeSocialRegisterCiamForm(); + var isClear = 1; + var formIntval; + setTimeout(show_birthdate_date_block, 1000); + formIntval = setInterval(function(){ jQuery('#lr-loading').hide(); + if (isClear > 0) { + clearInterval(formIntval); + } + }, 1000); + } +}); + diff --git a/drupal-10/src/customer_identity_and_access_management/lr_ciam/lr_ciam.info.yml b/drupal-10/src/customer_identity_and_access_management/lr_ciam/lr_ciam.info.yml new file mode 100644 index 0000000..bcaaffb --- /dev/null +++ b/drupal-10/src/customer_identity_and_access_management/lr_ciam/lr_ciam.info.yml @@ -0,0 +1,6 @@ +name: CIAM +type: module +description: 'Allow users to sign up through a registration form. User Registration offers fully customized options for collecting and updating user data.' +package: CIAM LoginRadius +configure: lr_ciam.settings_form +core_version_requirement: ^9.4 || ^10 diff --git a/drupal-10/src/customer_identity_and_access_management/lr_ciam/lr_ciam.install b/drupal-10/src/customer_identity_and_access_management/lr_ciam/lr_ciam.install new file mode 100644 index 0000000..58c3f9b --- /dev/null +++ b/drupal-10/src/customer_identity_and_access_management/lr_ciam/lr_ciam.install @@ -0,0 +1,79 @@ +moduleExists('sociallogin')) { + $requirements['ciam'] = [ + 'description' => 'Please Uninstall "User Registration and Management" Plugin to Activate LoginRadius CIAM.', + 'severity' => REQUIREMENT_ERROR, + ]; + } + if (!class_exists('\LoginRadiusSDK\Utility\Functions')) { + $requirements['lr_ciam'] = [ + 'description' => t('Ciam requires LoginRadius PHP SDK V2 library. Make sure the library is installed. Check README.txt for installation instructions.'), + 'severity' => REQUIREMENT_ERROR, + ]; + } + } + return $requirements; +} + +/** + * Implements hook_schema(). + */ +function lr_ciam_schema() { + $schema = []; + if (!Database::getConnection()->schema()->fieldExists('users', 'lr_ciam_uid')) { + !Database::getConnection()->schema()->addField('users', 'lr_ciam_uid', [ + 'type' => 'varchar', + 'length' => 255, + 'not null' => FALSE, + 'default' => '', + ]); + } + if (!Database::getConnection()->schema()->tableExists('loginradius_mapusers')) { + $schema['loginradius_mapusers'] = [ + 'description' => 'Stores Engage linked account information.', + 'fields' => [ + 'user_id' => [ + 'type' => 'int', + 'unsigned' => TRUE, + 'not null' => TRUE, + 'description' => 'User ID of the user table.', + ], + 'provider' => [ + 'type' => 'varchar', + 'length' => 30, + 'not null' => TRUE, + 'description' => 'The provider\'s machine name.', + ], + 'provider_id' => [ + 'type' => 'varchar', + 'length' => 255, + 'not null' => TRUE, + 'description' => 'The provider\'s unique id.', + ], + ], + ]; + } + return $schema; +} + +/** + * Implements hook_install(). + */ +function lr_ciam_install() { + module_set_weight('lr_ciam', 4); +} diff --git a/drupal-10/src/customer_identity_and_access_management/lr_ciam/lr_ciam.libraries.yml b/drupal-10/src/customer_identity_and_access_management/lr_ciam/lr_ciam.libraries.yml new file mode 100644 index 0000000..4263f89 --- /dev/null +++ b/drupal-10/src/customer_identity_and_access_management/lr_ciam/lr_ciam.libraries.yml @@ -0,0 +1,62 @@ +drupal.loading: + version: VERSION + css: + component: + css/lr_loading.min.css: {} + +drupal.ciam_email_popup: + version: VERSION + css: + component: + css/login_frontend.min.css: {} + +drupal.user_login: + version: VERSION + js: + js/user_login.js: {} + +drupal.user_register: + version: VERSION + js: + js/user_register.js: {} + +drupal.user_pass: + version: VERSION + js: + js/user_pass.js: {} + +drupal.account_linking: + version: VERSION + js: + js/account_linking.js: {} + +drupal.social_interface: + version: VERSION + js: + js/social_interface.js: {} + +drupal.ciam_custom: + version: VERSION + js: + js/ciam_custom.js: {} + +drupal.ciam_admin: + version: VERSION + js: + js/ciam_admin.js: {} + +drupal.ciam_core: + header: true + version: VERSION + css: + component: + css/ciam.min.css: {} + js: + //auth.lrcontent.com/v2/js/LoginRadiusV2.js: { weight: -10 } + js/ciam_interface.min.js: { weight: -10 } + js/LoginRadiusFrontEnd.min.js: { weight: -10 } + + dependencies: + - core/jquery + - core/drupalSettings + - core/jquery.ui.datepicker diff --git a/drupal-10/src/customer_identity_and_access_management/lr_ciam/lr_ciam.links.menu.yml b/drupal-10/src/customer_identity_and_access_management/lr_ciam/lr_ciam.links.menu.yml new file mode 100644 index 0000000..444a7ab --- /dev/null +++ b/drupal-10/src/customer_identity_and_access_management/lr_ciam/lr_ciam.links.menu.yml @@ -0,0 +1,6 @@ +lr_ciam.settings_form: + title: LoginRadius + description: 'Configure settings for LoginRadius' + route_name: lr_ciam.settings_form + parent: user.admin_index + \ No newline at end of file diff --git a/drupal-10/src/customer_identity_and_access_management/lr_ciam/lr_ciam.links.task.yml b/drupal-10/src/customer_identity_and_access_management/lr_ciam/lr_ciam.links.task.yml new file mode 100644 index 0000000..bae59ed --- /dev/null +++ b/drupal-10/src/customer_identity_and_access_management/lr_ciam/lr_ciam.links.task.yml @@ -0,0 +1,21 @@ +lr_ciam.change_password: + route_name: lr_ciam.change_password + title: 'Password' + base_route: entity.user.canonical + weight: 2 + +lr_ciam.settings_form: + route_name: lr_ciam.settings_form + title: 'Activation' + base_route: lr_ciam.settings_form + +authentication.settings_form: + route_name: authentication.settings_form + title: 'Authentication' + base_route: lr_ciam.settings_form + +advanced.settings_form: + route_name: advanced.settings_form + title: 'Advanced Settings' + base_route: lr_ciam.settings_form + \ No newline at end of file diff --git a/drupal-10/src/customer_identity_and_access_management/lr_ciam/lr_ciam.module b/drupal-10/src/customer_identity_and_access_management/lr_ciam/lr_ciam.module new file mode 100644 index 0000000..54eef01 --- /dev/null +++ b/drupal-10/src/customer_identity_and_access_management/lr_ciam/lr_ciam.module @@ -0,0 +1,1381 @@ +get('api_key')); +$api_secret = trim($config->get('api_secret')); +$api_request_signing = $config->get('api_request_signing'); + +if($api_key != ''){ +define('LR_API_KEY', $api_key); +} +if($api_secret != ''){ +$decrypted_secret_key = encrypt_and_decrypt( $api_secret, $api_key, $api_key, 'd' ); +define('LR_API_SECRET', $decrypted_secret_key); +} + +if($api_request_signing == 'true') { + define('API_REQUEST_SIGNING', true); +} +define('API_CONFIG_DOMAIN', 'https://config.lrcontent.com'); + + + /** + * Encrypt and decrypt + * + * @param string $string string to be encrypted/decrypted + * @param string $action what to do with this? e for encrypt, d for decrypt + */ + + function encrypt_and_decrypt( $string, $secretKey, $secretIv, $action) { + // you may change these values to your own + $secret_key = $secretKey; + $secret_iv = $secretIv; + $output = false; + $encrypt_method = "AES-256-CBC"; + $key = hash( 'sha256', $secret_key ); + $iv = substr( hash( 'sha256', $secret_iv ), 0, 16 ); + if( $action == 'e' ) { + $output = base64_encode( openssl_encrypt( $string, $encrypt_method, $key, 0, $iv ) ); + } + else if( $action == 'd' ){ + $output = openssl_decrypt( base64_decode( $string ), $encrypt_method, $key, 0, $iv ); + } + return $output; + } + +/** + * Implements hook_theme(). + */ +function lr_ciam_theme() { + $path = \Drupal::service('extension.list.module')->getPath('lr_ciam') . '/theme'; + $theme = [ + 'user_login_form' => [ + 'template' => 'user_login_form', + 'render element' => 'form', + 'path' => $path, + ], + 'user_login' => [ + 'template' => 'user_login', + 'render element' => 'form', + 'path' => $path, + ], + 'user_register' => [ + 'template' => 'user_register', + 'render element' => 'form', + 'path' => $path, + ], + 'user_register_form' => [ + 'template' => 'user_register_form', + 'render element' => 'form', + 'path' => $path, + ], + 'set_password' => [ + 'template' => 'set_password', + 'render element' => 'form', + 'path' => $path, + ], + 'change_password' => [ + 'variables' => [ + 'params' => NULL, + ], + 'template' => 'change_password', + 'path' => $path, + ], + '2fa_container' => [ + 'variables' => [ + 'params' => NULL, + ], + 'template' => '2fa_container', + 'path' => $path, + ], + 'lr_profile_editor' => [ + 'variables' => [ + 'params' => NULL, + ], + 'template' => 'lr_profile_editor', + 'path' => $path, + ], + 'lr_update_phone' => [ + 'variables' => [ + 'params' => NULL, + ], + 'template' => 'lr_update_phone', + 'path' => $path, + ], + 'lr_backup_codes' => [ + 'variables' => [ + 'params' => NULL, + ], + 'template' => 'lr_backup_codes', + 'path' => $path, + ], + 'remove_email' => [ + 'variables' => [ + 'params' => NULL, + ], + 'template' => 'remove_email', + 'path' => $path, + ], + 'add_email' => [ + 'variables' => [ + 'params' => NULL, + ], + 'template' => 'add_email', + 'path' => $path, + ], + 'user_pass_form' => [ + 'template' => 'user_pass_form', + 'render element' => 'form', + 'path' => $path, + ], + 'user_pass' => [ + 'template' => 'user_pass', + 'render element' => 'form', + 'path' => $path, + ], + 'ciam_social_widget_container' => [ + 'variables' => [ + 'params' => NULL, + ], + 'template' => 'ciam_social_widget_container', + 'path' => $path, + ], + 'lr_ciam_linked' => [ + 'variables' => [ + 'params' => NULL, + ], + 'template' => 'lr_ciam_linked', + 'path' => $path, + ], + 'lr_ciam_popup' => [ + 'variables' => [ + 'params' => NULL, + ], + 'template' => 'lr_ciam_popup', + 'path' => $path, + ], + 'lr_loading' => [ + 'template' => 'lr_loading', + 'variables' => [ + 'params' => NULL, + ], + 'path' => $path, + ], + 'lr_message' => [ + 'template' => 'lr_message', + 'variables' => [ + 'params' => NULL, + ], + 'path' => $path, + ], + ]; + return $theme; +} + +/** + * Added Required variable to use in template fie. + * + * @param array $vars + */ +function template_preprocess_lr_ciam_linked(&$vars) { + global $base_url; + $vars['image_url'] = $base_url . '/' . \Drupal::service('extension.list.module')->getPath('lr_ciam') . '/images'; + $vars['callback'] = lr_ciam_get_callback_url(); +} + +/** + * Show and hide user pass form block. + */ +function template_preprocess_user_pass(&$variables) { + $config = \Drupal::config('lr_ciam.settings'); + $variables['api_key'] = trim($config->get('api_key')); + + $blocks = Block::loadMultiple(); + foreach ($blocks as $key => $block) { + $settings = $block->get('settings'); + if ($key == 'userforgotpasswordblock') { + $block_settings = []; + $block_settings = $settings; + } + } + $variables['link_login'] = isset($block_settings['forgot_block_link_login']) ? $block_settings['forgot_block_link_login'] : ''; + $variables['link_register'] = isset($block_settings['forgot_block_link_register']) ? $block_settings['forgot_block_link_register'] : ''; + if (!\Drupal::currentUser()->isAnonymous()) { + $variables['showpassonlogin'] = FALSE; + } + else { + $variables['showpassonlogin'] = TRUE; + } +} + +/** + * Show and hide user pass form. + * + * @param variables $array + */ +function template_preprocess_user_pass_form(&$variables) { + $config = \Drupal::config('lr_ciam.settings'); + $variables['api_key'] = trim($config->get('api_key')); + if (!\Drupal::currentUser()->isAnonymous()) { + $variables['showpassonlogin'] = FALSE; + $variables['rendered'] = \Drupal::service('renderer')->render($variables['form']); + } + else { + $variables['showpassonlogin'] = TRUE; + } +} + +/** + * Implements hook_form_FORM_ID_alter(). + */ +function lr_ciam_form_user_pass_form_alter(&$form, FormStateInterface $form_state) { + if (!\Drupal::currentUser()->isAnonymous()) { + $user = \Drupal::currentUser(); + $form['name']['#type'] = 'value'; + $form['name']['#value'] = $user->getEmail(); + $form['mail'] = [ + '#prefix' => '

', + '#markup' => t('Password reset instructions will be mailed to %email. You must log out to use the password reset link in the email.', ['%email' => $user->getEmail()]), + '#suffix' => '

', + ]; + + $form['actions'] = ['#type' => 'actions']; + $form['actions']['submit'] = ['#type' => 'submit', '#value' => t('Submit')]; + $form['#cache']['contexts'][] = 'url.query_args'; + return $form; + } +} + +/** + * Add variable to register form. + * + * @param array $variables + */ +function template_preprocess_user_register_form(&$variables) { + $variables['admin_access'] = TRUE; + $user = \Drupal::currentUser()->getRoles(); + + if (in_array("administrator", $user)) { + $variables['admin_access'] = FALSE; + } + + $config = \Drupal::config('lr_ciam.settings'); + $variables['api_key'] = trim($config->get('api_key')); + $variables['rendered'] = \Drupal::service('renderer')->render($variables['form']); +} + +/** + * Add variable to user register form block. + * + * @param array $variables + */ +function template_preprocess_user_register(&$variables) { + $variables['admin_access'] = TRUE; + $user = \Drupal::currentUser()->getRoles(); + if (in_array("administrator", $user)) { + $variables['admin_access'] = FALSE; + } + $config = \Drupal::config('lr_ciam.settings'); + $blocks = Block::loadMultiple(); + foreach ($blocks as $key => $block) { + $settings = $block->get('settings'); + if ($key == 'userregisterblock') { + $block_settings = []; + $block_settings = $settings; + } + } + + $variables['link_login'] = isset($block_settings['register_block_link_login']) ? $block_settings['register_block_link_login'] : ''; + $variables['link_forgot'] = isset($block_settings['register_block_link_forgot']) ? $block_settings['register_block_link_forgot'] : ''; + $variables['api_key'] = trim($config->get('api_key')); + $variables['rendered'] = \Drupal::service('renderer')->render($variables['form']); +} + +/** + * Add variable to user login form. + * + * @param array $variables + */ +function template_preprocess_user_login_form(&$variables) { + $config = \Drupal::config('lr_ciam.settings'); + $variables['api_key'] = trim($config->get('api_key')); +} + +/** + * Add variable to user login form block. + * + * @param $variables + */ +function template_preprocess_user_login(&$variables) { + $config = \Drupal::config('lr_ciam.settings'); + $blocks = Block::loadMultiple(); + foreach ($blocks as $key => $block) { + $settings = $block->get('settings'); + if ($key == 'userloginblock') { + $block_settings = []; + $block_settings = $settings; + } + } + + $variables['api_key'] = trim($config->get('api_key')); + $variables['link_register'] = isset($block_settings['login_block_link_register']) ? $block_settings['login_block_link_register'] : ''; + $variables['link_forgot'] = isset($block_settings['login_block_link_forgot']) ? $block_settings['login_block_link_forgot'] : ''; +} + +/** + * Get provider name. + * + * @param object $userprofile + * @param string $token + */ +function lr_ciam_add_loginradius_userdata($userprofile, $token) { + $provider = isset($userprofile->Provider) ? $userprofile->Provider : ''; + \Drupal::service('session')->set('provider', $provider); +} + +/** + * Implements hook_page_attachment(). + */ +function lr_ciam_page_attachments(&$page) { + + $config = \Drupal::config('lr_ciam.settings'); + $emailVerificationUrl = Url::fromRoute('')->setAbsolute()->toString(); + $resetPasswordUrl = Url::fromRoute('user.login')->setAbsolute()->toString(); + + if (isset($_COOKIE['lr_message']) && $_COOKIE['lr_message'] != '') { + $sec = $config->get('ciam_notification_timeout_setting'); + $refresh_sec = (isset($sec) && $sec != '' && $sec != '0') ? $sec : '5'; + $resStatus = \Drupal::request()->query->get('lrresponse'); + + $message = isset($_COOKIE['lr_message']) ? $_COOKIE['lr_message'] : ''; + $response = (isset($resStatus) && $resStatus != 'true') ? "error" : "success"; + setcookie("lr_message", "", time() - 3600, "/"); + if ($message != "") { + if ($response == 'error') { + \Drupal::messenger()->addError($message); + } + else { + \Drupal::messenger()->addStatus($message); + } + } + if ($refresh_sec != '' && $refresh_sec != '0') { + header("refresh:5;url=".$resetPasswordUrl); + } + } + + $route_name = \Drupal::routeMatch()->getRouteName(); + $anonymous = \Drupal::currentUser()->isAnonymous(); + $admin_route = \Drupal::service('router.admin_context')->isAdminRoute(); + + $email_verify_route = ($route_name == 'view.frontpage.page_1'); + $login_route = ($route_name == 'user.login'); + $register_route = ($route_name == 'user.register'); + $forgot_password = ($route_name == 'user.pass'); + $logout_route = ($route_name == 'system.403'); + + $path = parse_url(Url::fromRoute('')->toString()); + $sso_path = $path['path']; + $loggedIn = FALSE; + if (\Drupal::currentUser()->isAuthenticated()) { + $loggedIn = TRUE; + } + + // Don't load page attachments on admin pages. + if(!$loggedIn) { + if ($admin_route || ($anonymous && !($email_verify_route || $login_route || $register_route || $forgot_password || $logout_route))) { + return; + } + } else { + $user = \Drupal::currentUser()->getRoles(); + if (in_array("administrator", $user)) { + $page['#attached']['library'][] = 'lr_ciam/drupal.ciam_admin'; + } + } + + $access_token = []; + $lrPhoneId = []; + if (!$anonymous && $session = \Drupal::service('session')) { + $access_token = $session->get('access_token', []); + $lrPhoneId = $session->get('user_profile_phoneId', []); + } + + $my_settings = [ + 'verificationUrl' => $emailVerificationUrl, + 'resetPasswordUrl' => $resetPasswordUrl, + 'loggedIn' => $loggedIn, + 'accessToken' => isset($access_token) ? $access_token : '', + 'phoneId' => isset($lrPhoneId) ? $lrPhoneId : '', + 'appName' => trim($config->get('sso_site_name')), + 'apiKey' => trim($config->get('api_key')), + 'autoHideTime' => trim($config->get('ciam_notification_timeout_setting')), + 'appPath' => trim($sso_path), + 'callback' => urldecode(lr_ciam_get_callback_url()), + 'home' => Url::fromRoute('')->setAbsolute()->toString(), + ]; + + if ($config->get('ciam_terms_and_condition_html') != '') { + $string = $config->get('ciam_terms_and_condition_html'); + $string = str_replace(array(''), '', $string['value']); + $string = trim(str_replace('"', "'", $string)); + $terms = str_replace(array("\r\n", "\r", "\n"), " ", $string); + $my_settings['termsAndConditionHtml'] = trim($terms); + } + if ($config->get('ciam_ask_required_fields_on_traditional_login') != '' && $config->get('ciam_ask_required_fields_on_traditional_login') != 'false') { + $my_settings['askRequiredFieldForTraditionalLogin'] = (boolean) $config->get('ciam_ask_required_fields_on_traditional_login'); + } + if ($config->get('ciam_display_password_strength') != '' && $config->get('ciam_display_password_strength') != 'false') { + $my_settings['displayPasswordStrength'] = (boolean) $config->get('ciam_display_password_strength'); + } + if ($config->get('ciam_ask_email_for_unverified_user_login') != '' && $config->get('ciam_ask_email_for_unverified_user_login') != 'false') { + $my_settings['askEmailForUnverifiedProfileAlways'] = (boolean) $config->get('ciam_ask_email_for_unverified_user_login'); + } + if ($config->get('ciam_user_name_login') != '' && $config->get('ciam_user_name_login') != 'false') { + $my_settings['usernameLogin'] = (boolean) $config->get('ciam_user_name_login'); + } + if ($config->get('ciam_prompt_password_on_social_login') != '' && $config->get('ciam_prompt_password_on_social_login') != 'false') { + $my_settings['promptPasswordOnSocialLogin'] = (boolean) $config->get('ciam_prompt_password_on_social_login'); + } + if ($config->get('ciam_welcome_email_template') != '') { + $my_settings['welcomeEmailTemplate'] = $config->get('ciam_welcome_email_template'); + } + if ($config->get('ciam_email_verification_template') != '') { + $my_settings['verificationEmailTemplate'] = $config->get('ciam_email_verification_template'); + } + if ($config->get('ciam_reset_password_email_template') != '') { + $my_settings['resetPasswordEmailTemplate'] = $config->get('ciam_reset_password_email_template'); + } + if ($config->get('ciam_sms_template_2fa') != '') { + $my_settings['smsTemplate2FA'] = $config->get('ciam_sms_template_2fa'); + } + + $configSettings = lr_ciam_get_config_option(); + if ($configSettings->IsPhoneLogin === true) { + if ($config->get('ciam_check_phone_no_availability') != '' && $config->get('ciam_check_phone_no_availability') != 'false') { + $my_settings['existPhoneNumber'] = (boolean) $config->get('ciam_check_phone_no_availability'); + } + if ($config->get('ciam_welcome_sms_template') != '') { + $my_settings['smsTemplateWelcome'] = $config->get('ciam_welcome_sms_template'); + } + if ($config->get('ciam_sms_template_phone_verification') != '') { + $my_settings['smsTemplatePhoneVerification'] = $config->get('ciam_sms_template_phone_verification'); + } + if ($config->get('ciam_sms_template_reset_password') != '') { + $my_settings['smsTemplateForgot'] = $config->get('ciam_sms_template_reset_password'); + } + if ($config->get('ciam_sms_template_change_phone_no') != '') { + $my_settings['smsTemplateChangePhoneNo'] = $config->get('ciam_sms_template_change_phone_no'); + } + if ($config->get('ciam_instant_otp_login') != '' && $config->get('ciam_instant_otp_login') != 'false') { + $my_settings['instantOTPLogin'] = (boolean) $config->get('ciam_instant_otp_login'); + } + if ($config->get('ciam_sms_template_one_time_passcode') != '') { + $my_settings['smsTemplateInstantOTPLogin'] = $config->get('ciam_sms_template_one_time_passcode'); + } + } + + + $sott = ''; + if ($register_route) { + $sott = lr_ciam_get_sott($config->get('api_key')); + } + $my_settings['sott'] = $sott; + + + $error_level = ''; + $error_level = \Drupal::config('system.logging')->get('error_level'); + if ($error_level == 'all' || $error_level == 'verbose') { + $my_settings['debugMode'] = true; + } + if ($config->get('ciam_instant_link_login') != '' && $config->get('ciam_instant_link_login') != 'false') { + $my_settings['instantLinkLogin'] = (boolean) $config->get('ciam_instant_link_login'); + } + if ($config->get('ciam_instant_link_login_email_template') != '') { + $my_settings['instantLinkLoginEmailTemplate'] = $config->get('ciam_instant_link_login_email_template'); + } + if ($config->get('ciam_registation_form_schema') != '') { + $my_settings['registrationSchema'] = json_decode($config->get('ciam_registation_form_schema')); + } + + $my_settings['commonMessages'] = '{ + "SOCIAL_LOGIN_MSG": "'.SOCIAL_LOGIN_MSG.'", + "LOGIN_BY_EMAIL_MSG": "'.LOGIN_BY_EMAIL_MSG.'", + "REGISTRATION_SUCCESS_MSG": "'.REGISTRATION_SUCCESS_MSG.'", + "FORGOT_PASSWORD_MSG": "'.FORGOT_PASSWORD_MSG.'", + "VERIFICATION_OTP_SEND_ON_EMAIL_MSG": "'.VERIFICATION_OTP_SEND_ON_EMAIL_MSG.'", + "FORGOT_PASSWORD_SUCCESS_MSG": "'.FORGOT_PASSWORD_SUCCESS_MSG.'", + "TWO_FA_ENABLED_MSG": "'.TWO_FA_ENABLED_MSG.'", + "TWO_FA_DISABLED_MSG": "'.TWO_FA_DISABLED_MSG.'", + "OTP_SEND_ON_PHONE_SUCCESS_MSG": "'.OTP_SEND_ON_PHONE_SUCCESS_MSG.'", + "UPDATE_PHONE_SUCCESS_MSG": "'.UPDATE_PHONE_SUCCESS_MSG.'", + "EMAIL_VERIFICATION_SUCCESS_MSG": "'.EMAIL_VERIFICATION_SUCCESS_MSG.'", + "CHANGE_PASSWORD_SUCCESS_MSG": "'.CHANGE_PASSWORD_SUCCESS_MSG.'", + "ACCOUNT_LINKING_MSG": "'.ACCOUNT_LINKING_MSG.'", + "ACCOUNT_UNLINKING_MSG": "'.ACCOUNT_UNLINKING_MSG.'", + "ADD_EMAIL_MSG": "'.ADD_EMAIL_MSG.'", + "REMOVE_EMAIL_MSG": "'.REMOVE_EMAIL_MSG.'", + "UPDATE_USER_PROFILE": "'.UPDATE_USER_PROFILE.'" + }'; + + if ($config->get('ciam_custom_options') != '') { + $my_settings['customScript'] = ""; + $jsondata = lr_ciam_json_validate($config->get('ciam_custom_options')); + if (is_object($jsondata)) { + foreach ($jsondata as $key => $value) { + $my_settings['customScript'] .= "commonOptions." . $key . "="; + if (is_object($value) || is_array($value)) { + $encodedStr = json_encode($value); + $my_settings['customScript'] .= $encodedStr . ';'; + } + else { + $my_settings['customScript'] .= '"' . $value . '"' . ';'; + } + } + } + else { + if (is_string($jsondata)) { + $my_settings['customScript'] = $jsondata; + } + } + } + + + $page['#attached']['drupalSettings']['ciam'] = $my_settings; + $page['#attached']['library'][] = 'lr_ciam/drupal.ciam_core'; + + if($loggedIn === TRUE){ + $user = \Drupal::currentUser(); + $current_alias = \Drupal::service('path.current')->getPath(); + if ($current_alias == '/user/' . $user->id() || $current_alias == '/user/' . $user->id() . '/edit' || $current_alias == '/user/' . $user->id() . '/changepassword') { + $page['#attached']['library'][] = 'lr_ciam/drupal.ciam_custom'; + } + } +} + +/** + * Generate SOTT. + * + * @param $apiKey + * + * @return json|string + */ +function lr_ciam_get_sott($apiKey) { + if (isset($apiKey) && $apiKey != '') { + + \Drupal::service('page_cache_kill_switch')->trigger(); + + try { + $sottObject = new SottAPI(); + $result = $sottObject->generateSOTT('20'); + return isset($result->Sott) ? $result->Sott : ''; + } + catch (LoginRadiusException $e) { + \Drupal::logger('ciam')->error($e); + } + } +} + +/** + * Check String is json or not. + * + * @param $string + * + * @return json|string + */ +function lr_ciam_json_validate($string) { + $result = json_decode(str_replace("'", '"', $string)); + if (json_last_error() == JSON_ERROR_NONE) { + return $result; + } + else { + return $string; + } +} + +/** + * Implements hook_mail(). + */ +function lr_ciam_mail($key, &$message, $params) { + $data['user'] = $params['account']; + $options['langcode'] = $message['langcode']; + $variables = [ + '@site' => \Drupal::config('system.site') + ->get('name'), + '@username' => $data['user'] + ->getDisplayName(), + ]; + user_mail_tokens($variables, $data, $options); + switch ($key) { + case 'welcome_email': + $message['subject'] = t('Thank you for registering at @site', $variables, $options); + $message['body'][] = t("Thank you for registering at @site. + +You will be able to login in the future using + +Username : @username +Password : @pass + +-- [site:name] team", $variables, $options); + break; + } +} + +/** + * Get Callback Url For Social Login Interface. + * + * @return string + */ +function lr_ciam_get_callback_url() { + global $base_url; + $destination = (\Drupal::destination()->getAsArray()); + $callback = $destination['destination']; + \Drupal::service('page_cache_kill_switch')->trigger(); + if (strpos($callback, 'ajax') !== FALSE) { + $callback = Url::fromRoute('user'); + } + + $url = Url::fromUserInput('/user/ciamlogin', [ + 'query' => ['destination' => $callback], + 'absolute' => TRUE, + ])->toString(); + + $request_uri = \Drupal::request()->getRequestUri(); + if (strpos($request_uri, 'redirect_to') !== FALSE) { + $vid = \Drupal::request()->query->get('redirect_to'); + $url .= "&redirect_to=" . urldecode($vid); + } + $parse_url = parse_url($base_url); + $http_referer = isset($_SERVER["HTTP_REFERER"]) ? $_SERVER["HTTP_REFERER"] : ''; + if (\Drupal::currentUser()->isAuthenticated() && isset($parse_url['host']) && !empty($parse_url['host']) && (strpos($http_referer, $parse_url['host']) !== FALSE)) { + \Drupal::service('session')->set('referer_url', $_SERVER["HTTP_REFERER"]); + } + + return urlencode($url); +} + +/** + * Update user data after save. + * + * @param userid $user + * @param object $userprofile + */ +function lr_ciam_add_user_data_after_save($user, $userprofile) { + $user_manager = \Drupal::service('lr_ciam.user_manager'); + $user_manager->lrCiamUpdateUserTable($userprofile->Uid, $user->id()); +} + + +/** + * Implements hook_user_insert(). + */ +function lr_ciam_user_insert($account) { + $post_value = \Drupal::request()->request->all(); + $user = \Drupal::currentUser()->getRoles(); + if (in_array("administrator", $user)) { + + if (isset($post_value['op']) && $post_value['op'] == 'Create new account') { + $user_manager = \Drupal::service('lr_ciam.user_manager'); + $params = '{ + "Email":[ + { + "Type":"Primary", + "Value":"' . $post_value['mail'] . '" + } + ], + "UserName":"' . $post_value['name'] . '", + "Password":"' . $post_value['pass']['pass1'] . '" + }'; + + $response = $user_manager->lrCiamCreateUser($params); + if (isset($response->Uid) && !empty($response->Uid)) { + + Database::getConnection()->update('users_field_data')->fields([ + 'login' => \Drupal::time()->getRequestTime(), + ]) + ->condition('uid', $account->id()) + ->execute(); + $user_manager->lrCiamUpdateUserTable($response->Uid, $account->id()); + + + if (isset($post_value['notify']) && $post_value['notify'] == '1') { + try { + $forgotVerificationUrl = Url::fromRoute('user.login')->setAbsolute()->toString(); + $result = $user_manager->lrCiamForgotPassword(trim($post_value['mail']), $forgotVerificationUrl); + + if (isset($result->IsPosted) && $result->IsPosted) { + \Drupal::messenger()->addStatus(t('A welcome message with further instructions has been emailed to the new user %name.', [':url' => $account->url(), '%name' => $post_value['name']])); + } + } + catch (LoginRadiusException $e) { + $msg = isset($e->getErrorResponse()->Description) ? $e->getErrorResponse()->Description : 'error'; + \Drupal::messenger()->addError($msg); + $response = new RedirectResponse(Url::fromRoute('')->toString()); + $response->send(); + exit(); + } + } + if (isset($post_value['status']) && $post_value['status'] == "0") { + $user_manager->lrCiamBlockUser($response->Uid); + } + } + } + } +} + +/** + * Implements hook_user_presave(). + */ +function lr_ciam_user_presave($account) { + $post_value = \Drupal::request()->request->all(); + $user_manager = \Drupal::service('lr_ciam.user_manager'); + $ciam_uid = $user_manager->lrCiamGetCiamUid($account->id()); + $ciam_uname = $user_manager->lrCiamGetCiamUname($account->id()); + + if (isset($post_value['op']) && $post_value['op'] == 'Save') { + if (isset($post_value['form_id']) && $post_value['form_id'] == 'user_form') { + if (isset($post_value['name']) && $post_value['name'] != '') { + + if ($ciam_uname != $post_value['name']) { + $params = '{ + "UserName":"' . $post_value['name'] . '" + }'; + try { + $accountObject = new AccountAPI(); + $accountObject->updateAccountByUid($params, $ciam_uid); + } + catch (LoginRadiusException $e) { + $msg = isset($e->getErrorResponse()->Description) ? $e->getErrorResponse()->Description : 'error'; + \Drupal::messenger()->addError($msg); + $response = new RedirectResponse(Url::fromRoute('')->toString()); + $response->send(); + exit(); + } + } + } + } + } +} + +/** + * Implements hook_user_update(). + */ +function lr_ciam_user_update($account) { + $post_value = \Drupal::request()->request->all(); + $config = \Drupal::config('lr_ciam.settings'); + + $user_manager = \Drupal::service('lr_ciam.user_manager'); + $ciam_uid = $user_manager->lrCiamGetCiamUid($account->id()); + $field_defaults = $config->get('user_fields', []); + if (isset($post_value['op']) && $post_value['op'] == 'Save') { + $output = []; + + if (!empty($field_defaults)) { + foreach ($field_defaults as $key => $value) { + if ($value == 'BirthDate') { + $output[$value] = isset($post_value[$key][0]["value"]['date']) ? $post_value[$key][0]["value"]['date'] : ''; + $sldate = explode('-', $output[$value]); + $year = isset($sldate[0]) ? trim($sldate[0]) : ''; + $month = isset($sldate[1]) ? trim($sldate[1]) : ''; + $date = isset($sldate[2]) ? trim($sldate[2]) : ''; + $formatDate = trim($month . '-' . $date . '-' . $year); + $output[$value] = $formatDate; + } + else { + $output[$value] = isset($post_value[$key][0]["value"]) ? $post_value[$key][0]["value"] : ''; + } + } + } + + try { + $accountObject = new AccountAPI(); + $accountObject->updateAccountByUid($output, $ciam_uid); + } + catch (LoginRadiusException $e) { + + } + + if (isset($post_value['status'])) { + if ($post_value['status'] == "0" && isset($ciam_uid) && !empty($ciam_uid)) { + $user_manager->lrCiamBlockUser($ciam_uid); + } + else { + $user_manager->lrCiamUnblockUser($ciam_uid); + } + } + if (isset($post_value['pass']['pass1']) && !empty($post_value['pass']['pass1'])) { + $user = \Drupal::currentUser()->getRoles(); + if (in_array("administrator", $user)) { + if (empty($ciam_uid)) { + $params = '{ + "Email":[ + { + "Type":"Primary", + "Value":"' . $account->getEmail() . '" + } + ], + "UserName":"' . $account->getUsername() . '", + "Password":"' . $post_value['pass']['pass1'] . '" + }'; + $user_manager->lrCiamCreateUser($params); + return; + } + else { + $user_manager->lrCiamSetPassword($ciam_uid, $post_value['pass']['pass1']); + } + } + } + } + elseif (isset($post_value['op']) && $post_value['op'] == 'Apply' && isset($ciam_uid) && !empty($ciam_uid)) { + + if (isset($post_value['action']) && $post_value['action'] == 'user_block_user_action') { + $user_manager->lrCiamBlockUser($ciam_uid); + } + elseif (isset($post_value['action']) && $post_value['action'] == 'user_unblock_user_action') { + $user_manager->lrCiamUnblockUser($ciam_uid); + } + } +} + +/** + * Implements hook_ENTITY_TYPE_view_alter() for user entities. + */ +function lr_ciam_user_view_alter(array &$build, UserInterface $account, EntityViewDisplayInterface $display) { + $user = \Drupal::currentUser()->getRoles(); + if (!in_array("administrator", $user) && !\Drupal::currentUser()->isAnonymous()) { + $accountObject = new AccountAPI(); + $userProfileUid = \Drupal::service('session')->get('user_profile_uid', []); + + if(!empty($userProfileUid)){ + try { + $userprofile = $accountObject->getAccountProfileByUid($userProfileUid); + } + catch (LoginRadiusException $e) { + \Drupal::logger('ciam')->error($e); + } + } + + $config = \Drupal::config('lr_ciam.settings'); + $user_manager = \Drupal::service('lr_ciam.user_manager'); + + $field_map = $config->get('user_fields'); + $field_convert_info = $user_manager->fieldFieldConvertInfo(); + + $entity_type = 'user'; + $instances = []; + foreach (\Drupal::service('entity_field.manager') + ->getFieldDefinitions($entity_type, 'user') as $field_name => $field_definition) { + $user_bundle = $field_definition->getTargetBundle(); + + if (!empty($user_bundle)) { + $instances[$field_name]['type'] = $field_definition->getType(); + $instances[$field_name]['label'] = $field_definition->getLabel(); + } + } + + foreach ($instances as $field_name => $instance) { + $field = FieldStorageConfig::loadByName($entity_type, $field_name); + + if (isset($field_map[$field_name]) && isset($field_convert_info[$field->getType()]['callback'])) { + $callback = $field_convert_info[$field->getType()]['callback']; + $field_property_name = $field_map[$field_name]; + + if($field_property_name == "PhoneID"){ + $field_property_name = "PhoneId"; + } + + + if ($value = $user_manager->$callback($field_property_name, $userprofile, $field, $instance)) { + + if (False) { + $drupal_user_ref[$field_name]['widget']['0']['value']['#default_value'] = isset($value['value']) ? $value['value'] : $value; + } + else { + + $field = explode("field_", $field_name); + $fieldarray = explode("_", $field[1]); + + if(is_array($fieldarray)) { + $fieldName = (isset($fieldarray[0]) ? $fieldarray[0] : '') .''.(isset($fieldarray[1]) ? $fieldarray[1] : ''); + $build[$fieldName] = [ + '#type' => 'item', + '#markup' => '

' . t(ucfirst($fieldName)) . '

'.$value['value'], + ]; + } + } + } + } + } + } +} + +/** + * Implements hook_form_FORM_ID_alter(). + */ +function lr_ciam_form_user_form_alter(&$form, FormStateInterface $form_state) { + $config = \Drupal::config('lr_ciam.settings'); + $user = \Drupal::currentUser()->getRoles(); + +if (!in_array("administrator", $user) && !\Drupal::currentUser()->isAnonymous()) { + unset($form['#validate'][1]); + unset($form['account']['pass']); + unset($form['account']['current_pass']); + $form['account']['mail']['#disabled'] = TRUE; + + $socialObject = new SocialAPI(); + $accountObject = new AccountAPI(); + $mfaObject = new MultiFactorAuthenticationAPI(); + + try { + $res = $socialObject->validateAccessToken(trim(\Drupal::service('session')->get('access_token', ''))); + + if (isset($res->errorCode) && $res->errorCode == '906') { + $domain = Url::fromRoute('')->setAbsolute()->toString(); + $redirectUrl = $domain . 'user/logout'; + $response = new TrustedRedirectResponse($redirectUrl); + \Drupal::logger('ciam')->error($res->description); + return $response->send(); + } + } + catch (LoginRadiusException $e) { + $domain = Url::fromRoute('')->setAbsolute()->toString(); + $redirectUrl = $domain . 'user/logout'; + $response = new TrustedRedirectResponse($redirectUrl); + \Drupal::logger('ciam')->error($e); + return $response->send(); + } + $userProfileUid = \Drupal::service('session')->get('user_profile_uid', []); + try { + $result = $accountObject->getAccountProfileByUid($userProfileUid); + } + catch (LoginRadiusException $e) { + \Drupal::logger('ciam')->error($e); + } + + if (isset($_COOKIE['lr_profile_update']) && $_COOKIE['lr_profile_update'] != '') { + + $user_manager = \Drupal::service('lr_ciam.user_manager'); + $uid = $user_manager->checkProviderId($result->ID); + $user_name = $user_manager->getUserNameOnUpdateProfile($result); + $ciam_save_username_in_db = $config->get('ciam_save_name_in_db'); + + if ($form['account']['name']['#default_value'] != $user_name['username']) { + try { + \Drupal::database()->update('users_field_data') + ->fields(['name' => ($ciam_save_username_in_db == 'false') ? $result->ID : $user_name['username']]) + ->condition('uid', $uid) + ->execute(); + } + catch (Exception $e) { + \Drupal::logger('ciam')->error($e); + } + } + + setcookie("lr_profile_update", "", time() - 3600, "/"); + + $uid = $user_manager->checkProviderId($result->ID); + $user_manager->fieldUpdateUserObject($uid, $result); + } + + $ciam_save_mail_in_db = $config->get('ciam_save_mail_in_db'); + $defaultEmail = isset($result->Email) ? $result->Email[0]->Value : ''; + if ($ciam_save_mail_in_db == 'true' && isset($defaultEmail) && $defaultEmail != '') { + if ($form['account']['mail']['#default_value'] != $defaultEmail) { + \Drupal::database()->update('users_field_data') + ->condition('mail', $form['account']['mail']['#default_value']) + ->fields(['mail' => $defaultEmail, 'init' => $defaultEmail]) + ->execute(); + } + } + + + + if(isset($defaultEmail) && $defaultEmail != '') { + $form['account']['mail']['#default_value'] = $defaultEmail; + } + $form['account']['files[user_picture_0]']['#default_value'] = isset($result->ImageUrl) ? $result->ImageUrl : ''; + $form['lr_profile_editor'] = [ + '#type' => 'item', + '#theme' => 'lr_profile_editor', + '#attributes' => ['class' => ['lr-profileeditor-container']], + '#weight' => -15, + '#open' => TRUE, + ]; + + $form['lr_update_phone'] = [ + '#type' => 'item', + '#theme' => 'lr_update_phone', + '#attributes' => ['class' => ['lr-phone-container']], + '#weight' => -15, + '#open' => TRUE, + ]; + + $form['lr_message'] = [ + '#type' => 'item', + '#theme' => 'lr_message', + '#attributes' => ['class' => ['lr-message-container']], + '#weight' => -30, + '#open' => TRUE, + ]; + + if (isset($result->PhoneId) && $result->PhoneId != '') { + $form['account_phone'] = [ + '#type' => 'container', + '#weight' => -15, + ]; + $form['account_phone']['phoneid'] = [ + '#type' => 'textfield', + '#title' => t('Phone ID'), + '#attributes' => ['readonly' => 'readonly'], + '#description' => t('A valid phone number.'), + '#default_value' => $result->PhoneId, + ]; + } + + $configSettings = lr_ciam_get_config_option(); + + if (isset($result->Email) && count($result->Email) > 0 && $configSettings->EmailVerificationFlow != 'disabled') { + $form['account']['emailSetting'] = [ + '#type' => 'fieldset', + '#title' => t('Email Settings'), + '#collapsible' => TRUE, + '#collapsed' => TRUE, + ]; + + $header = [ + 'email' => ['data' => 'Email'], + 'action' => ['data' => 'Action'], + ]; + + $form['account']['emailSetting']['add'] = [ + '#type' => 'item', + '#markup' => '
Add Email
', + ]; + + for ($i = 0; $i < count($result->Email); $i++) { + $email[$i] = [ + '#type' => 'email', + '#attributes' => ['readonly' => 'readonly'], + '#default_value' => ($result->Email[$i]->Value ? $result->Email[$i]->Value : ''), + ]; + + $action[$i] = [ + '#type' => 'item', + '#markup' => '
Remove
', + ]; + + $rows['customize_field_' . $i] = [ + 'data' => [ + 'field' => ['data' => &$email[$i]], + 'label' => ['data' => &$action[$i]], + ], + ]; + + $data_to_send['customize_field_' . $i] = [ + 'field' => &$email[$i], + 'label' => &$action[$i], + ]; + } + + $form['account']['emailSetting']['table'] = [ + '#tree' => TRUE, + '#theme' => 'table', + '#header' => $header, + 'values' => $data_to_send, + '#rows' => &$rows, + ]; + + $form['add_email'] = [ + '#type' => 'item', + '#theme' => 'add_email', + '#attributes' => ['class' => ['add-email']], + '#weight' => -20, + '#open' => TRUE, + ]; + + $form['remove_email'] = [ + '#type' => 'item', + '#theme' => 'remove_email', + '#attributes' => ['class' => ['remove-email']], + '#weight' => -20, + '#open' => TRUE, + ]; + } + $form['account']['current_pass_required_value']['#access'] = FALSE; + $form['account']['current_pass']['#access'] = FALSE; + + + if (isset($configSettings->TwoFactorAuthentication) && $configSettings->TwoFactorAuthentication->IsEnabled) { + $authenticationAPI = new AuthenticationAPI(); + try { + $userProfileData = $authenticationAPI->getProfileByAccessToken(trim(\Drupal::service('session')->get('access_token', [])),'Provider'); + } + catch (LoginRadiusException $e) { + \Drupal::logger('ciam')->error($e); + } + + if ($userProfileData->Provider == 'Email') { + $form['lr_2fa_container'] = [ + '#type' => 'item', + '#theme' => '2fa_container', + '#attributes' => ['class' => ['lr-2fa-container']], + '#weight' => -25, + '#open' => TRUE, + ]; + } + + try { + $isEnabled = $mfaObject->mfaConfigureByAccessToken(\Drupal::service('session')->get('access_token', [])); + } + catch (LoginRadiusException $e) { + \Drupal::logger('ciam')->error($e); + } + + if ((isset($isEnabled->IsGoogleAuthenticatorVerified) && $isEnabled->IsGoogleAuthenticatorVerified) || (isset($isEnabled->IsOTPAuthenticatorVerified) && $isEnabled->IsOTPAuthenticatorVerified)) { + $form['lr_2fa_backup'] = [ + '#type' => 'details', + '#title' => 'Backup Codes List', + '#theme' => 'lr_backup_codes', + '#attributes' => ['class' => ['lr_2fa_backup']], + '#weight' => -21, + '#open' => TRUE, + ]; + } + } + $emailVerified = \Drupal::service('session')->get('emailVerified', []); + if (isset($emailVerified) && $emailVerified) { + $form['lr_ciam_linked'] = [ + '#type' => 'details', + '#title' => 'Account Linking', + '#theme' => 'lr_ciam_linked', + '#attributes' => ['class' => ['lr-ciam-linked']], + '#weight' => -20, + '#open' => TRUE, + ]; + } + } + return $form; +} + +/** + * Implements hook_user_format_name_alter(). + */ +function lr_ciam_user_format_name_alter(&$name, AccountInterface $account) { + + if (!\Drupal::currentUser()->isAnonymous()) { + + // If Login Radius name is used as Drupal user name, we + // don't need to look it up. + if (empty(\Drupal::config('lr_ciam.settings')->get('ciam_dont_save_name_in_db'))) { + return; + } + + $userFullName = \Drupal::service('session')->get('user_profile_fullName', []); + if (!empty($userFullName)) { + $name = $userFullName; + } + + } +} + +/** + * Implements hook_entity_base_field_info_alter(). + */ +function lr_ciam_entity_base_field_info_alter(&$fields, EntityTypeInterface $entity_type) { + if ($entity_type->id() == 'user') { + $constraints = $fields['mail']->getConstraints(); + unset($constraints['ProtectedUserField']); + $fields['mail']->setConstraints($constraints); + + $constraints = $fields['pass']->getConstraints(); + unset($constraints['ProtectedUserField']); + $fields['pass']->setConstraints($constraints); + } +} + +/** + * Delete user. + * + * @param object $account + */ +function lr_ciam_user_predelete($account) { + $config = \Drupal::config('lr_ciam.settings'); + $ciam_delete_lr_useraccount = $config->get('ciam_delete_lr_useraccount'); + $user_manager = \Drupal::service('lr_ciam.user_manager'); + $ciam_uid = $user_manager->lrCiamGetCiamUid($account->id()); + if($ciam_delete_lr_useraccount=='true'){ + $user_manager->userDelete($ciam_uid); + } + $user_manager->deleteMapUser($account->id()); +} + +/** + * Implements hook_mail_alter(). + */ +function lr_ciam_mail_alter(&$message) { + if ($message['key'] == 'register_admin_created') { + $message['send'] = FALSE; + } + if ($message['key'] == 'password_reset') { + $message['send'] = FALSE; + } +} + +/** + * Unset options when Identity Experience Framework enable. + */ +function lr_ciam_form_advanced_settings_alter(&$form, FormStateInterface $form_state) { + $ief_config = \Drupal::config('lr_ief.settings'); + + if ($ief_config->get('lr_ief_enable') == '1') { + unset($form['lr_user_settings']); + unset($form['lr_template_settings']); + unset($form['lr_field_mapping']); + } + return $form; +} + +/** + * Add authentication variable in database. + */ +function lr_ciam_add_extra_config_settings() { + return ['ciam_prompt_password_on_social_login', 'ciam_user_name_login', 'ciam_ask_email_for_unverified_user_login', 'ciam_ask_required_fields_on_traditional_login', + 'ciam_welcome_email_template', 'ciam_email_verification_template', 'ciam_reset_password_email_template', 'ciam_sms_template_2fa', 'ciam_check_phone_no_availability', + 'ciam_welcome_sms_template', 'ciam_sms_template_phone_verification','ciam_sms_template_reset_password','ciam_sms_template_change_phone_no', + ]; +} + +/** + * Add advanced variable in database. + */ +function lr_ciam_add_advance_config_settings() { + return ['ciam_instant_link_login', 'ciam_instant_link_login_email_template', 'ciam_instant_otp_login', 'ciam_sms_template_one_time_passcode', + 'ciam_display_password_strength', 'ciam_notification_timeout_setting', 'ciam_save_mail_in_db', 'ciam_save_name_in_db', 'ciam_delete_lr_useraccount','ciam_terms_and_condition_html', + 'ciam_custom_options', 'ciam_registation_form_schema', + ]; +} + +/** + * Get configurations from config API. + * + */ +function lr_ciam_get_config_option() { + try { + $configObject = new ConfigurationAPI(); + return $configObject->getConfigurations(); + } + catch (LoginRadiusException $e) { + \Drupal::logger('ciam')->error($e); + } +} + + + +/** + * Validate LoginRadius API Credentials. + * + * @param string $apiKey + * @param string $apiSecret + */ +function lr_ciam_get_authentication($apiKey, $apiSecret) { + if (isset($apiKey)) { + $data = []; + try { + + $resourcePath = 'https://api.loginradius.com/api/v2/app/validate'; + $queryParam = []; + $queryParam['apiKey'] = $apiKey; + $queryParam['apiSecret'] = $apiSecret; + $result = Functions::_apiClientHandler('GET', $resourcePath, $queryParam); + if (empty($result)) { + $data['message'] = t('Please check your php.ini settings to enable CURL or FSOCKOPEN'); + $data['status'] = 'error'; + } + + elseif (isset($result->Status) && !$result->Status) { + $error = [ + "API_KEY_NOT_VALID" => "LoginRadius API key is invalid. Get your LoginRadius API key from LoginRadius account", + "API_SECRET_NOT_VALID" => "LoginRadius API Secret is invalid. Get your LoginRadius API Secret from LoginRadius account", + "API_KEY_NOT_FORMATED" => "LoginRadius API Key is not formatted correctly", + "API_SECRET_NOT_FORMATED" => "LoginRadius API Secret is not formatted correctly", + ]; + + foreach ($result->Messages as $value) { + $data['message'] = $error["$value"]; + $data['status'] = 'error'; + break; + } + } + return $data; + } + + catch (LoginRadiusException $e) { + $data['message'] = t("Something went wrong, check your credentials."); + $data['status'] = 'error'; + return $data; + } + } +} + +/** + * Get configurations list from lr side. + * + * @param string $apiKey + */ +function lr_ciam_get_configuration($apiKey) { + if (isset($apiKey)) { + $res = []; + try { + $resourcePath = '/ciam/appinfo'; + $queryParam = []; + $queryParam['apiKey'] = $apiKey; + $result = Functions::_apiClientHandler('GET', $resourcePath, $queryParam); + + if (empty($result)) { + $res['response'] = ''; + }else{ + $res['response'] = $result; + } + return $res; + } + catch (LoginRadiusException $e) { + \Drupal::logger('ciam')->error($e); + } + } +} + +/** + * Implements hook_user_delete(). + */ +function lr_ciam_user_delete($account) { + $user_manager = \Drupal::service('lr_ciam.user_manager'); + $user_manager->deleteMapUser($account->id()); +} diff --git a/drupal-10/src/customer_identity_and_access_management/lr_ciam/lr_ciam.routing.yml b/drupal-10/src/customer_identity_and_access_management/lr_ciam/lr_ciam.routing.yml new file mode 100644 index 0000000..b840758 --- /dev/null +++ b/drupal-10/src/customer_identity_and_access_management/lr_ciam/lr_ciam.routing.yml @@ -0,0 +1,46 @@ +lr_ciam.change_password: + path: 'user/{user}/changepassword' + defaults: + _controller: '\Drupal\lr_ciam\Controller\CiamController::userChangePassword' + _title: 'changepass' + requirements: + _custom_access: '\Drupal\lr_ciam\Controller\CiamController::changePasswordAccess' + options: + no_cache: TRUE + +lr_ciam.user_register_validate: + path: 'user/ciamlogin' + defaults: + _controller: '\Drupal\lr_ciam\Controller\CiamController::userRegisterValidate' + _title: 'Ciam Login' + requirements: + _access: 'TRUE' + options: + no_cache: TRUE + +lr_ciam.settings_form: + path: 'admin/config/people/ciam' + defaults: + _title: 'LoginRadius' + _form: '\Drupal\lr_ciam\Form\CiamSettingsForm' + requirements: + _permission: 'administer user activation settings' + options: + no_cache: TRUE + +authentication.settings_form: + path: 'admin/config/people/ciam/authentication' + defaults: + _title: 'LoginRadius' + _form: '\Drupal\lr_ciam\Form\AuthenticationSettingsForm' + requirements: + _permission: 'administer user authentication settings' + +advanced.settings_form: + path: 'admin/config/people/ciam/advanced' + defaults: + _title: 'LoginRadius' + _form: '\Drupal\lr_ciam\Form\AdvancedSettingsForm' + requirements: + _permission: 'administer user advanced settings' + \ No newline at end of file diff --git a/drupal-10/src/customer_identity_and_access_management/lr_ciam/lr_ciam.services.yml b/drupal-10/src/customer_identity_and_access_management/lr_ciam/lr_ciam.services.yml new file mode 100644 index 0000000..1570e03 --- /dev/null +++ b/drupal-10/src/customer_identity_and_access_management/lr_ciam/lr_ciam.services.yml @@ -0,0 +1,11 @@ +services: + lr_ciam.user_manager: + class: Drupal\lr_ciam\CiamUserManager + lr_ciam.route_subscriber: + class: Drupal\lr_ciam\Routing\RouteSubscriber + tags: + - { name: event_subscriber } + lr_ciam.http_middleware: + class: Drupal\lr_ciam\RedirectMiddleware + tags: + - { name: http_middleware } \ No newline at end of file diff --git a/drupal-10/src/customer_identity_and_access_management/lr_ciam/src/CiamUserManager.php b/drupal-10/src/customer_identity_and_access_management/lr_ciam/src/CiamUserManager.php new file mode 100644 index 0000000..052164a --- /dev/null +++ b/drupal-10/src/customer_identity_and_access_management/lr_ciam/src/CiamUserManager.php @@ -0,0 +1,1162 @@ +connection = Database::getConnection(); + $this->moduleconfig = \Drupal::config('lr_ciam.settings'); + $this->apiSecret = trim($this->moduleconfig->get('api_secret')); + $this->apiKey = trim($this->moduleconfig->get('api_key')); + $this->apirequestsigning = trim($this->moduleconfig->get('api_request_signing')); + $this->redirectMiddleware = \Drupal::service('lr_ciam.http_middleware'); + } + + /** + * Update UID in database table. + * + * @param string $ciam_uid + * Uid get from user profile data. + * @param object $user_id + * User id get from drupal database. + * + * @return mixed + */ + public function lrCiamUpdateUserTable($ciam_uid, $user_id) { + try { + $this->connection->update('users') + ->fields(['lr_ciam_uid' => $ciam_uid]) + ->condition('uid', $user_id) + ->execute(); + } + catch (Exception $e) { + } + } + + /** + * User delete. + * + * @param object $user_id + * User id get from database. + * + * @return mixed + */ + public function userDelete($user_id) { + try { + $accountObj = new AccountAPI(); + return $accountObj->deleteAccountByUid($user_id); + } + catch (LoginRadiusException $e) { + } + } + + /** + * Get CIAM UID from users table. + * + * @param object $user_id + * User id get from drupal database. + * + * @return mixed + */ + public function lrCiamGetCiamUid($user_id) { + $query = \Drupal::database()->select('users', 'u'); + $query->addField('u', 'lr_ciam_uid'); + $query->condition('u.uid', $user_id); + $uid = $query->execute()->fetchField(); + return $uid; + } + + /** + * Get username from users_field_data table. + * + * @param object $user_id + * User id get from drupal database. + * + * @return username + */ + public function lrCiamGetCiamUname($user_id) { + $query = \Drupal::database()->select('users_field_data', 'u'); + $query->addField('u', 'name'); + $query->condition('u.uid', $user_id); + $uname = $query->execute()->fetchField(); + return $uname; + } + + /** + * Block user at CIAM. + */ + public function lrCiamBlockUser($uid) { + try { + $accountObj = new AccountAPI(); + $data = ["IsActive" => "false"]; + return $accountObj->updateAccountByUid($data, $uid); + } + catch (LoginRadiusException $e) { + \Drupal::logger('ciam')->error($e); + } + } + + /** + * Unblock user at CIAM. + */ + public function lrCiamUnblockUser($uid) { + try { + $accountObj = new AccountAPI(); + $data = ["IsActive" => "true"]; + return $accountObj->updateAccountByUid($data, $uid); + } + catch (LoginRadiusException $e) { + \Drupal::logger('ciam')->error($e); + } + } + + /** + * Delete mapped provider. + */ + public function deleteMapUser($aid) { + return $this->connection->delete('loginradius_mapusers') + ->condition('user_id', $aid) + ->execute(); + } + + /** + * Get user profile data. + */ + public function getUserData($userprofile) { + $userprofile->Email_value = (count($userprofile->Email) > 0 ? $userprofile->Email[0]->Value : ''); + $userprofile->Company_name = (isset($userprofile->Company->Name) ? $userprofile->Company->Name : ''); + $userprofile->Country_name = (isset($userprofile->Country->Name) ? $userprofile->Country->Name : ''); + $userprofile->PhoneNumber = (isset($userprofile->PhoneNumbers) && count($userprofile->PhoneNumbers) > 0 ? $userprofile->PhoneNumbers[0]->PhoneNumber : ''); + return $userprofile; + } + + /** + * Insert social provider data. + */ + public function insertSocialData($user_id, $provider_id, $provider) { + $this->connection->insert('loginradius_mapusers') + ->fields([ + 'user_id' => $user_id, + 'provider' => $provider, + 'provider_id' => $provider_id, + ]) + ->execute(); + } + + /** + * Get user by mail. + */ + public function getUserByEmail($email) { + return user_load_by_mail($email); + } + + /** + * Removed unescaped character. + */ + public function removeUnescapedChar($str) { + $in_str = str_replace([ + '<', + '>', + '&', + '{', + '}', + '*', + '/', + '(', + '[', + ']', + '!', + ')', + '&', + '*', + '#', + '$', + '%', + '^', + '|', + '?', + '+', + '=', + '"', + ',', + ], [''], $str); + $cur_encoding = mb_detect_encoding($in_str); + + if ($cur_encoding == "UTF-8" && mb_check_encoding($in_str, "UTF-8")) { + return $in_str; + } + else { + return utf8_encode($in_str); + } + } + + /** + * Check exist username. + * + * @param object $userprofile + * + * @return string Username of user + */ + public function checkUserName($userprofile) { + $user_name = $this->usernameOption($userprofile); + $index = 0; + + while (TRUE) { + if (user_load_by_name($user_name)) { + $index++; + $user_name = $user_name . $index; + } + else { + break; + } + } + $data['username'] = $this->removeUnescapedChar($user_name); + $data['fname'] = (!empty($userprofile->FirstName) ? $userprofile->FirstName : ''); + $data['lname'] = (!empty($userprofile->LastName) ? $userprofile->LastName : ''); + + if (empty($data['fname'])) { + $data['fname'] = $this->getDisplayName($userprofile); + } + + if (empty($data['lname'])) { + $data['lname'] = $this->getDisplayName($userprofile); + } + return $data; + } + + /** + * Get username from user profile data. + * + * @param object $userprofile + * User profile information. + * + * @return string Username of user + */ + public function usernameOption($userprofile) { + if (isset($userprofile->Provider) && $userprofile->Provider == 'Email' && isset($userprofile->UserName) && $userprofile->UserName != '') { + $username = $userprofile->UserName; + } + elseif (!empty($userprofile->FirstName) && !empty($userprofile->LastName)) { + $username = $userprofile->FirstName . ' ' . $userprofile->LastName; + } + elseif (!empty($userprofile->Email_value) && (isset($userprofile->Random_email_generated) && !$userprofile->Random_email_generated)) { + $user_name = explode('@', $userprofile->Email_value); + $username = $user_name[0]; + } + else { + $username = $this->getDisplayName($userprofile); + } + return $username; + } + + + /** + * Get username + */ + public function getDisplayName($userprofile) { + if (!empty($userprofile->FullName)) { + $username = $userprofile->FullName; + } + elseif (!empty($userprofile->ProfileName)) { + $username = $userprofile->ProfileName; + } + elseif (!empty($userprofile->NickName)) { + $username = $userprofile->NickName; + } + elseif (!empty($userprofile->PhoneId)) { + $username = str_replace([ + "-", + "+", + ], "", $userprofile->PhoneId); + } + elseif (!empty($userprofile->Email_value)) { + $user_name = explode('@', $userprofile->Email_value); + $username = $user_name[0]; + } + else { + $username = $userprofile->ID; + } + return $username; + } + + + /** + * Check exist username on update profile. + * + * @param object $userprofile + * + * @return string Username of user + */ + + public function getUserNameOnUpdateProfile($userprofile) { + $user_name = $this->usernameOption($userprofile); + + $data['username'] = $this->removeUnescapedChar($user_name); + $data['fname'] = (!empty($userprofile->FirstName) ? $userprofile->FirstName : ''); + $data['lname'] = (!empty($userprofile->LastName) ? $userprofile->LastName : ''); + + if (empty($data['fname'])) { + $data['fname'] = $this->getDisplayName($userprofile); + } + + if (empty($data['lname'])) { + $data['lname'] = $this->getDisplayName($userprofile); + } + return $data; + } + + /** + * Provider login to user. + * + * @param object $new_user + * @param object $userprofile + * @param boolean status + * + * @return mixed + */ + public function provideLogin($new_user, $userprofile, $status = FALSE) { + if (isset($userprofile) && !empty($userprofile)) { + if (is_array($userprofile) || is_object($userprofile)) { + $query = \Drupal::database()->select('loginradius_mapusers', 'lu'); + $query->addField('lu', 'user_id'); + $query->condition('lu.user_id', $new_user->id()); + $query->condition('lu.provider_id', $userprofile->ID); + $check_aid = $query->execute()->fetchField(); + if (isset($check_aid) && !$check_aid) { + $this->insertSocialData($new_user->id(), $userprofile->ID, $userprofile->Provider); + } + } + } + + + if ($new_user->isActive()) { + $url = ''; + $isNew = FALSE; + + if (!$new_user->isNew()) { + $this->fieldCreateUserObject($new_user, $userprofile); + $new_user->save(); + + $this->downloadProfilePic($userprofile->ImageUrl, $userprofile->ID, $new_user); + } + + \Drupal::service('session')->migrate(); + \Drupal::service('session')->set('emailVerified', FALSE); + if (isset($userprofile->EmailVerified)) { + \Drupal::service('session')->set('emailVerified', $userprofile->EmailVerified); + } + + if (\Drupal::moduleHandler()->moduleExists('lr_ciam')) { + if (isset($userprofile->Provider) && $userprofile->Provider == 'Email' && isset($userprofile->UserName) && $userprofile->UserName != '') { + $user_name = $userprofile->UserName; + } + + $user_manager = \Drupal::service('lr_ciam.user_manager'); + $db_uname = $user_manager->lrCiamGetCiamUname($new_user->id()); + + if (isset($db_uname) && $db_uname != '') { + if (isset($user_name) && $user_name != '' && $db_uname != $user_name) { + try { + $this->connection->update('users_field_data') + ->fields(['name' => $user_name]) + ->condition('uid', $new_user->id()) + ->execute(); + } + catch (Exception $e) { + \Drupal::logger('ciam')->error($e); + \Drupal::messenger()->addError($e->getMessage()); + } + } + } + } + + user_login_finalize($new_user); + if ($status) { + \Drupal::messenger()->addStatus(t('You are now logged in as %username.', ['%username' => $new_user->getDisplayName()])); + } + else { + \Drupal::messenger()->addStatus(t('You are now logged in as %username.', ['%username' => $new_user->getDisplayName()])); + } + return $this->redirectUser($url); + } + else { + + $sso_config = \Drupal::config('lr_sso.settings'); + \Drupal::messenger()->addError(t('You are either blocked, or have not activated your account. Please check your email.')); + if ($sso_config->get('sso_enable') == 1) { + $domain = Url::fromRoute('')->setAbsolute()->toString(); + $redirectUrl = $domain . 'user/logout'; + $response = new TrustedRedirectResponse($redirectUrl); + return $this->redirectMiddleware->setRedirectResponse($response); + + }else { + $domain = Url::fromRoute('')->setAbsolute()->toString(); + $redirectUrl = $domain . 'user/login'; + $response = new TrustedRedirectResponse($redirectUrl); + return $this->redirectMiddleware->setRedirectResponse($response); + } + } +} + /** + * Check provider id exist or not. + * + * @param string $pid + * provider id. + * + * @return provider id + */ + public function checkProviderId($pid) { + // $query = db_select('users', 'u'); + $query = \Drupal::database()->select('users', 'u'); + $query->join('loginradius_mapusers', 'lu', 'u.uid = lu.user_id'); + $query->addField('u', 'uid'); + $query->condition('lu.provider_id', $pid); + $check_aid = $query->execute()->fetchField(); + return $check_aid; + } + + /** + * Redirect user. + * + * @param string $variable_path + * + * @return mixed + */ + public function redirectUser($variable_path = '') { + $user = \Drupal::currentUser(); + $variable_path = (!empty($variable_path) ? $variable_path : 'login_redirection'); + $variable_custom_path = (($variable_path == 'login_redirection') ? 'custom_login_url' : ''); + $request_uri = \Drupal::request()->getRequestUri(); + + if (strpos($request_uri, 'redirect_to') !== FALSE) { + // Redirect to front site. + $redirectUrl = \Drupal::request()->query->get('redirect_to'); + $response = new TrustedRedirectResponse($redirectUrl); + return $this->redirectMiddleware->setRedirectResponse($response); + } + elseif ($this->moduleconfig->get($variable_path) == 1) { + // Redirect to profile. + $response = new RedirectResponse($user->id() . '/edit'); + return $this->redirectMiddleware->setRedirectResponse($response); + } + elseif ($this->moduleconfig->get($variable_path) == 2) { + // Redirect to custom page. + $custom_url = $this->moduleconfig->get($variable_custom_path); + if (!empty($custom_url)) { + $response = new RedirectResponse($custom_url); + return $this->redirectMiddleware->setRedirectResponse($response); + } + else { + return new RedirectResponse(Url::fromRoute('')->toString()); + } + } + else { + // Redirect to same page. + $referer_url = \Drupal::service('session')->get('referer_url', []); + if (!empty($referer_url)) { + $response = new RedirectResponse($referer_url); + return $this->redirectMiddleware->setRedirectResponse($response); + } + else { + $destination = (\Drupal::destination()->getAsArray()); + if (isset($destination['destination']) && $destination['destination'] != '') { + $response = new RedirectResponse($destination['destination']); + } + else { + $response = new RedirectResponse(Url::fromRoute('')->toString()); + } + return $this->redirectMiddleware->setRedirectResponse($response); + } + } + } + + /** + * Get profile pic. + * + * @param string $picture_url + * @param string $id + * @param string $user + * + * @return mixed + */ + public function downloadProfilePic($picture_url, $id, $user) { + if (user_picture_enabled()) { + // Make sure that we have everything we need. + if (!$picture_url || !$id) { + return FALSE; + } + $picture_config = \Drupal::config('field.field.user.user.user_picture'); + $pictureDirectory = $picture_config->get('settings.file_directory'); + $data = ['user' => $user]; + $pictureDirectory = \Drupal::token()->replace($pictureDirectory, $data); + // Check target directory from account settings and make sure it's writeable. + // $directory = file_default_scheme() . '://' . $pictureDirectory; + // if (!file_prepare_directory($directory, FILE_CREATE_DIRECTORY)) { + $directory = \Drupal::config('system.file')->get('default_scheme') . '://' . $pictureDirectory; + if (!\Drupal::service('file_system')->prepareDirectory($directory, FileSystemInterface::CREATE_DIRECTORY)) { + \Drupal::logger('ciam') + ->error('Could not save profile picture. Directory is not writeable: @directory', ['@dir' => $directory]); + } + // Download the picture. Facebook API always serves the images in jpg format. + $destination = $directory . '/' . Html::escape($id) . '.jpg'; + $request = @file_get_contents($picture_url); + if ($request) { + // $picture_file_data = file_save_data($request, $destination, FILE_EXISTS_REPLACE); + $picture_file_data = \Drupal::service('file.repository')->writeData($request, $destination, FileSystemInterface::EXISTS_REPLACE); + $maxResolution = $picture_config->get('settings.max_resolution'); + $minResolution = $picture_config->get('settings.min_resolution'); + file_validate_image_resolution($picture_file_data, $maxResolution, $minResolution); + $user->set('user_picture', $picture_file_data->id()); + $user->save(); + unset($_SESSION['messages']['status']); + return TRUE; + } + + // Something went wrong. + \Drupal::logger('ciam')->error('Could not save profile picture. Unhandled error.'); + return FALSE; + } + } + + /** + * Create user. + * + * @param string $userprofile + * + * @return mixed + */ + public function createUser($userprofile) { + if (isset($userprofile->ID) && !empty($userprofile->ID)) { + $user_config = \Drupal::config('user.settings'); + + $user_register = $user_config->get('register'); + if ($user_register == 'visitors' || $user_register == 'visitors_admin_approval') { + $newUserStatus = 0; + if ($user_register != 'visitors_admin_approval' && ($user_register == 'visitors')) { + $newUserStatus = 1; + } + $data = $this->checkUserName($userprofile); + // Set up the user fields. + $password = \Drupal::service('password_generator')->generate(32); + + $fields = [ + 'name' => ($this->moduleconfig->get('ciam_save_name_in_db') == 'false') ? $userprofile->ID : $data['username'], + 'mail' => $userprofile->Email_value, + 'init' => $userprofile->Email_value, + 'pass' => $password, + 'status' => $newUserStatus, + ]; + + $new_user = User::create($fields); + $this->fieldCreateUserObject($new_user, $userprofile); + $new_user->save(); + + // Log notice and invoke Rules event if new user was succesfully created. + if ($new_user->id()) { + \Drupal::logger('ciam') + ->notice('New user created. Username %username, UID: %uid', [ + '%username' => $new_user->getDisplayName(), + '%uid' => $new_user->id(), + ]); + // Return $new_user;. + $this->connection->insert('loginradius_mapusers') + ->fields([ + 'user_id' => $new_user->id(), + 'provider' => $userprofile->Provider, + 'provider_id' => $userprofile->ID, + ]) + ->execute(); + $this->downloadProfilePic($userprofile->ImageUrl, $userprofile->ID, $new_user); + + // Advanced module LR Code Hook Start. + if (count(\Drupal::moduleHandler()->getImplementations('add_user_data_after_save')) > 0) { + // Call all modules that implement the hook, and let them make changes to $variables. + \Drupal::moduleHandler()->invokeAll('add_user_data_after_save', [$new_user, $userprofile]); + } + // Advanced module LR Code Hook End. + $status = FALSE; + if (($user_config->get('verify_mail') == 1) || !$user_config->get('verify_mail')) { + $status = TRUE; + } + + if ($new_user->isActive() && $status && \Drupal::service('session')->get('user_verify', []) != 1) { + // $new_user->setLastLoginTime(REQUEST_TIME); + $new_user->setLastLoginTime(\Drupal::time()->getRequestTime()); + } + } + else { + // Something went wrong. + \Drupal::messenger()->addError(t('Creation of user account failed. Please contact site administrator.')); + \Drupal::logger('ciam')->error('Could not create new user.'); + return FALSE; + } + + if ($new_user->isActive() && $status && \Drupal::service('session')->get('user_verify', []) != 1) { + return $this->provideLogin($new_user, $userprofile); + } + elseif ($user_register != 'visitors_admin_approval' && ($new_user->isActive() || (\Drupal::service('session')->get('user_verify', []) == 1 && $status))) { + // Require email confirmation. + _user_mail_notify('status_activated', $new_user); + \Drupal::service('session')->set('user_verify', 0); + \Drupal::messenger()->addStatus(t('Once you have verified your e-mail address, you may log in via Social Login.')); + return new RedirectResponse(Url::fromRoute('user.login')->toString()); + } + else { + _user_mail_notify('register_pending_approval', $new_user); + \Drupal::messenger()->addStatus(t('Thank you for applying for an account. Your account is currently pending approval by the site administrator.
In the meantime, a welcome message with further instructions has been sent to your e-mail address.')); + return new RedirectResponse(Url::fromRoute('user.login')->toString()); + } + } + else { + \Drupal::messenger()->addError(t('Only site administrators can create new user accounts.')); + return new RedirectResponse(Url::fromRoute('user.login')->toString()); + } + } + } + + /** + * Check existing user. + * + * @param $userprofile + * + * @return mixed + */ + public function checkExistingUser($userprofile) { + $drupal_user = NULL; + if (isset($userprofile->ID) && !empty($userprofile->ID)) { + + $uid = $this->checkProviderId($userprofile->ID); + // Advanced module LR Code Hook End. + if ($uid) { + $drupal_user = User::load($uid); + } + } + + if (!$drupal_user) { + if (empty($userprofile->Email_value) || $this->moduleconfig->get('ciam_save_mail_in_db') == 'false') { + $userprofile->Email_value = $this->randomEmailGeneration(); + $userprofile->Random_email_generated = true; + } else{ + $userprofile->Random_email_generated = false; + } + if (!empty($userprofile->Email_value)) { + $drupal_user = $this->getUserByEmail($userprofile->Email_value); + if ($drupal_user) { + $this->insertSocialData($drupal_user->id(), $userprofile->ID, $userprofile->Provider); + } + } + } + + if ($drupal_user) { + + return $this->provideLogin($drupal_user, $userprofile, TRUE); + } + else { + + return $this->createUser($userprofile); + } + } + + /** + * Get random email. + * + */ + public function randomEmailGeneration() + { + $randomNo = $this->getRandomNumber(4); + $base_root = Url::fromRoute('')->setAbsolute()->toString(); + $site_domain = str_replace(array("http://","https://"), "", $base_root); + $email = $randomNo . '@' . $site_domain.'.com'; + $variable = substr($email, 0, strpos($email, ".com")); + $result = explode('.com', $variable); + $email = $result[0].'.com'; + return $email; + } + + /* + * function to generate a random string + */ + function getRandomNumber($n) { + $characters = 'abcdefghijklmnopqrstuvwxyz'.time(); + $randomString = ''; + + for ($i = 0; $i < $n; $i++) { + $index = rand(0, strlen($characters) - 1); + $randomString .= $characters[$index]; + } + return $randomString. time(); + } + + /** + * Create user. + * + * @param $payload + * + * @return array + */ + public function lrCiamCreateUser($payload) { + try { + $accountObj = new AccountAPI(); + return $accountObj->createAccount($payload); + } + catch (LoginRadiusException $e) { + if (isset($e->getErrorResponse()->Description) && $e->getErrorResponse()->Description) { + return $e->getErrorResponse()->Description; + } + } + } + + /** + * Set password. + * + * @param $uid + * @param $password + * + * @return mixed + */ + public function lrCiamSetPassword($uid, $password) { + try { + $accountObj = new AccountAPI(); + $accountObj->setAccountPasswordByUid($password, $uid); + } + catch (LoginRadiusException $e) { + } + } + + /** + * Handle Forgot password. + * + * @param $email + * @param $reset_password_url + * + * @return mixed + */ + public function lrCiamForgotPassword($email, $reset_password_url) { + try { + $authObj = new AuthenticationAPI(); + return $authObj->forgotPassword($email, $reset_password_url); + } + catch (LoginRadiusException $e) { + if (isset($e->getErrorResponse()->Description) && $e->getErrorResponse()->Description) { + return $e->getErrorResponse()->Description; + } + } + } + + /** + * Handle user callback. + * + * @param object $userprofile + * User profile data that you got from traditional/social network. + * + * @return mixed + */ + public function handleUserCallback($userprofile) { + return new RedirectResponse(Url::fromRoute('user.page')->toString()); + } + + + /** + * Convert field data. + * + * @return array + */ + public function fieldFieldConvertInfo() { + $convert_info = [ + 'text' => [ + 'label' => t('Text'), + 'callback' => 'fieldFieldConvertText', + ], + 'email' => [ + 'label' => t('Text'), + 'callback' => 'fieldFieldConvertText', + ], + 'string' => [ + 'label' => t('String'), + 'callback' => 'fieldFieldConvertText', + ], + 'string_long' => [ + 'label' => t('Long String'), + 'callback' => 'fieldFieldConvertText', + ], + 'text_long' => [ + 'label' => t('Long text'), + 'callback' => 'fieldFieldConvertText', + ], + 'list_string' => [ + 'label' => t('List String'), + 'callback' => 'fieldFieldConvertList', + ], + 'boolean' => [ + 'label' => t('Boolean'), + 'callback' => 'fieldFieldConvertBool', + ], + 'datetime' => [ + 'label' => t('Date'), + 'callback' => 'fieldFieldConvertDate', + ], + 'date' => [ + 'label' => t('Date'), + 'callback' => 'fieldFieldConvertDate', + ], + 'datestamp' => [ + 'label' => t('Date'), + 'callback' => 'fieldFieldConvertDate', + ], + ]; + + \Drupal::moduleHandler()->alter('fieldFieldConvertInfo', $convert_info); + return $convert_info; + } + + /** + * Convert text and text_long data. + * + * @param string $property_name + * User profile property name through which data mapped. + * @param object $userprofile + * User profile data that you got from traditional/social network. + * @param string $field + * User field name stored in database. + * @param string $instance + * Field instance. + * + * @return array + * Contain value of field map data + */ + public function fieldFieldConvertText($property_name, $userprofile, $field, $instance) { + $value = NULL; + if (!empty($property_name)) { + + if (isset($userprofile->$property_name)) { + if (is_string($userprofile->$property_name)) { + $value = $userprofile->$property_name; + } + elseif (is_object($userprofile->$property_name)) { + $value = $userprofile->$property_name; + if (isset($value->Name)) { + $value = $value->Name; + } + }elseif (is_bool($userprofile->$property_name)) { + $value = $userprofile->$property_name; + $value ? ['value' => (isset($value) && $value == 'true') ? true : '0'] : NULL; + } + } + + + return $value ? ['value' => $value] : NULL; + } + } + + + /** + * Convert bool data. + * + * @param string $property_name + * User profile property name through which data mapped. + * @param object $userprofile + * User profile data that you got from traditional/social network. + * @param string $field + * User field name stored in database. + * @param string $instance + * Field instance. + * + * @return array + * Contain value of field map data + */ + + public function fieldFieldConvertBool($property_name, $userprofile, $field, $instance) { + $value = NULL; + $property_name = explode("_", $property_name); + + if(is_array($property_name)){ + if(isset($property_name[0]) && $property_name[0] == 'cf') { + $name = $property_name[1]; + $value = $userprofile->CustomFields->$name; + } + } + elseif (is_string($userprofile->$property_name)) { + $value = $userprofile->$property_name; + } + elseif (is_object($userprofile->$property_name)) { + $object = $userprofile->$property_name; + if (isset($object->name)) { + $value = $object->name; + } + } + return $value ? ['value' => (isset($value) && $value == 'true') ? true : '0'] : NULL; + } + + /** + * Convert list data. + * + * @param string $property_name + * User profile property name through which data mapped. + * @param object $userprofile + * User profile data that you got from traditional/social network. + * @param string $field + * User field name stored in database. + * @param string $instance + * Field instance. + * + * @return array + * Contain value of field map data + */ + public function fieldFieldConvertList($property_name, $userprofile, $field, $instance) { + + if (!empty($property_name)) { + if (!isset($userprofile->$property_name) && !is_string($userprofile->$property_name)) { + return; + } + + $options = options_allowed_values($field); + $best_match = 0.0; + $match_sl = strtolower($userprofile->$property_name); + + + foreach ($options as $key => $option) { + $option = trim($option); + $match_option = strtolower($option); + $this_match = 0; + similar_text($match_option, $match_sl, $this_match); + + if ($this_match > $best_match) { + $best_match = $this_match; + $best_key = $key; + } + } + return isset($best_key) ? ['value' => $best_key] : NULL; + } + } + + /** + * Convert date data. + * + * @param string $property_name + * User profile property name through which data mapped. + * @param object $userprofile + * User profile data that you got from traditional/social network. + * @param string $field + * User field name stored in database. + * @param string $instance + * Field instance. + * + * @return array + * Contain value of field map data + */ + public function fieldFieldConvertDate($property_name, $userprofile, $field, $instance) { + if (!empty($property_name)) { + if (isset($userprofile->$property_name)) { + $value = NULL; + + if (strpos($userprofile->$property_name, '/') !== FALSE) { + $sldate = explode('/', $userprofile->$property_name); + $date = strtotime($userprofile->$property_name); + $formatDate = date('Y-m-d\TH:i:s', $date); + } + else { + $sldate = explode('-', $userprofile->$property_name); + $month = isset($sldate[0]) ? trim($sldate[0]) : ''; + $date = isset($sldate[1]) ? trim($sldate[1]) : ''; + $year = isset($sldate[2]) ? trim($sldate[2]) : ''; + $formatDate = trim($year . '-' . $month . '-' . $date, '-'); + $formatDate = $formatDate . 'T00:00:00'; + } + + if (count($sldate) == 3) { + if (!empty($formatDate)) { + $value = [ + 'value' => $formatDate, + 'date_type' => $instance['type'], + ]; + } + } + return $value; + } + } + } + + /** + * Field create user array. + * + * @param string $drupal_user + * User data. + * @param object $userprofile + * User profile data that you got from traditional/social network. + * + * @return array + * Contain value of user field map data + */ + public function fieldCreateUserArray(&$drupal_user, $userprofile) { + $this->fieldCreateUser(NULL, $drupal_user, $userprofile, TRUE); + } + + /** + * Field update user object. + * + */ + public function fieldUpdateUserObject($uid, $userprofile) { + if ($uid) { + $drupal_user = User::load($uid); + } + + if (isset($drupal_user) && $drupal_user->id()) { + $this->fieldUpdateUser($uid, $drupal_user, $drupal_user, $userprofile, FALSE); + } + } + + /** + * Field create user object. + * + * @param string $drupal_user + * User data. + * @param object $userprofile + * User profile data that you got from traditional/social network. + * + * @return array + * Contain value of user field map data + */ + public function fieldCreateUserObject($drupal_user, $userprofile) { + $this->fieldCreateUser($drupal_user, $drupal_user, $userprofile, FALSE); + } + + /** + * Field create user. + * + * @param string $drupal_user + * User data. + * @param string $drupal_user_ref + * user data reference. + * @param object $userprofile + * User profile data that you got from traditional/social network. *. + * @param $register_form + * Passed boolean true or false + * + * @return array + * Contain value of user field map data + */ + public function fieldCreateUser($drupal_user, &$drupal_user_ref, $userprofile, $register_form = FALSE) { + $field_map = $this->moduleconfig->get('user_fields'); + $field_convert_info = $this->fieldFieldConvertInfo(); + + $entity_type = 'user'; + $instances = []; + foreach (\Drupal::service('entity_field.manager') + ->getFieldDefinitions($entity_type, 'user') as $field_name => $field_definition) { + $user_bundle = $field_definition->getTargetBundle(); + + if (!empty($user_bundle)) { + $instances[$field_name]['type'] = $field_definition->getType(); + $instances[$field_name]['label'] = $field_definition->getLabel(); + } + } + + foreach ($instances as $field_name => $instance) { + $field = FieldStorageConfig::loadByName($entity_type, $field_name); + + if (isset($field_map[$field_name]) && isset($field_convert_info[$field->getType()]['callback'])) { + $callback = $field_convert_info[$field->getType()]['callback']; + $field_property_name = $field_map[$field_name]; + + if ($value = $this->$callback($field_property_name, $userprofile, $field, $instance)) { + + if (FALSE) { + $drupal_user_ref[$field_name]['widget']['0']['value']['#default_value'] = isset($value['value']) ? $value['value'] : $value; + } + else { + $drupal_user->set($field_name, $value); + } + } + } + } + } + + /** + * Field update user. + * + * @param string $uid + * User id. + * @param string $drupal_user + * User data. + * @param string $drupal_user_ref + * user data reference. + * @param object $userprofile + * User profile data that you got from traditional/social network. *. + * @param $register_form + * Passed boolean true or false + * + * @return array + * Contain value of user field map data + */ + + public function fieldUpdateUser($uid, $drupal_user, &$drupal_user_ref, $userprofile, $register_form = FALSE) { + $field_map = $this->moduleconfig->get('user_fields'); + $field_convert_info = $this->fieldFieldConvertInfo(); + + $entity_type = 'user'; + $instances = []; + foreach (\Drupal::service('entity_field.manager') + ->getFieldDefinitions($entity_type, 'user') as $field_name => $field_definition) { + $user_bundle = $field_definition->getTargetBundle(); + + if (!empty($user_bundle)) { + $instances[$field_name]['type'] = $field_definition->getType(); + $instances[$field_name]['label'] = $field_definition->getLabel(); + } + } + + foreach ($instances as $field_name => $instance) { + $field = FieldStorageConfig::loadByName($entity_type, $field_name); + + if (isset($field_map[$field_name]) && isset($field_convert_info[$field->getType()]['callback'])) { + $callback = $field_convert_info[$field->getType()]['callback']; + $field_property_name = $field_map[$field_name]; + + if ($value = $this->$callback($field_property_name, $userprofile, $field, $instance)) { + + if ($register_form) { + $drupal_user_ref[$field_name]['widget']['0']['value']['#default_value'] = isset($value['value']) ? $value['value'] : $value; + } + else { + + try { + $this->connection->update('user__'.$field_name) + ->fields([$field_name.'_value' => $value['value']]) + ->condition('entity_id', $uid) + ->execute(); + } + catch (Exception $e) { + } + } + } + } + } + } + +} diff --git a/drupal-10/src/customer_identity_and_access_management/lr_ciam/src/Controller/CiamController.php b/drupal-10/src/customer_identity_and_access_management/lr_ciam/src/Controller/CiamController.php new file mode 100644 index 0000000..cda5424 --- /dev/null +++ b/drupal-10/src/customer_identity_and_access_management/lr_ciam/src/Controller/CiamController.php @@ -0,0 +1,226 @@ +usermanager = $user_manager; + } + + /** + * {@inheritdoc} + */ + public static function create(ContainerInterface $container) { + return new static( + $container->get('lr_ciam.user_manager') + ); + } + + /** + * Set user password. + * + * Return change password form. + */ + public function userChangePassword($user) { + $post_value = \Drupal::request()->request->all(); + + if (isset($post_value['setpasswordsubmit']) && $post_value['setpasswordsubmit'] == 'submit') { + + if (isset($post_value['setnewpassword']) && !empty($post_value['setnewpassword']) && isset($post_value['setconfirmpassword']) && !empty($post_value['setconfirmpassword'])) { + + if ($post_value['setnewpassword'] == $post_value['setconfirmpassword']) { + + try { + $accountObject = new AccountAPI(); + $userProfileUid = \Drupal::service('session')->get('user_profile_uid', []); + $result = $accountObject->setAccountPasswordByUid($post_value['setnewpassword'], $userProfileUid); + if (isset($result) && $result) { + $this->messenger()->addStatus($this->t('Password set successfully.')); + } + } + catch (LoginRadiusException $e) { + \Drupal::logger('ciam')->error($e); + $this->messenger()->addError($e->getMessage()); + } + } + else { + $this->messenger()->addError($this->t('The Confirm Password field does not match the Password field.')); + } + } + else { + $this->messenger()->addError($this->t('The password and confirm password fields are required.')); + } + } + + try { + $authObject = new AuthenticationAPI(); + $userprofile = $authObject->getProfileByAccessToken(\Drupal::service('session')->get('access_token', []), 'Password'); + } + catch (LoginRadiusException $e) { + \Drupal::logger('ciam')->error($e); + } + + if (isset($userprofile->Password) && $userprofile->Password != '') { + $output = [ + '#title' => $this->t('Change Password'), + '#theme' => 'change_password', + '#attributes' => ['class' => ['change-password']], + ]; + } + else { + $output = [ + '#title' => $this->t('Set Password'), + '#theme' => 'set_password', + '#attributes' => ['class' => ['set-password']], + ]; + } + return $output; + } + + /** + * Show change password form. + */ + public function changePasswordAccess() { + $user = \Drupal::currentUser()->getRoles(); + $access_granted = in_array("administrator", $user); + + try { + $configObject = new ConfigurationAPI(); + $configData = $configObject->getConfigurations(); + } + catch (LoginRadiusException $e) { + \Drupal::logger('ciam')->error($e); + } + $optionVal = isset($configData->EmailVerificationFlow) ? $configData->EmailVerificationFlow : ''; + $lrProvider = \Drupal::service('session')->get('provider', []); + $isEmailVerified = \Drupal::service('session')->get('emailVerified', []); + if ($access_granted) { + return AccessResult::forbidden(); + } + + elseif ($optionVal === 'required' || $optionVal === 'disabled') { + if (isset($lrProvider) && $lrProvider == 'Email') { + return AccessResult::allowed(); + } + else { + return AccessResult::forbidden(); + } + } + elseif ($optionVal === 'optional') { + if (isset($lrProvider) && $lrProvider == 'Email' || isset($isEmailVerified) && $isEmailVerified) { + return AccessResult::allowed(); + } + else { + return AccessResult::forbidden(); + } + } + return AccessResult::forbidden(); + } + + /** + * Response for path 'user/login'. + * + * Handle token and validate the user. + */ + public function userRegisterValidate() { + + $action = \Drupal::request()->query->get('action_completed'); + if (isset($action) && $action == 'register') { + $this->messenger()->addStatus($this->t('Email for verification has been sent to your provided email id, check email for further instructions')); + return $this->redirect(""); + } + + if (isset($action) && $action == 'forgotpassword') { + $this->messenger()->addStatus($this->t('Password reset information sent to your provided email id, check email for further instructions')); + return $this->redirect(""); + } + + $request_token = isset($_REQUEST['token']) ? trim($_REQUEST['token']) : ''; + if (isset($_REQUEST['token'])) { + + $authObject = new AuthenticationAPI(); + \Drupal::service('session')->set('access_token', $request_token); + + // Get Userprofile form Access Token. + + try { + $userprofile = $authObject->getProfileByAccessToken($request_token); + $userprofile->widget_token = $request_token; + \Drupal::service('session')->set('user_profile_uid', $userprofile->Uid); + \Drupal::service('session')->set('user_profile_fullName', $userprofile->FullName); + \Drupal::service('session')->set('user_profile_phoneId', $userprofile->PhoneId); + + } + catch (LoginRadiusException $e) { + \Drupal::logger('ciam')->error($e); + $this->messenger()->addError($e->getMessage()); + return $this->redirect('user.login'); + } + + + // Advanced module LR Code Hook Start. + // Make sure at least one module implements our hook. + if (count(\Drupal::moduleHandler()->getImplementations('add_loginradius_userdata')) > 0) { + // Call all modules that implement the hook, and let them. + // Make changes to $variables. + $result = \Drupal::moduleHandler()->invokeAll('add_loginradius_userdata', [$userprofile, $userprofile->widget_token]); + $value = end($result); + if (!empty($value)) { + $userprofile = $value; + } + } + + // Advanced module LR Code Hook End. + if (\Drupal::currentUser()->isAnonymous()) { + if (isset($userprofile) && isset($userprofile->ID) && $userprofile->ID != '') { + $userprofile = $this->usermanager->getUserData($userprofile); + + \Drupal::service('session')->set('user_verify', 0); + + if (empty($userprofile->Email_value)) { + + $uid = $this->usermanager->checkProviderID($userprofile->ID); + + if ($uid) { + $drupal_user = User::load($uid); + } + + if (isset($drupal_user) && $drupal_user->id()) { + return $this->usermanager->provideLogin($drupal_user, $userprofile); + } + } + return $this->usermanager->checkExistingUser($userprofile); + } + else { + $this->messenger()->addError($this->t('Something went wrong, check your settings.')); + return $this->redirect(""); + } + } + else { + return $this->usermanager->handleUserCallback($userprofile); + } + } + else { + return $this->redirect('user.login'); + } + } +} diff --git a/drupal-10/src/customer_identity_and_access_management/lr_ciam/src/Form/AdvancedSettingsForm.php b/drupal-10/src/customer_identity_and_access_management/lr_ciam/src/Form/AdvancedSettingsForm.php new file mode 100644 index 0000000..04e592f --- /dev/null +++ b/drupal-10/src/customer_identity_and_access_management/lr_ciam/src/Form/AdvancedSettingsForm.php @@ -0,0 +1,261 @@ +config('lr_ciam.settings'); + $apiKey = trim($config->get('api_key')); + $apiSecret = trim($config->get('api_secret')); + // Configuration of which forms to protect, with what challenge. + if (isset($apiKey) && $apiKey != '' && isset($apiSecret) && $apiSecret != '') { + try { + $configObject = new ConfigurationAPI(); + $configOptions = $configObject->getConfigurations(); + } + catch (LoginRadiusException $e) { + \Drupal::logger('ciam')->error($e); + } + + $options = [ + 'output_format' => 'json', + ]; + $decryt_secret_key = encrypt_and_decrypt( $apiSecret, $apiKey, $apiKey, 'd' ); + $query_array = [ + 'apikey' => $apiKey, + 'apisecret' => $decryt_secret_key, + ]; + + try { + $url = "https://config.lrcontent.com/ciam/appInfo/templates"; + $email_templates = Functions::apiClient($url, $query_array, $options); + } + catch (LoginRadiusException $e) { + \Drupal::logger('ciam')->error($e); + } + } + + $form['lr_advanced_settings'] = [ + '#type' => 'details', + '#title' => $this->t('Advanced Options'), + '#open' => TRUE, + ]; + + $form['lr_advanced_settings']['ciam_instant_link_login'] = [ + '#type' => 'radios', + '#title' => $this->t('Enable Passwordless Link Login (?)'), + '#default_value' => $config->get('ciam_instant_link_login') ? $config->get('ciam_instant_link_login') : 'false', + '#options' => [ + 'true' => $this->t('Yes'), + 'false' => $this->t('No'), + ], + ]; + + if (isset($configOptions) && $configOptions->IsInstantSignin->EmailLink) { + $form['lr_advanced_settings']['ciam_instant_link_login_email_template'] = [ + '#type' => 'select', + '#title' => $this->t('Passwordless link login email template (?)'), + '#options' => $this->getEmailTemplate($email_templates->EmailTemplates->InstantSignIn), + '#default_value' => $config->get('ciam_instant_link_login_email_template'), + ]; + } + + if (isset($configOptions) && $configOptions->IsPhoneLogin) { + $form['lr_advanced_settings']['ciam_instant_otp_login'] = [ + '#type' => 'radios', + '#title' => $this->t('Enable passwordless OTP login (?)'), + '#default_value' => $config->get('ciam_instant_otp_login') ? $config->get('ciam_instant_otp_login') : 'false', + '#options' => [ + 'true' => $this->t('Yes'), + 'false' => $this->t('No'), + ], + ]; + + if (isset($configOptions) && $configOptions->IsInstantSignin->SmsOtp) { + $form['lr_advanced_settings']['ciam_sms_template_one_time_passcode'] = [ + '#type' => 'select', + '#title' => $this->t('Passwordless OTP login SMS template (?)'), + '#options' => $this->getEmailTemplate($email_templates->SMSTemplates->OneTimePassCode), + '#default_value' => $config->get('ciam_sms_template_one_time_passcode'), + ]; + } + } + + $form['lr_advanced_settings']['ciam_display_password_strength'] = [ + '#type' => 'radios', + '#title' => $this->t('Enable password strength (?)'), + '#default_value' => $config->get('ciam_display_password_strength') ? $config->get('ciam_display_password_strength') : 'false', + '#options' => [ + 'true' => $this->t('Yes'), + 'false' => $this->t('No'), + ], + ]; + + $form['lr_advanced_settings']['ciam_notification_timeout_setting'] = [ + '#type' => 'number', + '#title' => $this->t('Messages timeout setting (in seconds) (?)'), + '#default_value' => $config->get('ciam_notification_timeout_setting'), + '#min' => 0, + '#step' => 1, + ]; + + $form['lr_advanced_settings']['ciam_save_mail_in_db'] = [ + '#type' => 'radios', + '#title' => $this->t('Do you want to store customer email address in the database (?)'), + '#default_value' => $config->get('ciam_save_mail_in_db') ? $config->get('ciam_save_mail_in_db') : 'true', + '#options' => [ + 'true' => $this->t('Yes'), + 'false' => $this->t('No'), + ], + ]; + + $form['lr_advanced_settings']['ciam_save_name_in_db'] = [ + '#type' => 'radios', + '#title' => $this->t('Do you want to store customer first and last name as their username in the database (?)'), + '#default_value' => $config->get('ciam_save_name_in_db') ? $config->get('ciam_save_name_in_db') : 'true', + '#options' => [ + 'true' => $this->t('Yes'), + 'false' => $this->t('No'), + ], + ]; + + $form['lr_advanced_settings']['ciam_delete_lr_useraccount'] = [ + '#type' => 'radios', + '#title' => $this->t('Do you want to delete the customer profile from the LoginRadius database on account delete in Drupal (?)'), + '#default_value' => $config->get('ciam_delete_lr_useraccount') ? $config->get('ciam_delete_lr_useraccount') : 'true', + '#options' => [ + 'true' => $this->t('Yes'), + 'false' => $this->t('No'), + ], + ]; + + $form['lr_advanced_settings']['ciam_terms_and_condition_html'] = [ + '#type' => 'text_format', + '#title' => $this->t('Terms and Conditions (?)'), + '#default_value' => $config->get('ciam_terms_and_condition_html') ? $config->get('ciam_terms_and_condition_html')['value'] : '', + ]; + + $form['lr_advanced_settings']['ciam_custom_options'] = [ + '#type' => 'textarea', + '#title' => $this->t('Custom options for LoginRadius interface (?)'), + '#id' => 'ciam_custom_options', + '#rows' => 4, + '#default_value' => $config->get('ciam_custom_options'), + '#attributes' => [ + 'onchange' => "lrCheckValidJson();", + ], + '#description' => $this->t('Insert custom option like commonOptions.usernameLogin = true;'), + ]; + + $form['lr_advanced_settings']['ciam_registation_form_schema'] = [ + '#type' => 'textarea', + '#id' => 'ciam_registration_schema', + '#title' => $this->t('Registration form schema (?)'), + '#rows' => 4, + '#default_value' => $config->get('ciam_registation_form_schema'), + '#suffix' => "" + ]; + + // Submit button. + $form['actions'] = ['#type' => 'actions']; + $form['actions']['submit'] = [ + '#type' => 'submit', + '#attributes' => ['class' => ['advancedSettingSave']], + '#value' => $this->t('Save configurations'), + ]; + + return parent::buildForm($form, $form_state); + } + + /** + * Get email template. + */ + public function getEmailTemplate($template_array) { + $template = []; + if (is_array($template_array) || is_object($template_array)) { + foreach ($template_array as $name) { + $template[$name] = $name; + } + } + if (empty($template)) { + $template['default'] = 'default'; + } + return array_merge(['' => $this->t('- Select -')], $template); + } + + + /** + * Form submit handler. + */ + public function submitForm(array &$form, FormStateInterface $form_state) { + $sl_config = \Drupal::config('lr_ciam.settings'); + $api_key = $sl_config->get('api_key'); + $api_secret = $sl_config->get('api_secret'); + if ($api_key == '') { + $api_key = ''; + $api_secret = ''; + } + + $decryt_secret_key = encrypt_and_decrypt( $api_secret, $api_key, $api_key, 'd' ); + $data = lr_ciam_get_authentication($api_key, $decryt_secret_key); + if (isset($data['status']) && $data['status'] != 'status') { + $this->messenger()->addError($this->t($data['message'])); + return FALSE; + } + + Database::getConnection()->delete('config') + ->condition('name', 'lr_ciam.settings')->execute(); + + if (count(\Drupal::moduleHandler()->getImplementations('add_advance_config_settings')) > 0) { + // Call all modules that implement the hook, + // and let them make changes to $variables. + $data = \Drupal::moduleHandler()->invokeAll('add_advance_config_settings'); + } + + if (isset($data) && is_array($data)) { + foreach ($data as $value) { + $this->config('lr_ciam.settings') + ->set($value, $form_state->getValue($value)) + ->save(); + } + } + + $this->messenger()->addStatus($this->t('Settings have been saved.')); + // Clear page cache. + foreach (Cache::getBins() as $service_id => $cache_backend) { + if ($service_id == 'dynamic_page_cache') { + $cache_backend->deleteAll(); + } + } + } + +} diff --git a/drupal-10/src/customer_identity_and_access_management/lr_ciam/src/Form/AuthenticationSettingsForm.php b/drupal-10/src/customer_identity_and_access_management/lr_ciam/src/Form/AuthenticationSettingsForm.php new file mode 100644 index 0000000..4eb85d3 --- /dev/null +++ b/drupal-10/src/customer_identity_and_access_management/lr_ciam/src/Form/AuthenticationSettingsForm.php @@ -0,0 +1,378 @@ +config('lr_ciam.settings'); + $apiKey = trim($config->get('api_key')); + $apiSecret = trim($config->get('api_secret')); + // Configuration of which forms to protect, with what challenge. + if (isset($apiKey) && $apiKey != '' && isset($apiSecret) && $apiSecret != '') { + try { + $configObject = new ConfigurationAPI(); + $configOptions = $configObject->getConfigurations(); + } + catch (LoginRadiusException $e) { + \Drupal::logger('ciam')->error($e); + } + + $options = [ + 'output_format' => 'json', + ]; + $decryt_secret_key = encrypt_and_decrypt( $apiSecret, $apiKey, $apiKey, 'd' ); + $query_array = [ + 'apikey' => $apiKey, + 'apisecret' => $decryt_secret_key, + ]; + + try { + $url = "https://config.lrcontent.com/ciam/appInfo/templates"; + $email_templates = Functions::apiClient($url, $query_array, $options); + } + catch (LoginRadiusException $e) { + \Drupal::logger('ciam')->error($e); + } + } + + $form['lr_basic_settings'] = [ + '#type' => 'details', + '#title' => $this->t('Redirection settings after login (?)'), + ]; + + $form['lr_basic_settings']['login_redirection'] = [ + '#type' => 'radios', + '#default_value' => $config->get('login_redirection') ? $config->get('login_redirection') : 0, + '#options' => [ + 0 => $this->t('Redirect to same page'), + 1 => $this->t('Redirect to profile page'), + 2 => $this->t('Redirect to custom page (If you want user to be redirected to specific URL after login)'), + ], + ]; + + $form['lr_basic_settings']['login_redirection']['custom_login_url'] = [ + '#type' => 'textfield', + '#weight' => 50, + '#default_value' => $config->get('custom_login_url'), + ]; + + $form['lr_email_auth_settings'] = [ + '#type' => 'details', + '#title' => $this->t('Email Authentication Settings'), + ]; + + $form['lr_email_auth_settings']['ciam_prompt_password_on_social_login'] = [ + '#type' => 'radios', + '#title' => $this->t('Enable prompt password on Social login (?)'), + '#default_value' => $config->get('ciam_prompt_password_on_social_login') ? $config->get('ciam_prompt_password_on_social_login') : 'false', + '#options' => [ + 'true' => $this->t('Yes'), + 'false' => $this->t('No'), + ], + ]; + + $form['lr_email_auth_settings']['ciam_user_name_login'] = [ + '#type' => 'radios', + '#title' => $this->t('Enable login with username (?)'), + '#default_value' => $config->get('ciam_user_name_login') ? $config->get('ciam_user_name_login') : 'false', + '#options' => [ + 'true' => $this->t('Yes'), + 'false' => $this->t('No'), + ], + ]; + + $form['lr_email_auth_settings']['ciam_ask_email_for_unverified_user_login'] = [ + '#type' => 'radios', + '#title' => $this->t('Ask for email from unverified user (?)'), + '#default_value' => $config->get('ciam_ask_email_for_unverified_user_login') ? $config->get('ciam_ask_email_for_unverified_user_login') : 'false', + '#options' => [ + 'true' => $this->t('Yes'), + 'false' => $this->t('No'), + ], + ]; + + $form['lr_email_auth_settings']['ciam_ask_required_fields_on_traditional_login'] = [ + '#type' => 'radios', + '#title' => $this->t('Ask for required field on traditional login (?)'), + '#default_value' => $config->get('ciam_ask_required_fields_on_traditional_login') ? $config->get('ciam_ask_required_fields_on_traditional_login') : 'false', + '#options' => [ + 'true' => $this->t('Yes'), + 'false' => $this->t('No'), + ], + ]; + if (isset($email_templates->EmailTemplates)) { + $form['lr_email_auth_settings']['ciam_welcome_email_template'] = [ + '#title' => $this->t('Welcome email template (?)'), + '#type' => 'select', + '#options' => $this->getEmailTemplate($email_templates->EmailTemplates->Welcome), + '#default_value' => $config->get('ciam_welcome_email_template'), + ]; + $form['lr_email_auth_settings']['ciam_email_verification_template'] = [ + '#type' => 'select', + '#title' => $this->t('Account verification email template (?)'), + '#options' => $this->getEmailTemplate($email_templates->EmailTemplates->Verification), + '#default_value' => $config->get('ciam_email_verification_template'), + ]; + $form['lr_email_auth_settings']['ciam_reset_password_email_template'] = [ + '#type' => 'select', + '#title' => $this->t('Reset password email template (?)'), + '#options' => $this->getEmailTemplate($email_templates->EmailTemplates->ResetPassword), + '#default_value' => $config->get('ciam_reset_password_email_template'), + ]; + if (isset($configOptions) && $configOptions->TwoFactorAuthentication->IsEnabled) { + $form['lr_email_auth_settings']['ciam_sms_template_2fa'] = [ + '#type' => 'select', + '#title' => $this->t('Two-factor authentication SMS template (?)'), + '#options' => $this->getEmailTemplate($email_templates->SMSTemplates->SecondFactorAuthentication), + '#default_value' => $config->get('ciam_sms_template_2fa'), + ]; + } + } + + if (isset($configOptions) && $configOptions->IsPhoneLogin) { + $form['lr_phone_auth_settings'] = [ + '#type' => 'details', + '#title' => $this->t('Phone Authentication Settings'), + ]; + $form['lr_phone_auth_settings']['ciam_check_phone_no_availability'] = [ + '#type' => 'radios', + '#title' => $this->t('Check Phone number exist or not (?)'), + '#default_value' => $config->get('ciam_check_phone_no_availability') ? $config->get('ciam_check_phone_no_availability') : 'false', + '#options' => [ + 'true' => $this->t('Yes'), + 'false' => $this->t('No'), + ], + ]; + $form['lr_phone_auth_settings']['ciam_welcome_sms_template'] = [ + '#type' => 'select', + '#title' => $this->t('Phone welcome SMS template (?)'), + '#options' => $this->getEmailTemplate($email_templates->SMSTemplates->Welcome), + '#default_value' => $config->get('ciam_welcome_sms_template'), + ]; + $form['lr_phone_auth_settings']['ciam_sms_template_phone_verification'] = [ + '#type' => 'select', + '#title' => $this->t('Phone verification SMS template (?)'), + '#options' => $this->getEmailTemplate($email_templates->SMSTemplates->Verification), + '#default_value' => $config->get('ciam_sms_template_phone_verification'), + ]; + $form['lr_phone_auth_settings']['ciam_sms_template_reset_password'] = [ + '#type' => 'select', + '#title' => $this->t('Password reset SMS template (?)'), + '#options' => $this->getEmailTemplate($email_templates->SMSTemplates->ResetPassword), + '#default_value' => $config->get('ciam_sms_template_reset_password'), + ]; + $form['lr_phone_auth_settings']['ciam_sms_template_change_phone_no'] = [ + '#type' => 'select', + '#title' => $this->t('Change phone number SMS template (?)'), + '#options' => $this->getEmailTemplate($email_templates->SMSTemplates->ChangePhoneNo), + '#default_value' => $config->get('ciam_sms_template_change_phone_no'), + ]; + } + + $form['lr_field_mapping'] = [ + '#type' => 'details', + '#title' => $this->t('Field Mapping'), + ]; + $form['lr_field_mapping']['user_fields'] = [ + '#title' => 'user fields', + '#type' => 'details', + '#tree' => TRUE, + '#weight' => 5, + '#open' => TRUE, + ]; + $properties = $this->fieldUserProperties(); + $property_options = []; + + + foreach ($properties as $property => $property_info) { + if (isset($property_info['field_types'])) { + foreach ($property_info['field_types'] as $field_type) { + $property_options[$field_type][$property] = $property_info['label']; + } + } + } + + $field_defaults = $config->get('user_fields', []); + $entity_type = 'user'; + foreach (\Drupal::service('entity_field.manager') + ->getFieldDefinitions($entity_type, 'user') as $field_name => $field_definition) { + $user_bundle = $field_definition->getTargetBundle(); + if (!empty($user_bundle)) { + $instances[$field_name]['type'] = $field_definition->getType(); + $instances[$field_name]['label'] = $field_definition->getLabel(); + } + } + + foreach ($instances as $field_name => $instance) { + $field = FieldStorageConfig::loadByName($entity_type, $field_name); + + if (isset($property_options[$field->getType()])) { + $options = array_merge(['' => $this->t('- Do not import -')], $property_options[$field->getType()]); + + $form['lr_field_mapping']['user_fields'][$field->getName()] = [ + '#title' => $instance['label'], + '#type' => 'select', + '#options' => $options, + '#default_value' => isset($field_defaults[$field_name]) ? $field_defaults[$field_name] : '', + ]; + } + else { + $form['lr_field_mapping']['user_fields'][$field->getName()] = [ + '#title' => $instance['label'], + '#type' => 'form_element', + '#children' => $this->t('This field cannot be mapped with LR field.'), + '#theme_wrappers' => ['form_element'], + ]; + } + } + + // Submit button. + $form['actions'] = ['#type' => 'actions']; + $form['actions']['submit'] = [ + '#type' => 'submit', + '#value' => $this->t('Save configuration'), + ]; + + return parent::buildForm($form, $form_state); + } + + /** + * Get email template. + */ + public function getEmailTemplate($template_array) { + $template = []; + if (is_array($template_array) || is_object($template_array)) { + foreach ($template_array as $name) { + $template[$name] = $name; + } + } + if (empty($template)) { + $template['default'] = 'default'; + } + return array_merge(['' => $this->t('- Select -')], $template); + } + +/** + * Get fields for mapping. + */ +public function fieldUserProperties() { + $config = $this->config('lr_ciam.settings'); + $apiKey = trim($config->get('api_key')); + $apiSecret = trim($config->get('api_secret')); + if (isset($apiKey) && $apiKey != '' && isset($apiSecret) && $apiSecret != '') { + try { + $configObject = new ConfigurationAPI(); + $configOptions = $configObject->getConfigurations(); + } + catch (LoginRadiusException $e) { + \Drupal::logger('ciam')->error($e); + } + + $common = []; + if(isset($configOptions->RegistrationFormSchema)){ + foreach($configOptions->RegistrationFormSchema as $key => $val){ + + if($val->type != 'email' && $val->type != 'password' && $val->name != 'pin') { + + if($val->type == 'option'){ + $common[str_replace(' ', '', $val->display)]['label'] = $this->t($val->display); + $common[str_replace(' ', '', $val->display)]['field_types'] = ['text', 'list_string']; + } else if($val->type == 'multi'){ + $common[str_replace(' ', '', $val->name)]['label'] = $this->t($val->display); + $common[str_replace(' ', '', $val->name)]['field_types'] = ['text', 'boolean']; + }else if($val->name == 'birthdate'){ + $common[str_replace(' ', '', $val->display)]['label'] = $this->t($val->display); + $common[str_replace(' ', '', $val->display)]['field_types'] = ['text', 'date', 'datetime', 'datestamp']; + } else { + $common[str_replace(' ', '', $val->display)]['label'] = $this->t($val->display); + $common[str_replace(' ', '', $val->display)]['field_types'] = ['text', $val->type]; + } + } + } + } + + } + \Drupal::moduleHandler()->alter('fieldUserProperties', $common); + ksort($common); + $common = array_map("unserialize", array_unique(array_map("serialize", $common))); + return $common; + } + + /** + * Form submit handler. + */ + public function submitForm(array &$form, FormStateInterface $form_state) { + $config = \Drupal::config('lr_ciam.settings'); + $api_key = $config->get('api_key'); + $api_secret = $config->get('api_secret'); + if ($api_key == '') { + $api_key = ''; + $api_secret = ''; + } + $decryt_secret_key = encrypt_and_decrypt( $api_secret, $api_key, $api_key, 'd' ); + $data = lr_ciam_get_authentication($api_key, $decryt_secret_key); + if (isset($data['status']) && $data['status'] != 'status') { + $this->messenger()->addError($this->t($data['message'])); + return FALSE; + } + + Database::getConnection()->delete('config') + ->condition('name', 'lr_ciam.settings')->execute(); + + $this->config('lr_ciam.settings') + ->set('user_fields', $form_state->getValue('user_fields')) + ->set('login_redirection', $form_state->getValue('login_redirection')) + ->set('custom_login_url', $form_state->getValue('custom_login_url')) + ->save(); + if (count(\Drupal::moduleHandler()->getImplementations('add_extra_config_settings')) > 0) { + // Call all modules that implement the hook, + // and let them make changes to $variables. + $data = \Drupal::moduleHandler()->invokeAll('add_extra_config_settings'); + } + + if (isset($data) && is_array($data)) { + foreach ($data as $value) { + $this->config('lr_ciam.settings') + ->set($value, $form_state->getValue($value)) + ->save(); + } + } + $this->messenger()->addStatus($this->t('Settings have been saved.')); + + // Clear page cache. + foreach (Cache::getBins() as $service_id => $cache_backend) { + if ($service_id == 'dynamic_page_cache') { + $cache_backend->deleteAll(); + } + } + } +} diff --git a/drupal-10/src/customer_identity_and_access_management/lr_ciam/src/Form/CiamSettingsForm.php b/drupal-10/src/customer_identity_and_access_management/lr_ciam/src/Form/CiamSettingsForm.php new file mode 100644 index 0000000..96482cf --- /dev/null +++ b/drupal-10/src/customer_identity_and_access_management/lr_ciam/src/Form/CiamSettingsForm.php @@ -0,0 +1,110 @@ +config('lr_ciam.settings'); + $form['#attached']['library'][] = 'user/drupal.user.admin'; + // Configuration of which forms to protect, with what challenge. + + if ($config->get('api_key') != '' && $config->get('api_secret')) { + $is_phone_login = \Drupal::service('session')->get('is_phone_login', []); + if (isset($is_phone_login) && $is_phone_login) { + $form['phone_warning_block'] = [ + '#type' => 'fieldset', + '#title' => $this->t('Important Note:'), + '#description' => $this->t('If only the Phone Id Login options is enabled for the App, a random Email Id will be generated if a user registered using the PhoneID. Format of random email id is: "randomid+timestamp@yourdomain.com"'), + ]; + } + } + + $form['lr_settings'] = [ + '#type' => 'details', + '#title' => $this->t('LoginRadius API Configurations'), + '#description' => $this->t('To access the loginradius web service please enter the credentials below ( How to get it? )'), + '#open' => TRUE, + ]; + + $form['lr_settings']['api_key'] = [ + '#type' => 'textfield', + '#title' => $this->t('LoginRadius API Key'), + '#default_value' => $config->get('api_key'), + '#required' => TRUE, + ]; + + $decrypted_secret_key = encrypt_and_decrypt( $config->get('api_secret'), $config->get('api_key'), $config->get('api_key'), 'd' ); + $form['lr_settings']['api_secret'] = [ + '#type' => 'textfield', + "#suffix" => '
Show
', + '#title' => $this->t('LoginRadius API Secret'), + '#default_value' => $decrypted_secret_key, + '#id' => 'secret', + '#required' => TRUE, + ]; + + // Submit button. + $form['actions'] = ['#type' => 'actions']; + $form['actions']['submit'] = [ + '#type' => 'submit', + '#value' => $this->t('Save configuration'), + ]; + return parent::buildForm($form, $form_state); + } + + /** + * {@inheritdoc} + */ + public function submitForm(array &$form, FormStateInterface $form_state) { + $data = lr_ciam_get_authentication($form_state->getValue('api_key'), $form_state->getValue('api_secret')); + $configOptions = lr_ciam_get_configuration($form_state->getValue('api_key')); + \Drupal::service('session')->set('is_phone_login', isset($configOptions->IsPhoneLogin) ? $configOptions->IsPhoneLogin : ''); + if (isset($data['status']) && $data['status'] != 'status') { + $this->messenger()->addError($this->t($data['message'])); + return FALSE; + } + + $encrypted_secret_key = encrypt_and_decrypt( $form_state->getValue('api_secret'), $form_state->getValue('api_key'), $form_state->getValue('api_key'), 'e' ); + parent::SubmitForm($form, $form_state); + $this->config('lr_ciam.settings') + + ->set('api_key', $form_state->getValue('api_key')) + ->set('api_secret', $encrypted_secret_key) + ->set('api_request_signing', (isset($configOptions['response']->ApiRequestSigningConfig->IsEnabled) && $configOptions['response']->ApiRequestSigningConfig->IsEnabled) ? 'true' : 'false') + ->set('sso_site_name', isset($configOptions['response']->AppName) ? $configOptions['response']->AppName : '') + ->set('custom_hub_domain', isset($configOptions['response']->CustomDomain) ? $configOptions['response']->CustomDomain : '') + ->save(); + + // Clear page cache. + foreach (Cache::getBins() as $service_id => $cache_backend) { + if ($service_id == 'dynamic_page_cache') { + $cache_backend->deleteAll(); + } + } + } +} diff --git a/drupal-10/src/customer_identity_and_access_management/lr_ciam/src/Plugin/Block/UserForgotPassBlock.php b/drupal-10/src/customer_identity_and_access_management/lr_ciam/src/Plugin/Block/UserForgotPassBlock.php new file mode 100644 index 0000000..3e27c2c --- /dev/null +++ b/drupal-10/src/customer_identity_and_access_management/lr_ciam/src/Plugin/Block/UserForgotPassBlock.php @@ -0,0 +1,63 @@ + 'user_pass', + '#items' => [], + ]; + } + + /** + * {@inheritdoc} + */ + public function blockForm($form, FormStateInterface $form_state) { + $form = parent::blockForm($form, $form_state); + + $config = $this->getConfiguration(); + + $form['forgot_block_link_login'] = [ + '#type' => 'textfield', + '#title' => $this->t('Enter the link to custom login interface'), + '#default_value' => isset($config['forgot_block_link_login']) ? $config['forgot_block_link_login'] : '', + ]; + + $form['forgot_block_link_register'] = [ + '#type' => 'textfield', + '#title' => $this->t('Enter the link to custom register interface'), + '#default_value' => isset($config['forgot_block_link_register']) ? $config['forgot_block_link_register'] : '', + ]; + + return $form; + } + + /** + * {@inheritdoc} + */ + public function blockSubmit($form, FormStateInterface $form_state) { + parent::blockSubmit($form, $form_state); + $values = $form_state->getValues(); + $this->configuration['forgot_block_link_login'] = $values['forgot_block_link_login']; + $this->configuration['forgot_block_link_register'] = $values['forgot_block_link_register']; + } + +} diff --git a/drupal-10/src/customer_identity_and_access_management/lr_ciam/src/Plugin/Block/UserRegistrationBlock.php b/drupal-10/src/customer_identity_and_access_management/lr_ciam/src/Plugin/Block/UserRegistrationBlock.php new file mode 100644 index 0000000..f65ae16 --- /dev/null +++ b/drupal-10/src/customer_identity_and_access_management/lr_ciam/src/Plugin/Block/UserRegistrationBlock.php @@ -0,0 +1,63 @@ + 'user_register', + '#items' => [], + ]; + } + + /** + * {@inheritdoc} + */ + public function blockForm($form, FormStateInterface $form_state) { + $form = parent::blockForm($form, $form_state); + + $config = $this->getConfiguration(); + + $form['register_block_link_login'] = [ + '#type' => 'textfield', + '#title' => $this->t('Enter the link to custom login interface'), + '#default_value' => isset($config['register_block_link_login']) ? $config['register_block_link_login'] : '', + ]; + + $form['register_block_link_forgot'] = [ + '#type' => 'textfield', + '#title' => $this->t('Enter the link to custom forgot interface'), + '#default_value' => isset($config['register_block_link_forgot']) ? $config['register_block_link_forgot'] : '', + ]; + + return $form; + } + + /** + * {@inheritdoc} + */ + public function blockSubmit($form, FormStateInterface $form_state) { + parent::blockSubmit($form, $form_state); + $values = $form_state->getValues(); + $this->configuration['register_block_link_login'] = $values['register_block_link_login']; + $this->configuration['register_block_link_forgot'] = $values['register_block_link_forgot']; + } + +} diff --git a/drupal-10/src/customer_identity_and_access_management/lr_ciam/src/Plugin/Block/UserSocialLoginBlock.php b/drupal-10/src/customer_identity_and_access_management/lr_ciam/src/Plugin/Block/UserSocialLoginBlock.php new file mode 100644 index 0000000..3fb9dd1 --- /dev/null +++ b/drupal-10/src/customer_identity_and_access_management/lr_ciam/src/Plugin/Block/UserSocialLoginBlock.php @@ -0,0 +1,63 @@ + 'user_login', + '#items' => [], + ]; + } + + /** + * {@inheritdoc} + */ + public function blockForm($form, FormStateInterface $form_state) { + $form = parent::blockForm($form, $form_state); + + $config = $this->getConfiguration(); + + $form['login_block_link_register'] = [ + '#type' => 'textfield', + '#title' => $this->t('Enter the link to custom register interface'), + '#default_value' => isset($config['login_block_link_register']) ? $config['login_block_link_register'] : '', + ]; + + $form['login_block_link_forgot'] = [ + '#type' => 'textfield', + '#title' => $this->t('Enter the link to custom forgot interface'), + '#default_value' => isset($config['login_block_link_forgot']) ? $config['login_block_link_forgot'] : '', + ]; + + return $form; + } + + /** + * {@inheritdoc} + */ + public function blockSubmit($form, FormStateInterface $form_state) { + parent::blockSubmit($form, $form_state); + $values = $form_state->getValues(); + $this->configuration['login_block_link_register'] = $values['login_block_link_register']; + $this->configuration['login_block_link_forgot'] = $values['login_block_link_forgot']; + } + +} diff --git a/drupal-10/src/customer_identity_and_access_management/lr_ciam/src/RedirectMiddleware.php b/drupal-10/src/customer_identity_and_access_management/lr_ciam/src/RedirectMiddleware.php new file mode 100644 index 0000000..ce91daa --- /dev/null +++ b/drupal-10/src/customer_identity_and_access_management/lr_ciam/src/RedirectMiddleware.php @@ -0,0 +1,60 @@ +httpKernel = $http_kernel; + } + + /** + * {@inheritdoc} + */ + public function handle(Request $request, int $type = self::MAIN_REQUEST, bool $catch = true): Response { + $response = $this->httpKernel->handle($request, $type, $catch); + return $this->redirectResponse ?: $response; + } + + /** + * Stores the requested redirect response. + * + * @param RedirectResponse|null $redirectResponse + * Redirect response. + */ + public function setRedirectResponse(?RedirectResponse $redirectResponse) { + $this->redirectResponse = $redirectResponse; + } + +} diff --git a/drupal-10/src/customer_identity_and_access_management/lr_ciam/src/Routing/RouteSubscriber.php b/drupal-10/src/customer_identity_and_access_management/lr_ciam/src/Routing/RouteSubscriber.php new file mode 100644 index 0000000..220e6a3 --- /dev/null +++ b/drupal-10/src/customer_identity_and_access_management/lr_ciam/src/Routing/RouteSubscriber.php @@ -0,0 +1,30 @@ +get('lr_ciam.settings_form')) { + $route->setPath('admin/config/people/ciam'); + + $defaults = $route->getDefaults(); + $defaults['_title'] = "LoginRadius"; + + $route->setDefaults($defaults); + } + if ($route = $collection->get('advanced.settings_form')) { + $route->setPath('admin/config/people/ciam/advanced'); + } + } + +} diff --git a/drupal-10/src/customer_identity_and_access_management/lr_ciam/theme/2fa_container.html.twig b/drupal-10/src/customer_identity_and_access_management/lr_ciam/theme/2fa_container.html.twig new file mode 100644 index 0000000..5fcb437 --- /dev/null +++ b/drupal-10/src/customer_identity_and_access_management/lr_ciam/theme/2fa_container.html.twig @@ -0,0 +1,3 @@ +
+ +
diff --git a/drupal-10/src/customer_identity_and_access_management/lr_ciam/theme/add_email.html.twig b/drupal-10/src/customer_identity_and_access_management/lr_ciam/theme/add_email.html.twig new file mode 100644 index 0000000..b3455f8 --- /dev/null +++ b/drupal-10/src/customer_identity_and_access_management/lr_ciam/theme/add_email.html.twig @@ -0,0 +1,13 @@ +
+ +
diff --git a/drupal-10/src/customer_identity_and_access_management/lr_ciam/theme/change_password.html.twig b/drupal-10/src/customer_identity_and_access_management/lr_ciam/theme/change_password.html.twig new file mode 100644 index 0000000..926f53d --- /dev/null +++ b/drupal-10/src/customer_identity_and_access_management/lr_ciam/theme/change_password.html.twig @@ -0,0 +1,13 @@ + +
+
+ {% include 'lr_loading.html.twig' %} +
diff --git a/drupal-10/src/customer_identity_and_access_management/lr_ciam/theme/ciam_social_widget_container.html.twig b/drupal-10/src/customer_identity_and_access_management/lr_ciam/theme/ciam_social_widget_container.html.twig new file mode 100644 index 0000000..464197c --- /dev/null +++ b/drupal-10/src/customer_identity_and_access_management/lr_ciam/theme/ciam_social_widget_container.html.twig @@ -0,0 +1,17 @@ + +
+
+{{ attach_library('lr_ciam/drupal.social_interface') }} \ No newline at end of file diff --git a/drupal-10/src/customer_identity_and_access_management/lr_ciam/theme/lr_backup_codes.html.twig b/drupal-10/src/customer_identity_and_access_management/lr_ciam/theme/lr_backup_codes.html.twig new file mode 100644 index 0000000..6bbed27 --- /dev/null +++ b/drupal-10/src/customer_identity_and_access_management/lr_ciam/theme/lr_backup_codes.html.twig @@ -0,0 +1,15 @@ +
+
Reset Code
+
+ + + diff --git a/drupal-10/src/customer_identity_and_access_management/lr_ciam/theme/lr_ciam_linked.html.twig b/drupal-10/src/customer_identity_and_access_management/lr_ciam/theme/lr_ciam_linked.html.twig new file mode 100644 index 0000000..bc6d1d9 --- /dev/null +++ b/drupal-10/src/customer_identity_and_access_management/lr_ciam/theme/lr_ciam_linked.html.twig @@ -0,0 +1,39 @@ + + +{{ attach_library('lr_ciam/drupal.account_linking') }} + diff --git a/drupal-10/src/customer_identity_and_access_management/lr_ciam/theme/lr_ciam_popup.html.twig b/drupal-10/src/customer_identity_and_access_management/lr_ciam/theme/lr_ciam_popup.html.twig new file mode 100644 index 0000000..8de7e9a --- /dev/null +++ b/drupal-10/src/customer_identity_and_access_management/lr_ciam/theme/lr_ciam_popup.html.twig @@ -0,0 +1,14 @@ +{{ attach_library('lr_ciam/drupal.ciam_email_popup') }} + + + diff --git a/drupal-10/src/customer_identity_and_access_management/lr_ciam/theme/lr_loading.html.twig b/drupal-10/src/customer_identity_and_access_management/lr_ciam/theme/lr_loading.html.twig new file mode 100644 index 0000000..9ae3423 --- /dev/null +++ b/drupal-10/src/customer_identity_and_access_management/lr_ciam/theme/lr_loading.html.twig @@ -0,0 +1,13 @@ +{{ attach_library('lr_ciam/drupal.loading') }} + \ No newline at end of file diff --git a/drupal-10/src/customer_identity_and_access_management/lr_ciam/theme/lr_message.html.twig b/drupal-10/src/customer_identity_and_access_management/lr_ciam/theme/lr_message.html.twig new file mode 100644 index 0000000..181a14d --- /dev/null +++ b/drupal-10/src/customer_identity_and_access_management/lr_ciam/theme/lr_message.html.twig @@ -0,0 +1,8 @@ + diff --git a/drupal-10/src/customer_identity_and_access_management/lr_ciam/theme/lr_profile_editor.html.twig b/drupal-10/src/customer_identity_and_access_management/lr_ciam/theme/lr_profile_editor.html.twig new file mode 100644 index 0000000..c99109c --- /dev/null +++ b/drupal-10/src/customer_identity_and_access_management/lr_ciam/theme/lr_profile_editor.html.twig @@ -0,0 +1,3 @@ +
+
+
diff --git a/drupal-10/src/customer_identity_and_access_management/lr_ciam/theme/lr_update_phone.html.twig b/drupal-10/src/customer_identity_and_access_management/lr_ciam/theme/lr_update_phone.html.twig new file mode 100644 index 0000000..5e15a86 --- /dev/null +++ b/drupal-10/src/customer_identity_and_access_management/lr_ciam/theme/lr_update_phone.html.twig @@ -0,0 +1,3 @@ +
+ +
diff --git a/drupal-10/src/customer_identity_and_access_management/lr_ciam/theme/remove_email.html.twig b/drupal-10/src/customer_identity_and_access_management/lr_ciam/theme/remove_email.html.twig new file mode 100644 index 0000000..49846c3 --- /dev/null +++ b/drupal-10/src/customer_identity_and_access_management/lr_ciam/theme/remove_email.html.twig @@ -0,0 +1,13 @@ +
+ +
diff --git a/drupal-10/src/customer_identity_and_access_management/lr_ciam/theme/set_password.html.twig b/drupal-10/src/customer_identity_and_access_management/lr_ciam/theme/set_password.html.twig new file mode 100644 index 0000000..0604218 --- /dev/null +++ b/drupal-10/src/customer_identity_and_access_management/lr_ciam/theme/set_password.html.twig @@ -0,0 +1,28 @@ + +
+
+
+
+ +
+ +
+
+ + +
+ +
+ +
+
+ {% include 'lr_loading.html.twig' %} +
diff --git a/drupal-10/src/customer_identity_and_access_management/lr_ciam/theme/user_login.html.twig b/drupal-10/src/customer_identity_and_access_management/lr_ciam/theme/user_login.html.twig new file mode 100644 index 0000000..7339548 --- /dev/null +++ b/drupal-10/src/customer_identity_and_access_management/lr_ciam/theme/user_login.html.twig @@ -0,0 +1,26 @@ +{{ attach_library('lr_ciam/drupal.user_login') }} +{% if api_key %} + + +{% include 'lr_message.html.twig' %} + +
+ {% include 'ciam_social_widget_container.html.twig' %} + + +
+
+
+
+ + {% if link_register %} + Create new account   + {% endif %} + {% if link_forgot %} + Request new password + {% endif %} + {% include 'lr_loading.html.twig' %} + {% include 'lr_ciam_popup.html.twig' %} +
+ +{% endif %} diff --git a/drupal-10/src/customer_identity_and_access_management/lr_ciam/theme/user_login_form.html.twig b/drupal-10/src/customer_identity_and_access_management/lr_ciam/theme/user_login_form.html.twig new file mode 100644 index 0000000..eddfad2 --- /dev/null +++ b/drupal-10/src/customer_identity_and_access_management/lr_ciam/theme/user_login_form.html.twig @@ -0,0 +1,19 @@ +{{ attach_library('lr_ciam/drupal.user_login') }} +{% if api_key %} + + +{% include 'lr_message.html.twig' %} + +
+ {% include 'ciam_social_widget_container.html.twig' %} + + +
+
+
+
+ {% include 'lr_loading.html.twig' %} + {% include 'lr_ciam_popup.html.twig' %} +
+ +{% endif %} diff --git a/drupal-10/src/customer_identity_and_access_management/lr_ciam/theme/user_pass.html.twig b/drupal-10/src/customer_identity_and_access_management/lr_ciam/theme/user_pass.html.twig new file mode 100644 index 0000000..b705e42 --- /dev/null +++ b/drupal-10/src/customer_identity_and_access_management/lr_ciam/theme/user_pass.html.twig @@ -0,0 +1,17 @@ + +{% if showpassonlogin %} + +{% include 'lr_message.html.twig' %} + +
+
+ {% if link_login %} + Login   + {% endif %} + {% if link_register %} + Create new account + {% endif %} + {% include 'lr_loading.html.twig' %} +
+{% endif %} + {{ attach_library('lr_ciam/drupal.user_pass') }} \ No newline at end of file diff --git a/drupal-10/src/customer_identity_and_access_management/lr_ciam/theme/user_pass_form.html.twig b/drupal-10/src/customer_identity_and_access_management/lr_ciam/theme/user_pass_form.html.twig new file mode 100644 index 0000000..6f1d5fe --- /dev/null +++ b/drupal-10/src/customer_identity_and_access_management/lr_ciam/theme/user_pass_form.html.twig @@ -0,0 +1,17 @@ + +{% if showpassonlogin %} +{% if api_key %} + +{% include 'lr_message.html.twig' %} + +
+
+ {% include 'lr_loading.html.twig' %} +
+{% endif %} +{% else %} + {{ attach_library('lr_ciam/drupal.user_pass') }} +{{ rendered }} +{% endif %} + + diff --git a/drupal-10/src/customer_identity_and_access_management/lr_ciam/theme/user_register.html.twig b/drupal-10/src/customer_identity_and_access_management/lr_ciam/theme/user_register.html.twig new file mode 100644 index 0000000..301e1dd --- /dev/null +++ b/drupal-10/src/customer_identity_and_access_management/lr_ciam/theme/user_register.html.twig @@ -0,0 +1,24 @@ +{{ attach_library('lr_ciam/drupal.user_register') }} +{% if admin_access %} +{% if api_key %} +{% include 'lr_message.html.twig' %} + + {% include 'ciam_social_widget_container.html.twig' %} +
+
+ + {% if link_login %} + Login   + {% endif %} + {% if link_forgot %} + Request new password + {% endif %} + + {% include 'lr_loading.html.twig' %} + {% include 'lr_ciam_popup.html.twig' %} +
+{% endif %} +{% else %} +{{ rendered }} + +{% endif %} diff --git a/drupal-10/src/customer_identity_and_access_management/lr_ciam/theme/user_register_form.html.twig b/drupal-10/src/customer_identity_and_access_management/lr_ciam/theme/user_register_form.html.twig new file mode 100644 index 0000000..f139fab --- /dev/null +++ b/drupal-10/src/customer_identity_and_access_management/lr_ciam/theme/user_register_form.html.twig @@ -0,0 +1,16 @@ +{{ attach_library('lr_ciam/drupal.user_register') }} +{% if admin_access %} +{% if api_key %} +{% include 'lr_message.html.twig' %} + + {% include 'ciam_social_widget_container.html.twig' %} +
+
+ {% include 'lr_loading.html.twig' %} + {% include 'lr_ciam_popup.html.twig' %} +
+{% endif %} +{% else %} +{{ rendered }} + +{% endif %} diff --git a/drupal-10/src/customer_identity_and_access_management/lr_identity_experience_framework/lr_identity_experience_framework.info.yml b/drupal-10/src/customer_identity_and_access_management/lr_identity_experience_framework/lr_identity_experience_framework.info.yml new file mode 100644 index 0000000..4d53461 --- /dev/null +++ b/drupal-10/src/customer_identity_and_access_management/lr_identity_experience_framework/lr_identity_experience_framework.info.yml @@ -0,0 +1,10 @@ +name: Identity Experience Framework +type: module +description: 'Allow users to sign up/login/forgot password etc on Identity Experience Framework.' +package: CIAM LoginRadius +dependencies: + - drupal:lr_ciam +configure: lr_identity_experience_framework.settings_form +version: '5.1.2' +core_version_requirement: ^9.4 || ^10 +project: 'customer_identity_and_access_management' diff --git a/drupal-10/src/customer_identity_and_access_management/lr_identity_experience_framework/lr_identity_experience_framework.install b/drupal-10/src/customer_identity_and_access_management/lr_identity_experience_framework/lr_identity_experience_framework.install new file mode 100644 index 0000000..0f38f3a --- /dev/null +++ b/drupal-10/src/customer_identity_and_access_management/lr_identity_experience_framework/lr_identity_experience_framework.install @@ -0,0 +1,13 @@ +trigger(); + + $destination = ['destination' => "destination"]; + $current_alias = \Drupal::service('path.current')->getPath(); + $enable_ief = $ief_config->get('lr_ief_enable'); + $site_name = $config->get('sso_site_name'); + $custom_hub_domain = $config->get('custom_hub_domain'); + + if ((isset($enable_ief) && $enable_ief == '1') && (isset($site_name) && $site_name != '')) { + if (\Drupal::currentUser()->isAnonymous()) { + $getDestination = \Drupal::request()->query->get('destination'); + if (($current_alias == '/user/login') && (isset($getDestination) && $getDestination == $destination['destination']) || ($current_alias == '/user/login') || ($current_alias == '/user')) { + if(isset($custom_hub_domain) && $custom_hub_domain !== '') { + $url = 'https://' . $custom_hub_domain . '/auth.aspx?action=login&return_url=' . urldecode(lr_ciam_get_callback_url()); + } else { + $url = 'https://' . $site_name . '.hub.loginradius.com/auth.aspx?action=login&return_url=' . urldecode(lr_ciam_get_callback_url()); + } + $response = new RedirectResponse($url); + return $response->send(); + } + elseif (($current_alias == '/user/register') && (isset($getDestination) && $getDestination == $destination['destination']) || ($current_alias == '/user/register')) { + if(isset($custom_hub_domain) && $custom_hub_domain !== '') { + $url = 'https://' . $custom_hub_domain . '/auth.aspx?action=register&return_url=' . urldecode(lr_ciam_get_callback_url()); + } else { + $url = 'https://' . $site_name . '.hub.loginradius.com/auth.aspx?action=register&return_url=' . urldecode(lr_ciam_get_callback_url()); + } + $response = new RedirectResponse($url); + return $response->send(); + } + elseif ($current_alias == '/user/password') { + if(isset($custom_hub_domain) && $custom_hub_domain !== '') { + $response = new RedirectResponse('https://' . $custom_hub_domain . '/auth.aspx?action=forgotpassword&return_url=' . urldecode(lr_ciam_get_callback_url())); + } else { + $response = new RedirectResponse('https://' . $site_name . '.hub.loginradius.com/auth.aspx?action=forgotpassword&return_url=' . urldecode(lr_ciam_get_callback_url())); + } + return $response->send(); + } + } + } +} + +/** + * Implements hook_user_logout(). + */ +function lr_identity_experience_framework_user_logout($account) { + $sso_config = \Drupal::config('lr_sso.settings'); + $ief_config = \Drupal::config('lr_ief.settings'); + $enable_ief = $ief_config->get('lr_ief_enable'); + if ($sso_config->get('sso_enable') != 1 && $enable_ief == '1') { + $config = \Drupal::config('lr_ciam.settings'); + $site_name = $config->get('sso_site_name'); + $base_url = Url::fromRoute('')->setAbsolute()->toString(); + $response = new RedirectResponse('https://' . $site_name . '.hub.loginradius.com/auth.aspx?action=logout&return_url=' . $base_url); + return $response->send(); + } +} diff --git a/drupal-10/src/customer_identity_and_access_management/lr_identity_experience_framework/lr_identity_experience_framework.routing.yml b/drupal-10/src/customer_identity_and_access_management/lr_identity_experience_framework/lr_identity_experience_framework.routing.yml new file mode 100644 index 0000000..a432798 --- /dev/null +++ b/drupal-10/src/customer_identity_and_access_management/lr_identity_experience_framework/lr_identity_experience_framework.routing.yml @@ -0,0 +1,9 @@ +lr_identity_experience_framework.settings_form: + path: 'admin/config/people/ciam/ief' + defaults: + _title: 'LoginRadius' + _form: '\Drupal\lr_identity_experience_framework\Form\IdentityExperienceFrameworkSettingsForm' + requirements: + _permission: 'administer ciam settings' + options: + no_cache: TRUE diff --git a/drupal-10/src/customer_identity_and_access_management/lr_identity_experience_framework/src/Form/IdentityExperienceFrameworkSettingsForm.php b/drupal-10/src/customer_identity_and_access_management/lr_identity_experience_framework/src/Form/IdentityExperienceFrameworkSettingsForm.php new file mode 100644 index 0000000..9fc01e6 --- /dev/null +++ b/drupal-10/src/customer_identity_and_access_management/lr_identity_experience_framework/src/Form/IdentityExperienceFrameworkSettingsForm.php @@ -0,0 +1,82 @@ +config('lr_ief.settings'); + // Configuration of which forms to protect, with what challenge. + $form['ief'] = [ + '#type' => 'details', + '#title' => $this->t('Identity Experience Framework Settings'), + '#open' => TRUE, + ]; + + $form['ief']['lr_ief_enable'] = [ + '#type' => 'radios', + '#title' => $this->t('Enable Identity Experience Framework (?)'), + '#default_value' => $ief_config->get('lr_ief_enable') ? $ief_config->get('lr_ief_enable') : 0, + '#options' => [ + 1 => $this->t('Yes'), + 0 => $this->t('No'), + ], + ]; + + // Submit button. + $form['actions'] = ['#type' => 'actions']; + $form['actions']['submit'] = [ + '#type' => 'submit', + '#value' => $this->t('Save configuration'), + ]; + + return parent::buildForm($form, $form_state); + } + + /** + * {@inheritdoc} + */ + public function submitForm(array &$form, FormStateInterface $form_state) { + $config = $this->config('lr_ciam.settings'); + $api_key = $config->get('api_key'); + $api_secret = $config->get('api_secret'); + if ($api_key == '') { + $api_key = ''; + $api_secret = ''; + } + $decryt_secret_key = encrypt_and_decrypt( $api_secret, $api_key, $api_key, 'd' ); + $data = lr_ciam_get_authentication($api_key, $decryt_secret_key); + if (isset($data['status']) && $data['status'] != 'status') { + $this->messenger()->addError($this->t($data['message'])); + return FALSE; + } + parent::SubmitForm($form, $form_state); + $this->config('lr_ief.settings') + ->set('lr_ief_enable', $form_state->getValue('lr_ief_enable')) + ->save(); + } + +} diff --git a/drupal-10/src/customer_identity_and_access_management/lr_simple_oauth/lr_simple_oauth.info.yml b/drupal-10/src/customer_identity_and_access_management/lr_simple_oauth/lr_simple_oauth.info.yml new file mode 100644 index 0000000..5b2ee42 --- /dev/null +++ b/drupal-10/src/customer_identity_and_access_management/lr_simple_oauth/lr_simple_oauth.info.yml @@ -0,0 +1,8 @@ +name: LoginRadius Simple OAuth +type: module +description: LoginRadius OAuth authentication integration with Simple OAuth. +package: CIAM LoginRadius +dependencies: + - drupal:lr_ciam + - drupal:simple_oauth +core_version_requirement: ^9.4 || ^10 diff --git a/drupal-10/src/customer_identity_and_access_management/lr_simple_oauth/lr_simple_oauth.module b/drupal-10/src/customer_identity_and_access_management/lr_simple_oauth/lr_simple_oauth.module new file mode 100644 index 0000000..fbacf53 --- /dev/null +++ b/drupal-10/src/customer_identity_and_access_management/lr_simple_oauth/lr_simple_oauth.module @@ -0,0 +1,24 @@ +' . t('About') . ''; + $output .= '

' . t('LoginRadius OAuth authentication integration with Simple OAuth.') . '

'; + return $output; + + default: + } +} diff --git a/drupal-10/src/customer_identity_and_access_management/lr_simple_oauth/lr_simple_oauth.services.yml b/drupal-10/src/customer_identity_and_access_management/lr_simple_oauth/lr_simple_oauth.services.yml new file mode 100644 index 0000000..5524b81 --- /dev/null +++ b/drupal-10/src/customer_identity_and_access_management/lr_simple_oauth/lr_simple_oauth.services.yml @@ -0,0 +1,4 @@ +services: + lr_simple_oauth.auth: + class: Drupal\lr_simple_oauth\UserAuth + arguments: [] diff --git a/drupal-10/src/customer_identity_and_access_management/lr_simple_oauth/src/LrSimpleOauthServiceProvider.php b/drupal-10/src/customer_identity_and_access_management/lr_simple_oauth/src/LrSimpleOauthServiceProvider.php new file mode 100644 index 0000000..72cfcd7 --- /dev/null +++ b/drupal-10/src/customer_identity_and_access_management/lr_simple_oauth/src/LrSimpleOauthServiceProvider.php @@ -0,0 +1,24 @@ +getDefinition('simple_oauth.repositories.user'); + $definition->replaceArgument(0, new Reference('lr_simple_oauth.auth')); + } + +} diff --git a/drupal-10/src/customer_identity_and_access_management/lr_simple_oauth/src/UserAuth.php b/drupal-10/src/customer_identity_and_access_management/lr_simple_oauth/src/UserAuth.php new file mode 100644 index 0000000..3ceabbb --- /dev/null +++ b/drupal-10/src/customer_identity_and_access_management/lr_simple_oauth/src/UserAuth.php @@ -0,0 +1,79 @@ +moduleconfig = \Drupal::config('lr_ciam.settings'); + $this->apiKey = trim($this->moduleconfig->get('api_key')); + $this->apiSecret = trim($this->moduleconfig->get('api_secret')); + } + + /** + * {@inheritdoc} + */ + public function authenticate($username, $password) { + // Authenticate the user with the LoginRadius service. + $data = '{ + "email": "' . $username . '", + "password": "' . $password . '", + "securityanswer": "" + }'; + + // Get a user profile using email and password. + try { + $authObj = new AuthenticationAPI(); + $result = $authObj->loginByEmail($data); + } + catch (LoginRadiusException $e) { + return FALSE; + } + + // Check if the user was authenticated with LoginRadius service. + if (isset($result->access_token) && $result->access_token != '') { + // Get uid from db using email. + $query = \Drupal::database()->select('users_field_data', 'u'); + $query->addField('u', 'uid'); + $query->condition('u.mail', $result->Profile->Email[0]->Value); + $uid = $query->execute()->fetchField(); + + // If User exist on LoginRadius but does not exist on Drupal, + // Then create user on Drupal. + if (isset($uid) && $uid == '') { + $fields = [ + 'name' => $username, + 'mail' => $result->Profile->Email[0]->Value, + 'init' => $result->Profile->Email[0]->Value, + 'pass' => $password, + 'status' => '1', + ]; + $new_user = User::create($fields); + $new_user->save(); + return $new_user->id(); + } + else { + return $uid; + } + } + else { + return FALSE; + } + } + +} diff --git a/drupal-10/src/customer_identity_and_access_management/lr_sso/js/sso_frontend.js b/drupal-10/src/customer_identity_and_access_management/lr_sso/js/sso_frontend.js new file mode 100644 index 0000000..bf8baca --- /dev/null +++ b/drupal-10/src/customer_identity_and_access_management/lr_sso/js/sso_frontend.js @@ -0,0 +1,66 @@ +jQuery(document).ready(function () { + jQuery('a[href*="user/logout"]').click(function (e) { + e.preventDefault(); + var options = {}; + options.onSuccess = function () { + window.location = drupalSettings.sso.logoutUrl; + }; + LRObject.init("logout", options); + }); + + if (window.location.href.indexOf('user/logout') > 0) { + var options = {}; + options.onSuccess = function () { + window.location = drupalSettings.sso.loginUrl; + }; + LRObject.init("logout", options); + } +}); + +if (drupalSettings.sso.isNotLogin) { + jQuery(document).ready(function () { + if (jQuery(".interfacecontainerdiv").length) { + var options = {}; + options.onSuccess = function (response) { + var form = document.createElement("form"); + form.action = drupalSettings.sso.loginUrl; + form.method = "POST"; + + var hidden = document.createElement("input"); + hidden.type = "hidden"; + hidden.name = "token"; + hidden.value = response; + + form.appendChild(hidden); + document.body.appendChild(form); + form.submit(); + }; + + var lrSsoLoginInterval = setInterval(function () { + if (typeof LRObject !== 'undefined') + { + clearInterval(lrSsoLoginInterval); + LRObject.init("ssoLogin", options); + } + }, 1); + } + }); + jQuery("#lr-loading").hide(); +} + +if (drupalSettings.sso.isNotLoginThenLogout) { + jQuery(document).ready(function () { + var check_options = {}; + check_options.onError = function () { + window.location = drupalSettings.sso.logoutUrl; + }; + + var lrSsoNotLoginInterval = setInterval(function () { + if (typeof LRObject !== 'undefined') + { + clearInterval(lrSsoNotLoginInterval); + LRObject.init("ssoNotLoginThenLogout", check_options); + } + }, 1); + }); +} \ No newline at end of file diff --git a/drupal-10/src/customer_identity_and_access_management/lr_sso/js/sso_frontend.min.js b/drupal-10/src/customer_identity_and_access_management/lr_sso/js/sso_frontend.min.js new file mode 100644 index 0000000..98b66b5 --- /dev/null +++ b/drupal-10/src/customer_identity_and_access_management/lr_sso/js/sso_frontend.min.js @@ -0,0 +1 @@ +jQuery(document).ready(function(){if(jQuery('a[href*="user/logout"]').click(function(n){n.preventDefault();var t={onSuccess:function(){window.location=drupalSettings.sso.logoutUrl}};LRObject.init("logout",t)}),window.location.href.indexOf("user/logout")>0){var n={onSuccess:function(){window.location=drupalSettings.sso.loginUrl}};LRObject.init("logout",n)}}),drupalSettings.sso.isNotLogin&&(jQuery(document).ready(function(){if(jQuery(".interfacecontainerdiv").length)var n={onSuccess:function(n){var t=document.createElement("form");t.action=drupalSettings.sso.loginUrl,t.method="POST";var e=document.createElement("input");e.type="hidden",e.name="token",e.value=n,t.appendChild(e),document.body.appendChild(t),t.submit()}},t=setInterval(function(){"undefined"!=typeof LRObject&&(clearInterval(t),LRObject.init("ssoLogin",n))},1)}),jQuery("#lr-loading").hide()),drupalSettings.sso.isNotLoginThenLogout&&jQuery(document).ready(function(){var n={onError:function(){window.location=drupalSettings.sso.logoutUrl}},t=setInterval(function(){"undefined"!=typeof LRObject&&(clearInterval(t),LRObject.init("ssoNotLoginThenLogout",n))},1)}); \ No newline at end of file diff --git a/drupal-10/src/customer_identity_and_access_management/lr_sso/lr_sso.info.yml b/drupal-10/src/customer_identity_and_access_management/lr_sso/lr_sso.info.yml new file mode 100644 index 0000000..af2f3c4 --- /dev/null +++ b/drupal-10/src/customer_identity_and_access_management/lr_sso/lr_sso.info.yml @@ -0,0 +1,8 @@ +name: SSO (Single Sign On) +type: module +description: 'Enable a single login system for multiple websites: users only need to log in once to get access to all of your web properties.' +package: CIAM LoginRadius +dependencies: + - drupal:lr_ciam +configure: lr_sso.settings_form +core_version_requirement: ^9.4 || ^10 diff --git a/drupal-10/src/customer_identity_and_access_management/lr_sso/lr_sso.install b/drupal-10/src/customer_identity_and_access_management/lr_sso/lr_sso.install new file mode 100644 index 0000000..9f32280 --- /dev/null +++ b/drupal-10/src/customer_identity_and_access_management/lr_sso/lr_sso.install @@ -0,0 +1,13 @@ +get('sso_site_name'); + + + if ($sso_config->get('sso_enable') == 1 && !empty($site_name)) { + + $user = \Drupal::currentUser()->getRoles(); + $my_settings['logoutUrl'] = Url::fromRoute('user.logout')->setAbsolute()->toString(); + + if (\Drupal::currentUser()->isAnonymous()) { + + $my_settings['isNotLogin'] = TRUE; + $my_settings['loginUrl'] = Url::fromRoute('user.login')->setAbsolute()->toString(); + } + if (!\Drupal::currentUser()->isAnonymous() && !in_array("administrator", $user)) { + + $my_settings['isNotLoginThenLogout'] = TRUE; + } + + $page['#cache']['contexts'][] = 'user.roles'; + $page['#attached']['drupalSettings']['sso'] = $my_settings; + $page['#attached']['library'][] = 'lr_sso/drupal.coresso'; + } +} diff --git a/drupal-10/src/customer_identity_and_access_management/lr_sso/lr_sso.routing.yml b/drupal-10/src/customer_identity_and_access_management/lr_sso/lr_sso.routing.yml new file mode 100644 index 0000000..3bf2577 --- /dev/null +++ b/drupal-10/src/customer_identity_and_access_management/lr_sso/lr_sso.routing.yml @@ -0,0 +1,9 @@ +lr_sso.settings_form: + path: 'admin/config/people/ciam/sso' + defaults: + _title: 'LoginRadius' + _form: '\Drupal\lr_sso\Form\SSOSettingsForm' + requirements: + _permission: 'administer user registration settings' + options: + no_cache: TRUE diff --git a/drupal-10/src/customer_identity_and_access_management/lr_sso/src/Form/SSOSettingsForm.php b/drupal-10/src/customer_identity_and_access_management/lr_sso/src/Form/SSOSettingsForm.php new file mode 100644 index 0000000..59e436a --- /dev/null +++ b/drupal-10/src/customer_identity_and_access_management/lr_sso/src/Form/SSOSettingsForm.php @@ -0,0 +1,81 @@ +config('lr_sso.settings'); + // Configuration of which forms to protect, with what challenge. + $form['sso'] = [ + '#type' => 'details', + '#title' => $this->t('Single Sign On Settings'), + '#open' => TRUE, + ]; + $form['sso']['sso_enable'] = [ + '#type' => 'radios', + '#title' => $this->t('Do you want to enable Single Sign On (SSO) (?)'), + '#default_value' => $config->get('sso_enable') ? $config->get('sso_enable') : 0, + '#options' => [ + 1 => $this->t('Yes'), + 0 => $this->t('No'), + ], + ]; + // Submit button. + $form['actions'] = ['#type' => 'actions']; + $form['actions']['submit'] = [ + '#type' => 'submit', + '#value' => $this->t('Save configuration'), + ]; + + return parent::buildForm($form, $form_state); + } + + /** + * {@inheritdoc} + */ + public function submitForm(array &$form, FormStateInterface $form_state) { + $sl_config = $this->config('lr_ciam.settings'); + $api_key = $sl_config->get('api_key'); + $api_secret = $sl_config->get('api_secret'); + if ($api_key == '') { + $api_key = ''; + $api_secret = ''; + } + + $decryt_secret_key = encrypt_and_decrypt( $api_secret, $api_key, $api_key, 'd' ); + $data = lr_ciam_get_authentication($api_key, $decryt_secret_key); + if (isset($data['status']) && $data['status'] != 'status') { + $this->messenger()->addError($this->t($data['message'])); + return FALSE; + } + parent::SubmitForm($form, $form_state); + $this->config('lr_sso.settings') + ->set('sso_enable', $form_state->getValue('sso_enable')) + ->save(); + } + +}