Changeset 1788237
- Timestamp:
- 12/17/2017 10:09:41 AM (8 years ago)
- Location:
- authentiq/trunk
- Files:
-
- 12 edited
-
CHANGELOG.txt (modified) (1 diff)
-
README.txt (modified) (2 diffs)
-
admin/partials/authentiq-settings.php (modified) (3 diffs)
-
authentiq.php (modified) (2 diffs)
-
includes/class-authentiq-options.php (modified) (1 diff)
-
includes/class-authentiq-provider.php (modified) (3 diffs)
-
includes/class-authentiq-user.php (modified) (7 diffs)
-
includes/class-authentiq-widget.php (modified) (1 diff)
-
languages/authentiq-en_US.mo (modified) (previous)
-
languages/authentiq-en_US.po (modified) (9 diffs)
-
public/class-authentiq-public.php (modified) (2 diffs)
-
public/js/authentiq-public.min.js (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
authentiq/trunk/CHANGELOG.txt
r1775125 r1788237 1 1 == Changelog == 2 3 = 1.0.3 - 2017-12-17 = 4 5 * Feature - Stop updating username and display_name on sub-sequent signins. 6 * Feature - Add settings for defining a specific redirect URL after signin. 2 7 3 8 = 1.0.2 - 2017-11-25 = -
authentiq/trunk/README.txt
r1775125 r1788237 4 4 Requires at least: 4.6 5 5 Tested up to: 4.9 6 Stable tag: 1.0. 26 Stable tag: 1.0.3 7 7 License: GPLv2 or later 8 8 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 112 112 == Changelog == 113 113 114 = 1.0.3 - 2017-12-17 = 115 116 * Feature - Stop updating username and display_name on sub-sequent signins. 117 * Feature - Add settings for defining a specific redirect URL after signin. 118 114 119 = 1.0.2 - 2017-11-25 = 115 120 -
authentiq/trunk/admin/partials/authentiq-settings.php
r1756312 r1788237 102 102 <input type="text" name="authentiq_settings[client_id]" id="authentiq_settings[client_id]" 103 103 value="<?php echo esc_attr($this->options->get('client_id')); ?>" class="regular-text"> 104 105 104 </td> 106 105 </tr> … … 114 113 value="<?php echo esc_attr($this->options->get('client_secret')); ?>" 115 114 class="regular-text"> 116 117 115 </td> 118 116 </tr> … … 216 214 </td> 217 215 </tr> 218 </tbody> 219 </table> 220 221 <h2><?php esc_html_e('Domain filter', AUTHENTIQ_LANG) ?></h2> 222 <table class="form-table"> 223 <tbody> 216 217 <tr> 218 <th scope="row"> 219 <label for="authentiq_settings[default_login_redirection]"><?php esc_html_e('Page after login', AUTHENTIQ_LANG) ?></label> 220 </th> 221 <td valign="center"> 222 <input type="text" name="authentiq_settings[default_login_redirection]" 223 id="authentiq_settings[default_login_redirection]" 224 value="<?php echo esc_attr($this->options->get('default_login_redirection')); ?>" 225 placeholder="<?php esc_html_e('no redirect', AUTHENTIQ_LANG) ?>" 226 class="regular-text"> 227 228 <?php esc_html_e('for', AUTHENTIQ_LANG) ?> 229 230 <?php $default_login_redirection_applies_to = $this->options->get('default_login_redirection_applies_to'); ?> 231 232 <label for="authentiq_settings[default_login_redirection_applies_to]"> 233 <select name="authentiq_settings[default_login_redirection_applies_to]" 234 id="authentiq_settings[default_login_redirection_applies_to]"> 235 <option value="all" <?php selected($default_login_redirection_applies_to, 'all'); ?>> 236 <?php esc_html_e('All users', AUTHENTIQ_LANG) ?> 237 </option> 238 <?php wp_dropdown_roles($default_login_redirection_applies_to); ?> 239 </select> 240 </label> 241 </td> 242 </tr> 243 224 244 <tr> 225 245 <th scope="row"><label -
authentiq/trunk/authentiq.php
r1775003 r1788237 4 4 * Plugin URI: https://wordpress.org/plugins/authentiq 5 5 * Description: Sign in (and sign up) to WordPress sites using the Authentiq ID app. Strong authentication, without the passwords. 6 * Version: 1.0. 26 * Version: 1.0.3 7 7 * Author: The Authentiq Team 8 8 * Author URI: https://www.authentiq.com … … 21 21 define('AUTHENTIQ_PLUGIN_DIR', trailingslashit(plugin_dir_path(__FILE__))); 22 22 define('AUTHENTIQ_PLUGIN_URL', trailingslashit(plugin_dir_url(__FILE__))); 23 define('AUTHENTIQ_VERSION', '1.0. 2');23 define('AUTHENTIQ_VERSION', '1.0.3'); 24 24 define('AUTHENTIQ_NAME', 'authentiq'); 25 25 define('AUTHENTIQ_LANG', AUTHENTIQ_NAME); -
authentiq/trunk/includes/class-authentiq-options.php
r1775003 r1788237 116 116 117 117 // Default redirect_to after a sign-in for Authentiq plugin 118 'default_login_redirection' => home_url(), 118 'default_login_redirection' => '', 119 'default_login_redirection_applies_to' => 'all', 119 120 120 121 // Used for showing messages in the admin area -
authentiq/trunk/includes/class-authentiq-provider.php
r1775003 r1788237 60 60 61 61 public static function get_authorize_url($extra_scopes = array()) { 62 global $wp; 62 63 63 64 $options = Authentiq_Options::Instance(); … … 94 95 95 96 // Pass redirect_to with state, in order we can redirect back after sign-in 96 $redirect_to = get_permalink();97 $redirect_to = home_url(add_query_arg(array(), $wp->request)); 97 98 if (!empty($redirect_to)) { 98 99 $state_obj['redirect_to'] = $redirect_to; … … 273 274 // Perform user login to WP 274 275 if ($user) { 275 // Default redirect URL for Authentiq 276 $redirect_to = $this->options->get('default_login_redirection', home_url()); 277 278 if (isset($_REQUEST['redirect_to']) && !empty($_REQUEST['redirect_to'])) { 279 $redirect_to = $_REQUEST['redirect_to']; 280 281 } else if (isset($state_obj['redirect_to']) && !empty($state_obj['redirect_to'])) { 282 $redirect_to = $state_obj['redirect_to']; 276 // check if a redirect URL is set and user role meets the condition to redirect the page 277 $default_login_redirection_applies_to = $this->options->get('default_login_redirection_applies_to'); 278 if ($default_login_redirection_applies_to === 'all' 279 || in_array($default_login_redirection_applies_to, (array)$user->roles)) { 280 $redirect_to = $this->options->get('default_login_redirection'); 281 } 282 283 if (empty($redirect_to)) { 284 // Default redirect URL to frontend home page 285 $redirect_to = home_url(); 286 287 // if user is admin, then move to the admin area 288 if (is_super_admin($user->ID)) { 289 $redirect_to = admin_url(); 290 } 291 292 if (isset($_REQUEST['redirect_to']) && !empty($_REQUEST['redirect_to'])) { 293 $redirect_to = $_REQUEST['redirect_to']; 294 295 } else if (isset($state_obj['redirect_to']) && !empty($state_obj['redirect_to'])) { 296 $redirect_to = $state_obj['redirect_to']; 297 } 283 298 } 284 299 -
authentiq/trunk/includes/class-authentiq-user.php
r1775003 r1788237 21 21 * @return array 22 22 */ 23 private static function get_user_data_from_userinfo($userinfo) { 24 $email = null; 23 private static function get_user_data_from_userinfo($userinfo, $update = false) { 24 // Create the user data array for updating WP user info 25 $userdata = array(); 26 25 27 if (isset($userinfo->email) && is_email($userinfo->email)) { 26 28 $email = sanitize_email($userinfo->email); 27 } 28 29 $first_name = null; 30 $last_name = null; 31 $user_name = null; 32 $display_name = null; 29 $userdata['user_email'] = $email; 30 } 33 31 34 32 // Try to get username from Authentiq ID, when set 35 33 if (isset($userinfo->preferred_username)) { 36 $user_name = $userinfo->preferred_username; 37 $display_name = $user_name; 38 } 39 40 if (!$display_name && isset($userinfo->name)) { 41 $display_name = $userinfo->name; 34 $preferred_username = trim($userinfo->preferred_username); 35 36 // only set nickname on user creation 37 if (!$update) { 38 $userdata['nickname'] = $preferred_username; 39 } 40 41 // default user_login is the $preferred_username 42 $userdata['user_login'] = $preferred_username; 43 } 44 45 // if no user_login set so far, try to set one using the email 46 if (!isset($userdata['user_login']) && $userdata['user_email']) { 47 $email_parts = explode('@', $userdata['user_email']); 48 $userdata['user_login'] = $email_parts[0]; 42 49 } 43 50 44 51 if (isset($userinfo->given_name)) { 45 $first_name = $userinfo->given_name; 46 47 if (!$user_name) $user_name = strtolower($first_name); 52 $first_name = trim($userinfo->given_name); 53 $userdata['first_name'] = $first_name; 54 55 // if no user_login set, then use the first_name 56 $userdata['user_login'] = !empty($userdata['user_login']) ? $userdata['user_login'] : strtolower($first_name); 48 57 } 49 58 50 59 if (isset($userinfo->family_name)) { 51 $ last_name= $userinfo->family_name;60 $userdata['last_name'] = $userinfo->family_name; 52 61 } 53 62 … … 55 64 // as a fallback remove non english chars, so as email name can be used 56 65 // with //translit you get a meaningful conversion to ASCII (e.g. ß -> ss) 57 $user_name = iconv('UTF-8', 'ASCII//TRANSLIT', $user_name); 58 59 // if no username set so far, try to set one using the email 60 if (!$user_name) { 61 $email_parts = explode('@', $email); 62 $user_name = $email_parts[0]; 63 } 64 65 // Create the user data array for updating WP user info 66 $user_data = array( 67 'user_email' => trim($email), 68 'user_login' => trim($user_name), 69 'first_name' => trim($first_name), 70 'last_name' => trim($last_name), 71 'display_name' => trim($display_name), 72 'nickname' => trim($user_name), 73 ); 74 75 return $user_data; 66 if ($userdata['user_login']) { 67 $userdata['user_login'] = iconv('UTF-8', 'ASCII//TRANSLIT', $userdata['user_login']); 68 } 69 70 return $userdata; 76 71 } 77 72 … … 83 78 * @return array 84 79 */ 85 private static function get_authentiq_userinfo($userinfo ) {86 $user _data = array();80 private static function get_authentiq_userinfo($userinfo, $update = false) { 81 $userdata = array(); 87 82 88 83 if (isset($userinfo->phone_number)) { 89 $user _data['phone_number'] = $userinfo->phone_number;84 $userdata['phone_number'] = trim($userinfo->phone_number); 90 85 91 86 if (isset($userinfo->phone_number_verified)) { 92 $user _data['phone_number_verified'] = $userinfo->phone_number_verified;87 $userdata['phone_number_verified'] = $userinfo->phone_number_verified; 93 88 } 94 89 95 90 if (isset($userinfo->phone_type)) { 96 $user _data['phone_type'] = $userinfo->phone_type;91 $userdata['phone_type'] = trim($userinfo->phone_type); 97 92 } 98 93 } 99 94 100 95 if (isset($userinfo->address)) { 101 $user _data['address'] = (array)$userinfo->address;96 $userdata['address'] = (array)$userinfo->address; 102 97 } 103 98 104 99 $twitter_scope = 'aq:social:twitter'; 105 100 if (isset($userinfo->$twitter_scope)) { 106 $user _data['twitter'] = (array)$userinfo->$twitter_scope;101 $userdata['twitter'] = (array)$userinfo->$twitter_scope; 107 102 } 108 103 109 104 $facebook_scope = 'aq:social:facebook'; 110 105 if (isset($userinfo->$facebook_scope)) { 111 $user _data['facebook'] = (array)$userinfo->$facebook_scope;106 $userdata['facebook'] = (array)$userinfo->$facebook_scope; 112 107 } 113 108 114 109 $linkedin_scope = 'aq:social:linkedin'; 115 110 if (isset($userinfo->$linkedin_scope)) { 116 $user _data['linkedin'] = (array)$userinfo->$linkedin_scope;117 } 118 119 return $user _data;111 $userdata['linkedin'] = (array)$userinfo->$linkedin_scope; 112 } 113 114 return $userdata; 120 115 } 121 116 … … 129 124 */ 130 125 public static function create_user($userinfo) { 131 // Get WP user info from Authentiq userinfo132 $user_data = Authentiq_User::get_user_data_from_userinfo($userinfo);133 134 126 // FIXME: check if email is required 135 127 if (empty($userinfo->email)) { … … 137 129 throw new Authentiq_User_Creation_Failed_Exception($msg); 138 130 } 131 132 // Get WP user info from Authentiq userinfo 133 $user_data = Authentiq_User::get_user_data_from_userinfo($userinfo); 139 134 140 135 // Generate a random password, otherwise account creation fails … … 224 219 225 220 // Get WP user info from Authentiq userinfo 226 $user_data = Authentiq_User::get_user_data_from_userinfo($userinfo );221 $user_data = Authentiq_User::get_user_data_from_userinfo($userinfo, true); 227 222 228 223 /** … … 258 253 259 254 // Add Authentiq extra info to WP user profile 260 $authentiq_userinfo = Authentiq_User::get_authentiq_userinfo($userinfo );255 $authentiq_userinfo = Authentiq_User::get_authentiq_userinfo($userinfo, false); 261 256 if (!empty($authentiq_userinfo)) { 262 257 Authentiq_User::update_userinfo($user_id, $authentiq_userinfo); -
authentiq/trunk/includes/class-authentiq-widget.php
r1754859 r1788237 137 137 138 138 public function get_logged_in_template($instance) { 139 $redirect_to = get_permalink(); 139 global $wp; 140 141 $redirect_to = home_url(add_query_arg(array(), $wp->request)); 140 142 $logout_url = wp_logout_url($redirect_to); 141 143 -
authentiq/trunk/languages/authentiq-en_US.po
r1756312 r1788237 2 2 msgstr "" 3 3 "Project-Id-Version: authentiq\n" 4 "POT-Creation-Date: 2017-1 0-31 23:37+0200\n"5 "PO-Revision-Date: 2017-1 0-31 23:37+0200\n"4 "POT-Creation-Date: 2017-12-17 12:02+0200\n" 5 "PO-Revision-Date: 2017-12-17 12:02+0200\n" 6 6 "Last-Translator: \n" 7 7 "Language-Team: Authentiq team <hello@authentiq.com>\n" … … 58 58 msgstr "" 59 59 60 #: admin/partials/authentiq-settings.php:10 960 #: admin/partials/authentiq-settings.php:108 61 61 msgid "Client Secret" 62 62 msgstr "" 63 63 64 #: admin/partials/authentiq-settings.php:119 65 msgid "Requested scopes" 66 msgstr "" 67 64 68 #: admin/partials/authentiq-settings.php:121 65 msgid "Requested scopes"66 msgstr ""67 68 #: admin/partials/authentiq-settings.php:12369 69 msgid "Additional scopes requested from Authentiq ID on user sign in." 70 70 msgstr "" 71 71 72 #: admin/partials/authentiq-settings.php:13 272 #: admin/partials/authentiq-settings.php:130 73 73 #: admin/partials/authentiq-user-profile.php:43 74 74 msgid "Phone number" 75 75 msgstr "" 76 76 77 #: admin/partials/authentiq-settings.php:1 4177 #: admin/partials/authentiq-settings.php:139 78 78 #: admin/partials/authentiq-user-profile.php:58 79 79 msgid "Address" 80 80 msgstr "" 81 81 82 #: admin/partials/authentiq-settings.php:1 5182 #: admin/partials/authentiq-settings.php:149 83 83 #: admin/partials/authentiq-user-profile.php:69 84 84 msgid "Twitter" 85 85 msgstr "" 86 86 87 #: admin/partials/authentiq-settings.php:1 6187 #: admin/partials/authentiq-settings.php:159 88 88 #: admin/partials/authentiq-user-profile.php:82 89 89 msgid "Facebook" 90 90 msgstr "" 91 91 92 #: admin/partials/authentiq-settings.php:1 7192 #: admin/partials/authentiq-settings.php:169 93 93 msgid "Linkedin" 94 94 msgstr "" 95 95 96 #: admin/partials/authentiq-settings.php:17 996 #: admin/partials/authentiq-settings.php:177 97 97 msgid "Functionality" 98 98 msgstr "" 99 99 100 #: admin/partials/authentiq-settings.php:18 4100 #: admin/partials/authentiq-settings.php:182 101 101 msgid "Classic WordPress Login" 102 102 msgstr "" 103 103 104 #: admin/partials/authentiq-settings.php:19 2104 #: admin/partials/authentiq-settings.php:190 105 105 msgid "Allow" 106 106 msgstr "" 107 107 108 #: admin/partials/authentiq-settings.php: 200108 #: admin/partials/authentiq-settings.php:198 109 109 msgid "all users" 110 110 msgstr "" 111 111 112 #: admin/partials/authentiq-settings.php: 201112 #: admin/partials/authentiq-settings.php:199 113 113 msgid "users without Authentiq ID" 114 114 msgstr "" 115 115 116 #: admin/partials/authentiq-settings.php:20 4116 #: admin/partials/authentiq-settings.php:202 117 117 msgid "to sign in with username and password." 118 118 msgstr "" 119 119 120 #: admin/partials/authentiq-settings.php:21 4120 #: admin/partials/authentiq-settings.php:212 121 121 msgid "" 122 122 "Skip the WordPress login page, and proceed directly to Authentiq sign in." 123 123 msgstr "" 124 124 125 #: admin/partials/authentiq-settings.php:221 126 msgid "Domain filter" 127 msgstr "" 128 129 #: admin/partials/authentiq-settings.php:226 125 #: admin/partials/authentiq-settings.php:219 126 msgid "Page after login" 127 msgstr "" 128 129 #: admin/partials/authentiq-settings.php:225 130 msgid "no redirect" 131 msgstr "" 132 133 #: admin/partials/authentiq-settings.php:228 134 msgid "for" 135 msgstr "" 136 137 #: admin/partials/authentiq-settings.php:236 138 msgid "All users" 139 msgstr "" 140 141 #: admin/partials/authentiq-settings.php:246 130 142 msgid "Domains to filter" 131 143 msgstr "" 132 144 133 #: admin/partials/authentiq-settings.php:2 35145 #: admin/partials/authentiq-settings.php:255 134 146 msgid "Only" 135 147 msgstr "" 136 148 137 #: admin/partials/authentiq-settings.php:2 36149 #: admin/partials/authentiq-settings.php:256 138 150 msgid "No" 139 151 msgstr "" 140 152 141 #: admin/partials/authentiq-settings.php:2 39153 #: admin/partials/authentiq-settings.php:259 142 154 msgid "Users from the following domains are allowed." 143 155 msgstr "" 144 156 145 #: admin/partials/authentiq-settings.php: 280157 #: admin/partials/authentiq-settings.php:300 146 158 #: admin/partials/authentiq-user-profile.php:135 147 159 msgid "Please try again." … … 184 196 msgstr "" 185 197 186 #: includes/class-authentiq-provider.php:2 19198 #: includes/class-authentiq-provider.php:220 187 199 msgid "" 188 200 "Error: Your Authentiq Client ID has not set in the Authentiq plugin settings." 189 201 msgstr "" 190 202 191 #: includes/class-authentiq-provider.php:22 3203 #: includes/class-authentiq-provider.php:224 192 204 msgid "" 193 205 "Error: Your Authentiq Client Secret has not set in the Authentiq plugin " … … 195 207 msgstr "" 196 208 197 #: includes/class-authentiq-provider.php:25 1209 #: includes/class-authentiq-provider.php:252 198 210 msgid "Error: There was an issue decoding the id_token." 199 211 msgstr "" 200 212 201 #: includes/class-authentiq-provider.php: 287202 #: includes/class-authentiq-provider.php:3 05213 #: includes/class-authentiq-provider.php:314 214 #: includes/class-authentiq-provider.php:332 203 215 msgid "Failed to login using Authentiq." 204 216 msgstr "" 205 217 206 #: includes/class-authentiq-provider.php: 292218 #: includes/class-authentiq-provider.php:319 207 219 msgid "" 208 220 "Error: the Client Secret configured on the Authentiq plugin is wrong. Make " … … 210 222 msgstr "" 211 223 212 #: includes/class-authentiq-provider.php:4 24224 #: includes/class-authentiq-provider.php:451 213 225 #, php-format 214 226 msgid "This email domain (%s) is not allowed by site administrator." 215 227 msgstr "" 216 228 217 #: includes/class-authentiq-provider.php:4 33229 #: includes/class-authentiq-provider.php:460 218 230 #, php-format 219 231 msgid "This email domain (%s) is not whitelisted by site administrator." 220 232 msgstr "" 221 233 222 #: includes/class-authentiq-provider.php:4 65234 #: includes/class-authentiq-provider.php:492 223 235 msgid "Please set an email at AuthentiqID App." 224 236 msgstr "" 225 237 226 #: includes/class-authentiq-provider.php:4 70238 #: includes/class-authentiq-provider.php:497 227 239 msgid "Please verify the email used at AuthentiqID App." 228 240 msgstr "" 229 241 230 #: includes/class-authentiq-provider.php: 495242 #: includes/class-authentiq-provider.php:522 231 243 msgid "This Authentiq ID is already linked to another WordPress user." 232 244 msgstr "" 233 245 234 #: includes/class-authentiq-provider.php:5 03246 #: includes/class-authentiq-provider.php:530 235 247 msgid "Current WordPress user is already linked with another Authentiq ID." 236 248 msgstr "" 237 249 238 #: includes/class-authentiq-provider.php:5 49250 #: includes/class-authentiq-provider.php:576 239 251 msgid "Failed to create WordPress user" 240 252 msgstr "" 241 253 242 #: includes/class-authentiq-provider.php:5 55254 #: includes/class-authentiq-provider.php:582 243 255 msgid "User registration is not allowed by site adminitrator." 244 256 msgstr "" 245 257 246 #: includes/class-authentiq-provider.php:6 44247 #: includes/class-authentiq-provider.php:6 64258 #: includes/class-authentiq-provider.php:671 259 #: includes/class-authentiq-provider.php:691 248 260 msgid "Passwords have been disabled. Try to login with Authentiq." 249 261 msgstr "" 250 262 251 #: includes/class-authentiq-provider.php:6 58263 #: includes/class-authentiq-provider.php:685 252 264 msgid "" 253 265 "You have already linked your account with Authentiq ID. Please use Authentiq " … … 255 267 msgstr "" 256 268 257 #: includes/class-authentiq-provider.php:7 26269 #: includes/class-authentiq-provider.php:753 258 270 msgid "" 259 271 "The Authentiq state parameter can not be verified. This may be due to this " … … 262 274 msgstr "" 263 275 264 #: includes/class-authentiq-user.php:1 36276 #: includes/class-authentiq-user.php:128 265 277 msgid "Email is required by your site administrator." 266 278 msgstr "" 267 279 268 #: includes/class-authentiq-user.php: 198280 #: includes/class-authentiq-user.php:216 269 281 msgid "No user set to be updated." 270 282 msgstr "" … … 293 305 294 306 #: includes/class-authentiq-widget.php:50 295 #: includes/class-authentiq-widget.php:14 4307 #: includes/class-authentiq-widget.php:146 296 308 #: public/partials/logged-in-state.php:3 297 309 msgid "Sign out" … … 315 327 316 328 #: public/class-authentiq-public.php:112 public/class-authentiq-public.php:151 317 #: public/class-authentiq-public.php:19 4329 #: public/class-authentiq-public.php:196 318 330 msgid "Please visit the Authentiq plugin settings and configure the client." 319 331 msgstr "" -
authentiq/trunk/public/class-authentiq-public.php
r1756312 r1788237 191 191 192 192 function render_logged_in_state($sign_out_text = null) { 193 global $wp; 194 193 195 if (!$this->options->is_configured()) { 194 196 $msg = __('Please visit the Authentiq plugin settings and configure the client.', AUTHENTIQ_LANG); … … 198 200 } 199 201 200 $redirect_to = get_permalink();202 $redirect_to = home_url(add_query_arg(array(),$wp->request)); 201 203 $logout_url = wp_logout_url($redirect_to); 202 204 -
authentiq/trunk/public/js/authentiq-public.min.js
r1775003 r1788237 1 1 /*! 2 * Authentiq WordPress plugin - v1.0. 22 * Authentiq WordPress plugin - v1.0.3 3 3 * 4 4 * Authentiq
Note: See TracChangeset
for help on using the changeset viewer.