Plugin Directory

Changeset 1797096


Ignore:
Timestamp:
01/04/2018 04:00:41 PM (8 years ago)
Author:
yotiwordpress
Message:

Show Yoti settings link on the plugins page after activation - Integrated the new inline QR code version 2.0.1

Location:
yoti/trunk
Files:
1 added
5 edited

Legend:

Unmodified
Added
Removed
  • yoti/trunk/README.md

    r1787610 r1797096  
    11# Yoti WordPress Plugin
    22
    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).
     3This 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).
    44
    55## Requirements
    66
    7 This SDK works with the WordPress Business Plan package.
     7This plugin works with the WordPress Business Plan package.
    88
    9 ## Installing the SDK
     9## Installing the plugin
    1010
    11 You can install the Yoti SDK in two ways:
     11You can install the Yoti WordPress plugin in two ways:
    1212
    13 ### By importing the Yoti SDK inside your project
     13### By importing the plugin into your project
    1414
    15 1. Log on to your Wordpress Admin Dashboard e.g. https://www.wordpressurl.org.uk/wp-admin
     151. Log on to your Wordpress Admin Dashboard e.g. `https://www.wordpressurl.org.uk/wp-admin`
    16162. Navigate to `Plugins > Add New`
    17173. Search for Yoti, install and activate the plugin
     
    22222. Run `./pack-plugin.sh`. This will download the Yoti PHP SDK and place it in the plugin directory
    23233. On completion of step 2, you will have a file called `yoti-wordpress-edge.zip`.
    24 4. Upload this file in your Wordpress Admin Dashboard at `Plugins > Add New`, then click `Upload Plugin`.
     244. Upload this file to your Wordpress Admin Dashboard at `Plugins > Add New`, then click `Upload Plugin`.
    25255. Once installed, click on `Activate Plugin`.
     26
     27## Setting up your Yoti Application
     28
     29After you registered your [Yoti](https://www.yoti.com/), access the [dashboard](https://www.yoti.com/dashboard/login) to create a new application.
     30
     31Specify 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
     33The `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
     35The `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.
    2636
    2737## Plugin Setup
     
    3848Please do not open the .pem file as this might corrupt the key and you will need to create a new application.
    3949
    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
    4951
    5052`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.
     
    5860### Setup
    5961
    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:
     62Clone this repository and go into the folder:
    6363
    6464```shell
     
    9494
    9595For any questions or support please email [sdksupport@yoti.com](mailto:sdksupport@yoti.com).
    96 Please provide the following the get you up and working as quick as possible:
     96Please provide the following to get you up and working as quickly as possible:
    9797
    98 * Computer Type
    99 * OS Version
     98* Computer type
     99* OS version
     100* Version of WordPress being used
    100101* Screenshot
     102
     103Once 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  
    55Requires at least: 3.0.1
    66Tested up to: 4.9.1
    7 Stable tag: 1.1.5
     7Stable tag: 1.1.6
    88License: GNU v3
    99License URI: https://www.gnu.org/licenses/gpl.txt
     
    8888    Version     Date            Changes
    8989
     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.
    9094
    9195    1.1.5       2017/04/14      Integrate the new inline QR style for Yoti button.
     
    9498    1.1.4       2017/08/11      Integrate SDK identifier to track plugin usage.
    9599                                Apply Yoti style to the unlink button.
    96                                 Add Company Name to Yoti settings
     100                                Add Company Name to Yoti settings.
    97101
    98102    1.1.3       2017/14/08      Change Yoti generic user ID to use the combination of user given names and family name.
     
    105109    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.
    106110
    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.
    108112
    109113    1.0.9       2017/19/05      Add plugin documentation.
  • yoti/trunk/sdk/Yoti/YotiClient.php

    r1787610 r1797096  
    247247        if (!$token)
    248248        {
    249             throw new \Exception('Could not connect decrypt token.', 401);
     249            throw new \Exception('Could not decrypt connect token.', 401);
    250250        }
    251251
  • yoti/trunk/views/admin-options.php

    r1787610 r1797096  
    8383            <th scope="row"></th>
    8484            <td>
    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>
     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>
    8686            </td>
    8787          </tr>
     
    8989            <th scope="row"></th>
    9090            <td>
    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>
     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>
    9292            </td>
    9393          </tr>
  • yoti/trunk/yoti.php

    r1787610 r1797096  
    55Plugin URI: https://wordpress.org/plugins/yoti/
    66Description: Let Yoti users quickly register on your site.
    7 Version: 1.1.5
     7Version: 1.1.6
    88Author: Yoti SDK.
    99Author URI: https://yoti.com
    1010*/
    1111
    12 use Yoti\ActivityDetails;
     12
     13// Make sure we don't expose any info if called directly
     14if ( !function_exists( 'add_action' ) ) {
     15    echo 'Hi there!  I\'m just a plugin, not much I can do when called directly.';
     16    exit;
     17}
    1318
    1419require_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';
     20require_once __DIR__ . '/class.yoti.php';
    1921
    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.
     23register_uninstall_hook(__FILE__, array('Yoti', 'yoti_uninstall_hook'));
     24register_activation_hook(__FILE__, array('Yoti', 'yoti_activation_hook'));
     25add_action('init', array('Yoti', 'yoti_init'));
     26add_action('admin_menu', array('Yoti', 'yoti_admin_menu'));
     27add_action('login_form', array('Yoti', 'yoti_login_header'));
     28add_action('wp_login', array('Yoti', 'yoti_login'), 10, 2);
     29add_action('wp_logout', array('Yoti', 'yoti_logout'), 10, 2);
     30add_action('show_user_profile', array('Yoti', 'show_user_profile'), 10, 1);
     31add_action('edit_user_profile', array('Yoti', 'show_user_profile'), 10, 1);
     32add_action('widgets_init', array('Yoti', 'yoti_register_widget'));
     33add_action('wp_enqueue_scripts', array('Yoti', 'yoti_enqueue_scripts'));
     34add_action('admin_notices', array('Yoti', 'yoti_plugin_activate_notice'));
     35add_filter('plugin_action_links_' . plugin_basename(__FILE__), array('Yoti', 'yoti_plugin_action_links'), 10, 2);
    3136
    32 /**
    33  * Uninstall hook
    34  */
    35 function yoti_uninstall_hook()
    36 {
    37     YotiHelper::deleteYotiConfigData();
    38 }
    39 
    40 /**
    41  *  init
    42  */
    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         // Action
    55         $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                     // Redirect
    70                     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 menu
    84  */
    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 footer
    93  */
    94 function yoti_login_header()
    95 {
    96     // Don't allow unless session
    97     if (!YotiHelper::getYotiUserFromStore())
    98     {
    99         return;
    100     }
    101     // On page refresh clear the YotiUserStore session and don't display the message
    102     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_login
    126  * @param $user
    127  */
    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 checked
    138     if ($activityDetails && $yotiNoLinkIsNotChecked)
    139     {
    140         // Link account to Yoti
    141         $helper = new YotiHelper();
    142         $helper->createYotiUser($user->ID, $activityDetails);
    143     }
    144 
    145     // Remove Yoti session
    146     unset($_SESSION['yoti_nolink']);
    147     YotiHelper::clearYotiUserStore();
    148 }
    149 
    150 /**
    151  * WP logout hook
    152  */
    153 function yoti_logout()
    154 {
    155     YotiHelper::clearFlash();
    156 }
    157 
    158 /**
    159  * @param WP_User $user
    160  */
    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 scope
    174     $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 hooks
    191 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.