Changeset 1797096
- Timestamp:
- 01/04/2018 04:00:41 PM (8 years ago)
- Location:
- yoti/trunk
- Files:
-
- 1 added
- 5 edited
-
README.md (modified) (5 diffs)
-
class.yoti.php (added)
-
readme.txt (modified) (4 diffs)
-
sdk/Yoti/YotiClient.php (modified) (1 diff)
-
views/admin-options.php (modified) (2 diffs)
-
yoti.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
yoti/trunk/README.md
r1787610 r1797096 1 1 # Yoti WordPress Plugin 2 2 3 This repository contains the tools you need to quickly integrate your WordPress backend with Yoti ,so that your users can share their identity details with your application in a secure and trusted way. The plugin uses the Yoti PHP SDK. If you're interested in finding out more about the SDK, click [here](https://github.com/getyoti/yoti-php-sdk).3 This repository contains the tools you need to quickly integrate your WordPress backend with Yoti so that your users can share their identity details with your application in a secure and trusted way. The plugin uses the Yoti PHP SDK. If you're interested in finding out more about the SDK, click [here](https://github.com/getyoti/yoti-php-sdk). 4 4 5 5 ## Requirements 6 6 7 This SDKworks with the WordPress Business Plan package.7 This plugin works with the WordPress Business Plan package. 8 8 9 ## Installing the SDK9 ## Installing the plugin 10 10 11 You can install the Yoti SDKin two ways:11 You can install the Yoti WordPress plugin in two ways: 12 12 13 ### By importing the Yoti SDK insideyour project13 ### By importing the plugin into your project 14 14 15 1. Log on to your Wordpress Admin Dashboard e.g. https://www.wordpressurl.org.uk/wp-admin15 1. Log on to your Wordpress Admin Dashboard e.g. `https://www.wordpressurl.org.uk/wp-admin` 16 16 2. Navigate to `Plugins > Add New` 17 17 3. Search for Yoti, install and activate the plugin … … 22 22 2. Run `./pack-plugin.sh`. This will download the Yoti PHP SDK and place it in the plugin directory 23 23 3. On completion of step 2, you will have a file called `yoti-wordpress-edge.zip`. 24 4. Upload this file inyour Wordpress Admin Dashboard at `Plugins > Add New`, then click `Upload Plugin`.24 4. Upload this file to your Wordpress Admin Dashboard at `Plugins > Add New`, then click `Upload Plugin`. 25 25 5. Once installed, click on `Activate Plugin`. 26 27 ## Setting up your Yoti Application 28 29 After you registered your [Yoti](https://www.yoti.com/), access the [dashboard](https://www.yoti.com/dashboard/login) to create a new application. 30 31 Specify the basic details of your application such as the name, description and optional logo. These details can be whatever you like and will not affect the plugin's functionality. 32 33 The `Data` tab - Specify any attributes you'd like users to share. You must select at least one. If you plan to allow new user registrations, we recommended choosing `Given Name(s)`, `Family Name` and `Email Address` at a minimum. 34 35 The `Integration` tab - Here is where you specify the callback URL. This can be found on your Yoti settings page in your WordPress admin dashboard. **NOTE**: If you get redirected to your WordPress frontpage instead of the Admin area, simply add `/wp-admin` to the URL. 26 36 27 37 ## Plugin Setup … … 38 48 Please do not open the .pem file as this might corrupt the key and you will need to create a new application. 39 49 40 ## Setting up your Yoti Application 41 42 Specify the basic details of your application such as the name, description and optional logo. These details can be whatever you like and will not affect the plugin's functionality. 43 44 The `Data` tab - Specify any attributes you'd like users to share. You must select at least one. If you plan to allow new user registrations, we recommended choosing `Given Name(s)`, `Family Name` and `Email Address` at a minimum. 45 46 The `Integration` tab - Here is where you specify the callback URL. This can be found on your Yoti settings page in your WordPress Admin Dashboard. **NOTE**: If you get redirected to your WordPress frontpage instead of the Admin area, simply add `/wp-admin` to the URL. 47 48 ## Allowing new registrations 50 ## Settings for new registrations 49 51 50 52 `Only allow existing Wordpress users to link their Yoti account` - This setting allows a new user to Register and Log in by using their Yoti. A new user who registeres this way will be set to the `Subscriber` role in WordPress. If enabled, when a new user tries to scan the Yoti QR code, they will be redirected back to the login page with an error message displayed. … … 58 60 ### Setup 59 61 60 To try out our Docker container, clone this repository and run the following commands: 61 62 Go to the directory where the repo was cloned: 62 Clone this repository and go into the folder: 63 63 64 64 ```shell … … 94 94 95 95 For any questions or support please email [sdksupport@yoti.com](mailto:sdksupport@yoti.com). 96 Please provide the following t he get you up and working as quickas possible:96 Please provide the following to get you up and working as quickly as possible: 97 97 98 * Computer Type 99 * OS Version 98 * Computer type 99 * OS version 100 * Version of WordPress being used 100 101 * Screenshot 102 103 Once we have answered your question we may contact you again to discuss Yoti products and services. If you’d prefer us not to do this, please let us know when you e-mail. -
yoti/trunk/readme.txt
r1787610 r1797096 5 5 Requires at least: 3.0.1 6 6 Tested up to: 4.9.1 7 Stable tag: 1.1. 57 Stable tag: 1.1.6 8 8 License: GNU v3 9 9 License URI: https://www.gnu.org/licenses/gpl.txt … … 88 88 Version Date Changes 89 89 90 1.1.6 2018/01/04 Integrate the new inline QR code version 2.0.1. 91 Refactor Yoti button widget to follow WordPress widget standard. 92 Show Yoti settings link on the plugins page after activation. 93 Add admin notice display after Yoti plugin activation. 90 94 91 95 1.1.5 2017/04/14 Integrate the new inline QR style for Yoti button. … … 94 98 1.1.4 2017/08/11 Integrate SDK identifier to track plugin usage. 95 99 Apply Yoti style to the unlink button. 96 Add Company Name to Yoti settings 100 Add Company Name to Yoti settings. 97 101 98 102 1.1.3 2017/14/08 Change Yoti generic user ID to use the combination of user given names and family name. … … 105 109 1.1.1 2017/20/07 Fix a bug that was occurring when a user decides not to link their account to Yoti during the login process. 106 110 107 1.1.0 2017/20/07 Remove PHP module mcrypt dependency from WordPress plugin 111 1.1.0 2017/20/07 Remove PHP module mcrypt dependency from WordPress plugin. 108 112 109 113 1.0.9 2017/19/05 Add plugin documentation. -
yoti/trunk/sdk/Yoti/YotiClient.php
r1787610 r1797096 247 247 if (!$token) 248 248 { 249 throw new \Exception('Could not connect decrypt token.', 401);249 throw new \Exception('Could not decrypt connect token.', 401); 250 250 } 251 251 -
yoti/trunk/views/admin-options.php
r1787610 r1797096 83 83 <th scope="row"></th> 84 84 <td> 85 <label><input type="checkbox" name="yoti_only_existing" value="1"<?php echo $onlyExistingUserCheckBox ?> /> Only allow existing Word press users to link their Yoti account</label>85 <label><input type="checkbox" name="yoti_only_existing" value="1"<?php echo $onlyExistingUserCheckBox ?> /> Only allow existing WordPress users to link their Yoti account</label> 86 86 </td> 87 87 </tr> … … 89 89 <th scope="row"></th> 90 90 <td> 91 <label><input type="checkbox" name="yoti_user_email" value="1" <?php echo $useEmailAddressCheckBox ?> /> Attempt to link Yoti email address with Word press account for first time users</label>91 <label><input type="checkbox" name="yoti_user_email" value="1" <?php echo $useEmailAddressCheckBox ?> /> Attempt to link Yoti email address with WordPress account for first time users</label> 92 92 </td> 93 93 </tr> -
yoti/trunk/yoti.php
r1787610 r1797096 5 5 Plugin URI: https://wordpress.org/plugins/yoti/ 6 6 Description: Let Yoti users quickly register on your site. 7 Version: 1.1. 57 Version: 1.1.6 8 8 Author: Yoti SDK. 9 9 Author URI: https://yoti.com 10 10 */ 11 11 12 use Yoti\ActivityDetails; 12 13 // Make sure we don't expose any info if called directly 14 if ( !function_exists( 'add_action' ) ) { 15 echo 'Hi there! I\'m just a plugin, not much I can do when called directly.'; 16 exit; 17 } 13 18 14 19 require_once ABSPATH . 'wp-admin/includes/upgrade.php'; 15 require_once __DIR__ . '/YotiHelper.php'; 16 require_once __DIR__ . '/YotiAdmin.php'; 17 require_once __DIR__ . '/YotiButton.php'; 18 require_once __DIR__ . '/YotiWidget.php'; 20 require_once __DIR__ . '/class.yoti.php'; 19 21 20 /** 21 * Activation hook 22 */ 23 function yoti_activation_hook() 24 { 25 // Create upload dir 26 if (!is_dir(YotiHelper::uploadDir())) 27 { 28 mkdir(YotiHelper::uploadDir(), 0777, TRUE); 29 } 30 } 22 // Register Yoti hooks. 23 register_uninstall_hook(__FILE__, array('Yoti', 'yoti_uninstall_hook')); 24 register_activation_hook(__FILE__, array('Yoti', 'yoti_activation_hook')); 25 add_action('init', array('Yoti', 'yoti_init')); 26 add_action('admin_menu', array('Yoti', 'yoti_admin_menu')); 27 add_action('login_form', array('Yoti', 'yoti_login_header')); 28 add_action('wp_login', array('Yoti', 'yoti_login'), 10, 2); 29 add_action('wp_logout', array('Yoti', 'yoti_logout'), 10, 2); 30 add_action('show_user_profile', array('Yoti', 'show_user_profile'), 10, 1); 31 add_action('edit_user_profile', array('Yoti', 'show_user_profile'), 10, 1); 32 add_action('widgets_init', array('Yoti', 'yoti_register_widget')); 33 add_action('wp_enqueue_scripts', array('Yoti', 'yoti_enqueue_scripts')); 34 add_action('admin_notices', array('Yoti', 'yoti_plugin_activate_notice')); 35 add_filter('plugin_action_links_' . plugin_basename(__FILE__), array('Yoti', 'yoti_plugin_action_links'), 10, 2); 31 36 32 /**33 * Uninstall hook34 */35 function yoti_uninstall_hook()36 {37 YotiHelper::deleteYotiConfigData();38 }39 40 /**41 * init42 */43 function yoti_init()44 {45 if (!session_id())46 {47 session_start();48 }49 50 if (!empty($_GET['yoti-select']))51 {52 $yc = new YotiHelper();53 54 // Action55 $action = !empty($_GET['action']) ? $_GET['action'] : '';56 $redirect = (!empty($_GET['redirect'])) ? $_GET['redirect'] : home_url();57 switch ($action)58 {59 case 'link':60 if ($yc->link())61 {62 wp_safe_redirect($redirect);63 }64 break;65 66 case 'unlink':67 if ($yc->unlink())68 {69 // Redirect70 wp_safe_redirect($redirect);71 }72 break;73 74 case 'bin-file':75 $yc->binFile('selfie', !empty($_GET['user_id']) ? $_GET['user_id'] : NULL);76 exit;77 break;78 }79 }80 }81 82 /**83 * Add items to admin menu84 */85 function yoti_admin_menu()86 {87 wp_enqueue_style('yoti-asset-css', plugin_dir_url(__FILE__) . 'assets/styles.css', FALSE);88 add_options_page('Yoti', 'Yoti', 'manage_options', 'yoti', 'YotiAdmin::init');89 }90 91 /**92 * add to login footer93 */94 function yoti_login_header()95 {96 // Don't allow unless session97 if (!YotiHelper::getYotiUserFromStore())98 {99 return;100 }101 // On page refresh clear the YotiUserStore session and don't display the message102 elseif($_REQUEST['REQUEST_METHOD'] != 'POST' && !isset($_REQUEST['redirect_to']))103 {104 YotiHelper::clearYotiUserStore();105 106 return;107 }108 109 $config = YotiHelper::getConfig();110 $companyName = 'WordPress';111 if(isset($config['yoti_company_name']) && !empty($config['yoti_company_name'])) {112 $companyName = $config['yoti_company_name'];113 }114 115 $noLink = (!empty($_POST['yoti_nolink'])) ? 1 : NULL;116 117 echo '<div style="margin: 0 0 25px 0" class="message">118 <div style="font-weight: bold; margin-bottom: 5px;">Warning: You are about to link your ' . $companyName . ' account to your Yoti account. Click the box below to keep them separate.</div>119 <input type="checkbox" id="edit-yoti-link" name="yoti_nolink" value="1" class="form-checkbox"' . ($noLink ? ' checked="checked"' : '') . '>120 <label class="option" for="edit-yoti-link">Don\'t link my Yoti account</label>121 </div>';122 }123 124 /**125 * @param $user_login126 * @param $user127 */128 function yoti_login($user_login=NULL, $user=NULL)129 {130 if (!$user) {131 return;132 }133 134 $activityDetails = YotiHelper::getYotiUserFromStore();135 $yotiNoLinkIsNotChecked = (!isset($_POST['yoti_nolink']) || empty($_POST['yoti_nolink']));136 137 // Check that activityDetails exists and yoti_nolink button is not checked138 if ($activityDetails && $yotiNoLinkIsNotChecked)139 {140 // Link account to Yoti141 $helper = new YotiHelper();142 $helper->createYotiUser($user->ID, $activityDetails);143 }144 145 // Remove Yoti session146 unset($_SESSION['yoti_nolink']);147 YotiHelper::clearYotiUserStore();148 }149 150 /**151 * WP logout hook152 */153 function yoti_logout()154 {155 YotiHelper::clearFlash();156 }157 158 /**159 * @param WP_User $user160 */161 function show_user_profile($user)162 {163 $yotiId = get_user_meta($user->ID, 'yoti_user.identifier');164 $dbProfile = YotiHelper::getUserProfile($user->ID);165 $profileUserId = $user->ID;166 167 $profile = NULL;168 if ($yotiId && $dbProfile)169 {170 $profile = new ActivityDetails($dbProfile, $yotiId);171 }172 173 // Add profile scope174 $show = function () use ($profile, $dbProfile, $profileUserId) {175 require_once __DIR__ . '/views/profile.php';176 };177 $show();178 }179 180 function yoti_register_widget()181 {182 register_widget('YotiWidget');183 }184 185 function yoti_enqueue_scripts()186 {187 wp_enqueue_script('yoti-asset-js', YotiHelper::YOTI_SDK_JAVASCRIPT_LIBRARY, [], NULL);188 }189 190 // Register hooks191 register_uninstall_hook(__FILE__, 'yoti_uninstall_hook');192 register_activation_hook(__FILE__, 'yoti_activation_hook');193 add_action('admin_menu', 'yoti_admin_menu');194 add_action('init', 'yoti_init');195 add_action('login_form', 'yoti_login_header');196 add_action('wp_login', 'yoti_login', 10, 2);197 add_action('wp_logout', 'yoti_logout', 10, 2);198 add_action('show_user_profile', 'show_user_profile', 10, 1);199 add_action('edit_user_profile', 'show_user_profile', 10, 1);200 add_action('widgets_init', 'yoti_register_widget');201 add_action('wp_enqueue_scripts', 'yoti_enqueue_scripts');202
Note: See TracChangeset
for help on using the changeset viewer.