Version Description
- Fix for issue during WP default login (unset session variables on logout)
- Fix for issue during Facebook login (used correct variable names)
- Fix for empty email insertion in account linking table (added empty email check before insertion)
- Fixed 'Add Application' button UI
- Code cleanup
Download this release
Release Info
Developer | cyberlord92 |
Plugin | Social Login |
Version | 6.5.0 |
Comparing to | |
See all releases |
Code changes from version 6.4.1 to 6.5.0
- class-mo-openid-login-widget.php +96 -211
- miniorange_openid_sso_settings.php +1 -1
- miniorange_openid_sso_settings_page.php +2 -2
- readme.txt +15 -1
class-mo-openid-login-widget.php
CHANGED
@@ -830,9 +830,13 @@ if(mo_openid_is_customer_registered()) {
|
|
830 |
}
|
831 |
|
832 |
function mo_openid_end_session() {
|
833 |
-
|
834 |
-
|
835 |
-
|
|
|
|
|
|
|
|
|
836 |
}
|
837 |
|
838 |
function encrypt_data($data, $key) {
|
@@ -847,20 +851,14 @@ if(mo_openid_is_customer_registered()) {
|
|
847 |
|
848 |
}
|
849 |
|
850 |
-
/**
|
851 |
-
*
|
852 |
-
*/
|
853 |
function mo_openid_login_validate(){
|
854 |
|
855 |
if( isset( $_POST['option'] ) and strpos( $_POST['option'], 'mo_openid_show_profile_form' ) !== false ){
|
856 |
-
$
|
857 |
-
$path .= '/wp-admin/load-styles.php?c=1&dir=ltr&load%5B%5D=dashicons,buttons,forms,l10n,login&ver=4.8.1';
|
858 |
-
$logo = plugins_url('/includes/images/miniOrange.png',__FILE__);
|
859 |
-
echo mo_openid_profile_completion_form($logo, $path, $_POST["last_name"],$_POST["first_name"], $_POST["user_full_name"],$_POST["user_url"], $_POST["user_picture"], $_POST['username_field'], $_POST['email_field'],$_POST["decrypted_app_name"],$_POST["decrypted_user_id"]);
|
860 |
exit;
|
861 |
}
|
862 |
|
863 |
-
if( isset( $_POST['option'] ) and strpos( $_POST['option'], 'mo_openid_account_linking' ) !== false ){
|
864 |
mo_openid_start_session();
|
865 |
//link account
|
866 |
if(!isset($_POST['mo_openid_create_new_account'])){
|
@@ -877,7 +875,6 @@ if(mo_openid_is_customer_registered()) {
|
|
877 |
$db_prefix = $wpdb->prefix;
|
878 |
$username_user_id = $wpdb->get_var($wpdb->prepare("SELECT ID FROM " .$db_prefix."users where user_login = %s", $_SESSION['username']));
|
879 |
|
880 |
-
|
881 |
if( !empty($username_user_id) ){
|
882 |
$email_explode = explode('@',$_SESSION['user_email'] );
|
883 |
$username = $email_explode[0];
|
@@ -932,7 +929,7 @@ if(mo_openid_is_customer_registered()) {
|
|
932 |
}
|
933 |
}
|
934 |
|
935 |
-
if( isset( $_REQUEST['option'] ) and strpos( $_REQUEST['option'], 'getmosociallogin' ) !== false ) {
|
936 |
$client_name = "wordpress";
|
937 |
$timestamp = round( microtime(true) * 1000 );
|
938 |
$api_key = get_option('mo_openid_admin_api_key');
|
@@ -959,7 +956,7 @@ if(mo_openid_is_customer_registered()) {
|
|
959 |
exit;
|
960 |
}
|
961 |
|
962 |
-
if( isset( $_POST['username_field']) and isset($_POST['email_field']) and $_POST['option'] == 'mo_openid_profile_form_submitted' ){
|
963 |
|
964 |
$username = $_POST['username_field'];
|
965 |
$user_email = $_POST['email_field'];
|
@@ -976,9 +973,6 @@ if(mo_openid_is_customer_registered()) {
|
|
976 |
$username = preg_replace('/[\x00-\x1F][\x7F][\x81][\x8D][\x8F][\x90][\x9D][\xA0][\xAD]/', '', $username);
|
977 |
$username = strtolower(str_replace(" ","",$username));
|
978 |
|
979 |
-
$path = site_url();
|
980 |
-
$path .= '/wp-admin/load-styles.php?c=1&dir=ltr&load%5B%5D=dashicons,buttons,forms,l10n,login&ver=4.8.1';
|
981 |
-
|
982 |
global $wpdb;
|
983 |
$email_user_id = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->users where user_email = %s", $user_email));
|
984 |
$username_user_id = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->users where user_login = %s", $username));
|
@@ -993,8 +987,7 @@ if(mo_openid_is_customer_registered()) {
|
|
993 |
}
|
994 |
|
995 |
$transaction_id = $send_content['tId'];
|
996 |
-
$
|
997 |
-
echo mo_openid_validate_otp_form($logo, $path, $username, $user_email, $transaction_id, $user_picture, $user_url,$last_name, $user_full_name,$first_name, $decrypted_app_name, $decrypted_user_id);
|
998 |
exit;
|
999 |
|
1000 |
}
|
@@ -1002,8 +995,7 @@ if(mo_openid_is_customer_registered()) {
|
|
1002 |
else {
|
1003 |
|
1004 |
if( isset($username_user_id) ){
|
1005 |
-
$
|
1006 |
-
echo mo_openid_username_already_exists($logo, $path, $last_name, $first_name, $user_full_name, $user_url, $user_picture, $username, $user_email, $decrypted_app_name, $decrypted_user_id);
|
1007 |
exit;
|
1008 |
}
|
1009 |
else {
|
@@ -1015,8 +1007,7 @@ if(mo_openid_is_customer_registered()) {
|
|
1015 |
}
|
1016 |
|
1017 |
$transaction_id = $send_content['tId'];
|
1018 |
-
$
|
1019 |
-
echo mo_openid_validate_otp_form($logo,$path, $username, $user_email, $transaction_id, $user_picture, $user_url, $last_name, $user_full_name,$first_name, $decrypted_app_name, $decrypted_user_id);
|
1020 |
exit;
|
1021 |
}
|
1022 |
|
@@ -1024,7 +1015,7 @@ if(mo_openid_is_customer_registered()) {
|
|
1024 |
}
|
1025 |
}
|
1026 |
|
1027 |
-
if( isset( $_POST['otp_field']) and $_POST['option'] == 'mo_openid_otp_validation' ){
|
1028 |
|
1029 |
$username = $_POST["username_field"];
|
1030 |
$user_email = $_POST["email_field"];
|
@@ -1041,13 +1032,9 @@ if(mo_openid_is_customer_registered()) {
|
|
1041 |
$validate_content = validate_otp_token($transaction_id, $otp_token);
|
1042 |
$status = $validate_content['status'];
|
1043 |
|
1044 |
-
$path = site_url();
|
1045 |
-
$path .= '/wp-admin/load-styles.php?c=1&dir=ltr&load%5B%5D=dashicons,buttons,forms,l10n,login&ver=4.8.1';
|
1046 |
-
|
1047 |
//if invalid OTP
|
1048 |
if($status == 'FAILURE'){
|
1049 |
-
$
|
1050 |
-
echo mo_openid_invalid_otp_form($logo, $path, $first_name, $last_name, $user_full_name, $user_url, $user_picture, $decrypted_app_name, $decrypted_user_id, $username,$user_email, $transaction_id); exit;
|
1051 |
}
|
1052 |
//if OTP is Valid
|
1053 |
else{
|
@@ -1095,10 +1082,7 @@ if(mo_openid_is_customer_registered()) {
|
|
1095 |
$_SESSION['social_app_name'] = $decrypted_app_name;
|
1096 |
$_SESSION['social_user_id'] = $decrypted_user_id;
|
1097 |
|
1098 |
-
|
1099 |
-
$path .= '/wp-admin/load-styles.php?c=1&dir=ltr&load%5B%5D=dashicons,buttons,forms,l10n,login&ver=4.8.1';
|
1100 |
-
$logo = plugins_url('/includes/images/miniOrange.png',__FILE__);
|
1101 |
-
echo mo_openid_account_linking_form($logo,$path);
|
1102 |
exit;
|
1103 |
}
|
1104 |
// else register
|
@@ -1109,7 +1093,7 @@ if(mo_openid_is_customer_registered()) {
|
|
1109 |
$random_password = wp_generate_password( 10, false );
|
1110 |
$user_profile_url = $user_url;
|
1111 |
|
1112 |
-
if(isset($
|
1113 |
$user_url = '';
|
1114 |
}
|
1115 |
|
@@ -1124,6 +1108,7 @@ if(mo_openid_is_customer_registered()) {
|
|
1124 |
);
|
1125 |
|
1126 |
$user_id = wp_insert_user( $userdata);
|
|
|
1127 |
if(is_wp_error( $user_id )) {
|
1128 |
//print_r($user_id);
|
1129 |
wp_die('There was an error in registration. Please contact your administrator.');
|
@@ -1152,7 +1137,7 @@ if(mo_openid_is_customer_registered()) {
|
|
1152 |
}
|
1153 |
}
|
1154 |
|
1155 |
-
if( isset( $_REQUEST['option'] ) and strpos( $_REQUEST['option'], 'moopenid' ) !== false ){
|
1156 |
|
1157 |
if( is_user_logged_in()){
|
1158 |
return;
|
@@ -1191,10 +1176,10 @@ if(mo_openid_is_customer_registered()) {
|
|
1191 |
|
1192 |
//if email or username not returned from app
|
1193 |
if ( empty($decrypted_email) || empty($decrypted_user_name) ){
|
|
|
1194 |
//check if provider + identifier group exists
|
1195 |
global $wpdb;
|
1196 |
$db_prefix = $wpdb->prefix;
|
1197 |
-
$table_name = $wpdb->prefix."mo_openid_linked_user";
|
1198 |
$id_returning_user = $wpdb->get_var($wpdb->prepare("SELECT user_id FROM ".$db_prefix."mo_openid_linked_user where linked_social_app = \"%s\" AND identifier = %s",$decrypted_app_name,$decrypted_user_id));
|
1199 |
|
1200 |
$email_user_id = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->users where user_email = \"%s\"", $decrypted_email));
|
@@ -1204,28 +1189,7 @@ if(mo_openid_is_customer_registered()) {
|
|
1204 |
if((isset($id_returning_user)) || (isset($email_user_id)) ){
|
1205 |
if ((!isset($id_returning_user)) && (isset($email_user_id)) ){
|
1206 |
$id_returning_user = $email_user_id;
|
1207 |
-
|
1208 |
-
$result = $wpdb->insert(
|
1209 |
-
$table_name,
|
1210 |
-
array(
|
1211 |
-
'linked_social_app' => $decrypted_app_name,
|
1212 |
-
'linked_email' => $decrypted_email,
|
1213 |
-
'user_id' => $id_returning_user,
|
1214 |
-
'identifier' => $decrypted_user_id
|
1215 |
-
),
|
1216 |
-
array(
|
1217 |
-
'%s',
|
1218 |
-
'%s',
|
1219 |
-
'%d',
|
1220 |
-
'%s'
|
1221 |
-
)
|
1222 |
-
);
|
1223 |
-
if($result === false){
|
1224 |
-
/*$wpdb->show_errors();
|
1225 |
-
$wpdb->print_error();
|
1226 |
-
exit;*/
|
1227 |
-
wp_die('Error in insert query');
|
1228 |
-
}
|
1229 |
}
|
1230 |
$user = get_user_by('id', $id_returning_user );
|
1231 |
if(get_option('moopenid_social_login_avatar') && isset($user_picture))
|
@@ -1240,10 +1204,7 @@ if(mo_openid_is_customer_registered()) {
|
|
1240 |
}
|
1241 |
// if new user and profile completion is enabled
|
1242 |
elseif (get_option('mo_openid_enable_profile_completion')){
|
1243 |
-
$
|
1244 |
-
$path .= '/wp-admin/load-styles.php?c=1&dir=ltr&load%5B%5D=dashicons,buttons,forms,l10n,login&ver=4.8.1';
|
1245 |
-
$logo = plugins_url('/includes/images/miniOrange.png',__FILE__);
|
1246 |
-
echo mo_openid_profile_completion_form($logo, $path, $last_name, $first_name, $user_full_name, $user_url, $user_picture, $decrypted_user_name, $decrypted_email, $decrypted_app_name, $decrypted_user_id);
|
1247 |
exit;
|
1248 |
}
|
1249 |
// if new user and profile completion and account linking is disabled, auto create dummy data and register user
|
@@ -1269,11 +1230,9 @@ if(mo_openid_is_customer_registered()) {
|
|
1269 |
$username = 'user_'.get_option('mo_openid_user_count');
|
1270 |
$user_email = 'user_'.get_option('mo_openid_user_count').'@'.$split_app_name[0].'.com';
|
1271 |
}
|
1272 |
-
|
1273 |
// remove white space from email
|
1274 |
$user_email = str_replace(' ', '', $user_email);
|
1275 |
|
1276 |
-
|
1277 |
//account linking
|
1278 |
if ( get_option('mo_openid_account_linking_enable')){
|
1279 |
mo_openid_start_session();
|
@@ -1287,18 +1246,14 @@ if(mo_openid_is_customer_registered()) {
|
|
1287 |
$_SESSION['social_app_name'] = $decrypted_app_name;
|
1288 |
$_SESSION['social_user_id'] = $decrypted_user_id;
|
1289 |
|
1290 |
-
|
1291 |
-
$path .= '/wp-admin/load-styles.php?c=1&dir=ltr&load%5B%5D=dashicons,buttons,forms,l10n,login&ver=4.8.1';
|
1292 |
-
$logo = plugins_url('/includes/images/miniOrange.png',__FILE__);
|
1293 |
-
echo mo_openid_account_linking_form($logo,$path);
|
1294 |
exit;
|
1295 |
}
|
1296 |
|
1297 |
$random_password = wp_generate_password( 10, false );
|
1298 |
-
|
1299 |
$user_profile_url = $user_url;
|
1300 |
|
1301 |
-
if(isset($
|
1302 |
$user_url = '';
|
1303 |
}
|
1304 |
|
@@ -1312,7 +1267,6 @@ if(mo_openid_is_customer_registered()) {
|
|
1312 |
'user_url' => $user_url,
|
1313 |
);
|
1314 |
|
1315 |
-
|
1316 |
$user_id = wp_insert_user( $userdata);
|
1317 |
if(is_wp_error( $user_id )) {
|
1318 |
//print_r($user_id);
|
@@ -1351,7 +1305,6 @@ if(mo_openid_is_customer_registered()) {
|
|
1351 |
else{
|
1352 |
|
1353 |
global $wpdb;
|
1354 |
-
$table_name = $wpdb->prefix . 'mo_openid_linked_user';
|
1355 |
$user_email = sanitize_email($decrypted_email);
|
1356 |
$username = strtolower(str_replace(" ","",$decrypted_user_name));
|
1357 |
|
@@ -1370,28 +1323,7 @@ if(mo_openid_is_customer_registered()) {
|
|
1370 |
|
1371 |
if ((!isset($linked_email_id)) && (isset($email_user_id)) ){
|
1372 |
$linked_email_id = $email_user_id;
|
1373 |
-
|
1374 |
-
$result = $wpdb->insert(
|
1375 |
-
$table_name,
|
1376 |
-
array(
|
1377 |
-
'linked_social_app' => $decrypted_app_name,
|
1378 |
-
'linked_email' => $user_email,
|
1379 |
-
'user_id' => $linked_email_id,
|
1380 |
-
'identifier' => $decrypted_user_id
|
1381 |
-
),
|
1382 |
-
array(
|
1383 |
-
'%s',
|
1384 |
-
'%s',
|
1385 |
-
'%d',
|
1386 |
-
'%s'
|
1387 |
-
)
|
1388 |
-
);
|
1389 |
-
if($result === false){
|
1390 |
-
/*$wpdb->show_errors();
|
1391 |
-
$wpdb->print_error();
|
1392 |
-
exit;*/
|
1393 |
-
wp_die('Error in insert query');
|
1394 |
-
}
|
1395 |
}
|
1396 |
|
1397 |
if(isset($linked_email_id)){
|
@@ -1428,15 +1360,11 @@ if(mo_openid_is_customer_registered()) {
|
|
1428 |
$_SESSION['user_picture'] = $user_picture;
|
1429 |
$_SESSION['social_app_name'] = $decrypted_app_name;
|
1430 |
$_SESSION['social_user_id'] = $decrypted_user_id;
|
1431 |
-
|
1432 |
-
$path .= '/wp-admin/load-styles.php?c=1&dir=ltr&load%5B%5D=dashicons,buttons,forms,l10n,login&ver=4.8.1';
|
1433 |
-
$logo = plugins_url('/includes/images/miniOrange.png',__FILE__);
|
1434 |
-
echo mo_openid_account_linking_form($logo,$path);
|
1435 |
exit;
|
1436 |
}
|
1437 |
else {
|
1438 |
// this user is a guest
|
1439 |
-
|
1440 |
// auto registration is enabled
|
1441 |
if(get_option('mo_openid_auto_register_enable')) {
|
1442 |
$random_password = wp_generate_password( 10, false );
|
@@ -1453,7 +1381,7 @@ if(mo_openid_is_customer_registered()) {
|
|
1453 |
|
1454 |
$user_profile_url = $user_url;
|
1455 |
|
1456 |
-
if(isset($
|
1457 |
$user_url = '';
|
1458 |
}
|
1459 |
|
@@ -1500,19 +1428,15 @@ if(mo_openid_is_customer_registered()) {
|
|
1500 |
}
|
1501 |
}
|
1502 |
|
1503 |
-
if( isset( $_REQUEST['autoregister'] ) and strpos( $_REQUEST['autoregister'],'false') !== false ) {
|
1504 |
if(!is_user_logged_in()) {
|
1505 |
mo_openid_disabled_register_message();
|
1506 |
}
|
1507 |
}
|
1508 |
|
1509 |
-
if( isset( $_REQUEST['option'] ) and strpos( $_REQUEST['option'], 'oauthredirect' ) !== false ) {
|
1510 |
|
1511 |
$appname = $_REQUEST['app_name'];
|
1512 |
-
if(get_option('mo_openid_apps_list'))
|
1513 |
-
$appslist = get_option('mo_openid_apps_list');
|
1514 |
-
else
|
1515 |
-
$appslist=array();
|
1516 |
|
1517 |
if(isset($_REQUEST['test']))
|
1518 |
setcookie("mo_oauth_test", true);
|
@@ -1562,7 +1486,7 @@ if(mo_openid_is_customer_registered()) {
|
|
1562 |
exit;
|
1563 |
}
|
1564 |
|
1565 |
-
if( strpos( $_SERVER['REQUEST_URI'], "/openidcallback") !== false ) {
|
1566 |
|
1567 |
if( is_user_logged_in()){
|
1568 |
return;
|
@@ -1800,7 +1724,6 @@ if(mo_openid_is_customer_registered()) {
|
|
1800 |
if ( empty($email) || empty($user_name) ){
|
1801 |
global $wpdb;
|
1802 |
$db_prefix = $wpdb->prefix;
|
1803 |
-
$table_name = $wpdb->prefix."mo_openid_linked_user";
|
1804 |
$id_returning_user = $wpdb->get_var($wpdb->prepare("SELECT user_id FROM ".$db_prefix."mo_openid_linked_user where linked_social_app = \"%s\" AND identifier = %s",$social_app_name,$social_user_id));
|
1805 |
|
1806 |
$email_user_id = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->users where user_email = \"%s\"", $email));
|
@@ -1811,28 +1734,7 @@ if(mo_openid_is_customer_registered()) {
|
|
1811 |
if((isset($id_returning_user)) || (isset($email_user_id))){
|
1812 |
if ((!isset($id_returning_user)) && (isset($email_user_id)) ){
|
1813 |
$id_returning_user = $email_user_id;
|
1814 |
-
|
1815 |
-
$result = $wpdb->insert(
|
1816 |
-
$table_name,
|
1817 |
-
array(
|
1818 |
-
'linked_social_app' => $social_app_name,
|
1819 |
-
'linked_email' => $email,
|
1820 |
-
'user_id' => $id_returning_user,
|
1821 |
-
'identifier' => $social_user_id
|
1822 |
-
),
|
1823 |
-
array(
|
1824 |
-
'%s',
|
1825 |
-
'%s',
|
1826 |
-
'%d',
|
1827 |
-
'%s'
|
1828 |
-
)
|
1829 |
-
);
|
1830 |
-
if($result === false){
|
1831 |
-
/*$wpdb->show_errors();
|
1832 |
-
$wpdb->print_error();
|
1833 |
-
exit;*/
|
1834 |
-
wp_die('Error in insert query');
|
1835 |
-
}
|
1836 |
}
|
1837 |
$user = get_user_by('id', $id_returning_user );
|
1838 |
if(get_option('moopenid_social_login_avatar') && isset($user_picture))
|
@@ -1849,10 +1751,7 @@ if(mo_openid_is_customer_registered()) {
|
|
1849 |
}
|
1850 |
// if new user and profile completion is enabled
|
1851 |
elseif (get_option('mo_openid_enable_profile_completion')){
|
1852 |
-
$
|
1853 |
-
$path .= '/wp-admin/load-styles.php?c=1&dir=ltr&load%5B%5D=dashicons,buttons,forms,l10n,login&ver=4.8.1';
|
1854 |
-
$logo = plugins_url('/includes/images/miniOrange.png',__FILE__);
|
1855 |
-
echo mo_openid_profile_completion_form($logo, $path, $last_name, $first_name, $user_full_name, $user_url, $user_picture, $user_name, $email, $social_app_name, $social_user_id);
|
1856 |
exit;
|
1857 |
}
|
1858 |
// if new user and profile completion is disabled, auto create dummy data and register user
|
@@ -1891,10 +1790,7 @@ if(mo_openid_is_customer_registered()) {
|
|
1891 |
$_SESSION['user_picture'] = $user_picture;
|
1892 |
$_SESSION['social_app_name'] = $social_app_name;
|
1893 |
$_SESSION['social_user_id'] = $social_user_id;
|
1894 |
-
|
1895 |
-
$path .= '/wp-admin/load-styles.php?c=1&dir=ltr&load%5B%5D=dashicons,buttons,forms,l10n,login&ver=4.8.1';
|
1896 |
-
$logo = plugins_url('/includes/images/miniOrange.png',__FILE__);
|
1897 |
-
echo mo_openid_account_linking_form($logo,$path);
|
1898 |
exit;
|
1899 |
}
|
1900 |
|
@@ -1902,7 +1798,7 @@ if(mo_openid_is_customer_registered()) {
|
|
1902 |
|
1903 |
$user_profile_url = $user_url;
|
1904 |
|
1905 |
-
if(isset($
|
1906 |
$user_url = '';
|
1907 |
}
|
1908 |
|
@@ -1950,7 +1846,6 @@ if(mo_openid_is_customer_registered()) {
|
|
1950 |
//email and username are both returned..dont show profile completion
|
1951 |
else{
|
1952 |
global $wpdb;
|
1953 |
-
$table_name = $wpdb->prefix . 'mo_openid_linked_user';
|
1954 |
$user_email = sanitize_email($email);
|
1955 |
$username = strtolower(str_replace(" ","",$user_name));
|
1956 |
|
@@ -1967,29 +1862,9 @@ if(mo_openid_is_customer_registered()) {
|
|
1967 |
mo_openid_start_session();
|
1968 |
if((isset($linked_email_id)) || (isset($email_user_id)) || (isset($existing_email_user_id)) ) { // user is a member
|
1969 |
if ((!isset($linked_email_id)) && (isset($email_user_id)) ){
|
1970 |
-
$linked_email_id = $email_user_id;
|
1971 |
|
1972 |
-
$
|
1973 |
-
|
1974 |
-
array(
|
1975 |
-
'linked_social_app' => $social_app_name,
|
1976 |
-
'linked_email' => $user_email,
|
1977 |
-
'user_id' => $linked_email_id,
|
1978 |
-
'identifier' => $social_user_id
|
1979 |
-
),
|
1980 |
-
array(
|
1981 |
-
'%s',
|
1982 |
-
'%s',
|
1983 |
-
'%d',
|
1984 |
-
'%s'
|
1985 |
-
)
|
1986 |
-
);
|
1987 |
-
if($result === false){
|
1988 |
-
/*$wpdb->show_errors();
|
1989 |
-
$wpdb->print_error();
|
1990 |
-
exit;*/
|
1991 |
-
wp_die('Error in insert query');
|
1992 |
-
}
|
1993 |
}
|
1994 |
|
1995 |
if(isset($linked_email_id)){
|
@@ -2028,10 +1903,7 @@ if(mo_openid_is_customer_registered()) {
|
|
2028 |
$_SESSION['user_picture'] = $user_picture;
|
2029 |
$_SESSION['social_app_name'] = $social_app_name;
|
2030 |
$_SESSION['social_user_id'] = $social_user_id;
|
2031 |
-
|
2032 |
-
$path .= '/wp-admin/load-styles.php?c=1&dir=ltr&load%5B%5D=dashicons,buttons,forms,l10n,login&ver=4.8.1';
|
2033 |
-
$logo = plugins_url('/includes/images/miniOrange.png',__FILE__);
|
2034 |
-
echo mo_openid_account_linking_form($logo,$path);
|
2035 |
exit;
|
2036 |
}
|
2037 |
else {
|
@@ -2041,7 +1913,6 @@ if(mo_openid_is_customer_registered()) {
|
|
2041 |
$random_password = wp_generate_password( 10, false );
|
2042 |
|
2043 |
if( isset($username_user_id) ){
|
2044 |
-
$email_array = array();
|
2045 |
$email_array = explode('@', $user_email);
|
2046 |
$username = $email_array[0];
|
2047 |
$username_user_id = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->users where user_login = %s", $username));
|
@@ -2053,7 +1924,7 @@ if(mo_openid_is_customer_registered()) {
|
|
2053 |
|
2054 |
$user_profile_url = $user_url;
|
2055 |
|
2056 |
-
if(isset($
|
2057 |
$user_url = '';
|
2058 |
}
|
2059 |
|
@@ -2068,7 +1939,6 @@ if(mo_openid_is_customer_registered()) {
|
|
2068 |
);
|
2069 |
|
2070 |
$user_id = wp_insert_user( $userdata);
|
2071 |
-
|
2072 |
if(is_wp_error( $user_id )) {
|
2073 |
//print_r($user_id);
|
2074 |
wp_die('There was an error in registration. Please contact your administrator.');
|
@@ -2107,7 +1977,8 @@ if(mo_openid_is_customer_registered()) {
|
|
2107 |
}
|
2108 |
}
|
2109 |
|
2110 |
-
function mo_openid_validate_otp_form($
|
|
|
2111 |
$html = '<head><link rel="stylesheet" href='.$path.' type="text/css" media="all" /></head>
|
2112 |
|
2113 |
<body class="login login-action-login wp-core-ui locale-en-us">
|
@@ -2173,7 +2044,8 @@ if(mo_openid_is_customer_registered()) {
|
|
2173 |
return $html;
|
2174 |
}
|
2175 |
|
2176 |
-
function mo_openid_username_already_exists($
|
|
|
2177 |
$html = '<style>.form-input-validation.is-error {color: #d94f4f;}</style><head><link rel="stylesheet" href='.$path.' type="text/css" media="all" /></head>
|
2178 |
|
2179 |
<body class="login login-action-login wp-core-ui locale-en-us">
|
@@ -2220,7 +2092,8 @@ if(mo_openid_is_customer_registered()) {
|
|
2220 |
|
2221 |
}
|
2222 |
|
2223 |
-
function mo_openid_profile_completion_form($
|
|
|
2224 |
$html = '<style>.form-input-validation.note {color: #d94f4f;}</style>
|
2225 |
<head><link rel="stylesheet" href='.$path.' type="text/css" media="all" /></head>
|
2226 |
<body class="login login-action-login wp-core-ui locale-en-us">
|
@@ -2267,7 +2140,8 @@ if(mo_openid_is_customer_registered()) {
|
|
2267 |
return $html;
|
2268 |
}
|
2269 |
|
2270 |
-
function mo_openid_invalid_otp_form($
|
|
|
2271 |
$html = '<style>.form-input-validation.is-error {color: #d94f4f;}</style>
|
2272 |
<head><link rel="stylesheet" href='.$path.' type="text/css" media="all" /></head>
|
2273 |
|
@@ -2313,7 +2187,8 @@ if(mo_openid_is_customer_registered()) {
|
|
2313 |
return $html;
|
2314 |
}
|
2315 |
|
2316 |
-
function mo_openid_account_linking_form(
|
|
|
2317 |
$html = "<head><link rel=\"stylesheet\" href=".$path. " type='text/css' media='all' /><head>
|
2318 |
<body class='login login-action-login wp-core-ui locale-en-us'>
|
2319 |
<div style=\"position:fixed;background:#f1f1f1;\"></div>
|
@@ -2363,55 +2238,59 @@ if(mo_openid_is_customer_registered()) {
|
|
2363 |
}
|
2364 |
|
2365 |
function mo_openid_link_account( $username, $user ){
|
2366 |
-
|
2367 |
if($user){
|
2368 |
$userid = $user->ID;
|
2369 |
}
|
2370 |
-
else{
|
2371 |
-
wp_die('No user is returned.');
|
2372 |
-
}
|
2373 |
mo_openid_start_session();
|
2374 |
-
$_SESSION['social_user_id'] = isset($_SESSION['social_user_id']) ? $_SESSION['social_user_id']:'';
|
2375 |
-
$_SESSION['social_app_name'] = isset($_SESSION['social_app_name']) ? $_SESSION['social_app_name']:'';
|
2376 |
-
|
2377 |
-
if(isset($userid) && is_null($_SESSION['social_user_id'] ) && is_null($_SESSION['social_app_name']))
|
2378 |
-
{
|
2379 |
-
return;
|
2380 |
-
}
|
2381 |
|
2382 |
$user_email = isset($_SESSION['user_email']) ? $_SESSION['user_email']:'';
|
2383 |
$social_app_identifier = isset($_SESSION['social_user_id']) ? $_SESSION['social_user_id']:'';
|
2384 |
$social_app_name = isset($_SESSION['social_app_name']) ? $_SESSION['social_app_name']:'';
|
2385 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2386 |
|
2387 |
global $wpdb;
|
2388 |
-
$table_name = $wpdb->prefix . 'mo_openid_linked_user';
|
2389 |
$db_prefix = $wpdb->prefix;
|
2390 |
-
$linked_email_id = $wpdb->get_var($wpdb->prepare("SELECT user_id FROM ".$db_prefix."mo_openid_linked_user where linked_email = \"%s\" AND linked_social_app
|
2391 |
|
2392 |
-
if
|
2393 |
-
|
2394 |
-
|
2395 |
-
|
2396 |
-
|
2397 |
-
'linked_email' => $user_email,
|
2398 |
-
'user_id' => $userid,
|
2399 |
-
'identifier' => $social_app_identifier
|
2400 |
-
),
|
2401 |
-
array(
|
2402 |
-
'%s',
|
2403 |
-
'%s',
|
2404 |
-
'%d',
|
2405 |
-
'%s'
|
2406 |
-
)
|
2407 |
-
);
|
2408 |
-
if($result === false){
|
2409 |
-
/*$wpdb->show_errors();
|
2410 |
-
$wpdb->print_error();
|
2411 |
-
exit;*/
|
2412 |
-
wp_die('Error in insert query');
|
2413 |
-
}
|
2414 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2415 |
}
|
2416 |
}
|
2417 |
|
@@ -2660,6 +2539,12 @@ Thank you.';
|
|
2660 |
}
|
2661 |
}
|
2662 |
|
|
|
|
|
|
|
|
|
|
|
|
|
2663 |
if(get_option('mo_openid_logout_redirection_enable') == 1){
|
2664 |
add_filter( 'logout_url', 'mo_openid_redirect_after_logout',0,1);
|
2665 |
}
|
@@ -2670,7 +2555,7 @@ Thank you.';
|
|
2670 |
|
2671 |
add_action( 'init', 'mo_openid_login_validate' );
|
2672 |
//add_action( 'init', 'mo_openid_start_session' );
|
2673 |
-
|
2674 |
add_action( 'mo_user_register', 'mo_openid_update_role', 1, 2);
|
2675 |
add_action( 'wp_login', 'mo_openid_login_redirect', 10, 2);
|
2676 |
add_action( 'wp_login', 'mo_openid_link_account', 9, 2);
|
830 |
}
|
831 |
|
832 |
function mo_openid_end_session() {
|
833 |
+
|
834 |
+
session_start();
|
835 |
+
session_unset(); //unsets all session variables
|
836 |
+
|
837 |
+
/*if( session_id() ) {
|
838 |
+
session_destroy();
|
839 |
+
}*/
|
840 |
}
|
841 |
|
842 |
function encrypt_data($data, $key) {
|
851 |
|
852 |
}
|
853 |
|
|
|
|
|
|
|
854 |
function mo_openid_login_validate(){
|
855 |
|
856 |
if( isset( $_POST['option'] ) and strpos( $_POST['option'], 'mo_openid_show_profile_form' ) !== false ){
|
857 |
+
echo mo_openid_profile_completion_form($_POST["last_name"],$_POST["first_name"], $_POST["user_full_name"],$_POST["user_url"], $_POST["user_picture"], $_POST['username_field'], $_POST['email_field'],$_POST["decrypted_app_name"],$_POST["decrypted_user_id"]);
|
|
|
|
|
|
|
858 |
exit;
|
859 |
}
|
860 |
|
861 |
+
else if( isset( $_POST['option'] ) and strpos( $_POST['option'], 'mo_openid_account_linking' ) !== false ){
|
862 |
mo_openid_start_session();
|
863 |
//link account
|
864 |
if(!isset($_POST['mo_openid_create_new_account'])){
|
875 |
$db_prefix = $wpdb->prefix;
|
876 |
$username_user_id = $wpdb->get_var($wpdb->prepare("SELECT ID FROM " .$db_prefix."users where user_login = %s", $_SESSION['username']));
|
877 |
|
|
|
878 |
if( !empty($username_user_id) ){
|
879 |
$email_explode = explode('@',$_SESSION['user_email'] );
|
880 |
$username = $email_explode[0];
|
929 |
}
|
930 |
}
|
931 |
|
932 |
+
else if( isset( $_REQUEST['option'] ) and strpos( $_REQUEST['option'], 'getmosociallogin' ) !== false ) {
|
933 |
$client_name = "wordpress";
|
934 |
$timestamp = round( microtime(true) * 1000 );
|
935 |
$api_key = get_option('mo_openid_admin_api_key');
|
956 |
exit;
|
957 |
}
|
958 |
|
959 |
+
else if( isset( $_POST['username_field']) and isset($_POST['email_field']) and $_POST['option'] == 'mo_openid_profile_form_submitted' ){
|
960 |
|
961 |
$username = $_POST['username_field'];
|
962 |
$user_email = $_POST['email_field'];
|
973 |
$username = preg_replace('/[\x00-\x1F][\x7F][\x81][\x8D][\x8F][\x90][\x9D][\xA0][\xAD]/', '', $username);
|
974 |
$username = strtolower(str_replace(" ","",$username));
|
975 |
|
|
|
|
|
|
|
976 |
global $wpdb;
|
977 |
$email_user_id = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->users where user_email = %s", $user_email));
|
978 |
$username_user_id = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->users where user_login = %s", $username));
|
987 |
}
|
988 |
|
989 |
$transaction_id = $send_content['tId'];
|
990 |
+
echo mo_openid_validate_otp_form($username, $user_email, $transaction_id, $user_picture, $user_url,$last_name, $user_full_name,$first_name, $decrypted_app_name, $decrypted_user_id);
|
|
|
991 |
exit;
|
992 |
|
993 |
}
|
995 |
else {
|
996 |
|
997 |
if( isset($username_user_id) ){
|
998 |
+
echo mo_openid_username_already_exists($last_name, $first_name, $user_full_name, $user_url, $user_picture, $username, $user_email, $decrypted_app_name, $decrypted_user_id);
|
|
|
999 |
exit;
|
1000 |
}
|
1001 |
else {
|
1007 |
}
|
1008 |
|
1009 |
$transaction_id = $send_content['tId'];
|
1010 |
+
echo mo_openid_validate_otp_form($username, $user_email, $transaction_id, $user_picture, $user_url, $last_name, $user_full_name,$first_name, $decrypted_app_name, $decrypted_user_id);
|
|
|
1011 |
exit;
|
1012 |
}
|
1013 |
|
1015 |
}
|
1016 |
}
|
1017 |
|
1018 |
+
else if( isset( $_POST['otp_field']) and $_POST['option'] == 'mo_openid_otp_validation' ){
|
1019 |
|
1020 |
$username = $_POST["username_field"];
|
1021 |
$user_email = $_POST["email_field"];
|
1032 |
$validate_content = validate_otp_token($transaction_id, $otp_token);
|
1033 |
$status = $validate_content['status'];
|
1034 |
|
|
|
|
|
|
|
1035 |
//if invalid OTP
|
1036 |
if($status == 'FAILURE'){
|
1037 |
+
echo mo_openid_invalid_otp_form($first_name, $last_name, $user_full_name, $user_url, $user_picture, $decrypted_app_name, $decrypted_user_id, $username,$user_email, $transaction_id); exit;
|
|
|
1038 |
}
|
1039 |
//if OTP is Valid
|
1040 |
else{
|
1082 |
$_SESSION['social_app_name'] = $decrypted_app_name;
|
1083 |
$_SESSION['social_user_id'] = $decrypted_user_id;
|
1084 |
|
1085 |
+
echo mo_openid_account_linking_form();
|
|
|
|
|
|
|
1086 |
exit;
|
1087 |
}
|
1088 |
// else register
|
1093 |
$random_password = wp_generate_password( 10, false );
|
1094 |
$user_profile_url = $user_url;
|
1095 |
|
1096 |
+
if(isset($decrypted_app_name) && !empty($decrypted_app_name) && $decrypted_app_name=='facebook'){
|
1097 |
$user_url = '';
|
1098 |
}
|
1099 |
|
1108 |
);
|
1109 |
|
1110 |
$user_id = wp_insert_user( $userdata);
|
1111 |
+
|
1112 |
if(is_wp_error( $user_id )) {
|
1113 |
//print_r($user_id);
|
1114 |
wp_die('There was an error in registration. Please contact your administrator.');
|
1137 |
}
|
1138 |
}
|
1139 |
|
1140 |
+
else if( isset( $_REQUEST['option'] ) and strpos( $_REQUEST['option'], 'moopenid' ) !== false ){
|
1141 |
|
1142 |
if( is_user_logged_in()){
|
1143 |
return;
|
1176 |
|
1177 |
//if email or username not returned from app
|
1178 |
if ( empty($decrypted_email) || empty($decrypted_user_name) ){
|
1179 |
+
|
1180 |
//check if provider + identifier group exists
|
1181 |
global $wpdb;
|
1182 |
$db_prefix = $wpdb->prefix;
|
|
|
1183 |
$id_returning_user = $wpdb->get_var($wpdb->prepare("SELECT user_id FROM ".$db_prefix."mo_openid_linked_user where linked_social_app = \"%s\" AND identifier = %s",$decrypted_app_name,$decrypted_user_id));
|
1184 |
|
1185 |
$email_user_id = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->users where user_email = \"%s\"", $decrypted_email));
|
1189 |
if((isset($id_returning_user)) || (isset($email_user_id)) ){
|
1190 |
if ((!isset($id_returning_user)) && (isset($email_user_id)) ){
|
1191 |
$id_returning_user = $email_user_id;
|
1192 |
+
mo_openid_insert_query($decrypted_app_name,$decrypted_email,$id_returning_user,$decrypted_user_id);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1193 |
}
|
1194 |
$user = get_user_by('id', $id_returning_user );
|
1195 |
if(get_option('moopenid_social_login_avatar') && isset($user_picture))
|
1204 |
}
|
1205 |
// if new user and profile completion is enabled
|
1206 |
elseif (get_option('mo_openid_enable_profile_completion')){
|
1207 |
+
echo mo_openid_profile_completion_form($last_name, $first_name, $user_full_name, $user_url, $user_picture, $decrypted_user_name, $decrypted_email, $decrypted_app_name, $decrypted_user_id);
|
|
|
|
|
|
|
1208 |
exit;
|
1209 |
}
|
1210 |
// if new user and profile completion and account linking is disabled, auto create dummy data and register user
|
1230 |
$username = 'user_'.get_option('mo_openid_user_count');
|
1231 |
$user_email = 'user_'.get_option('mo_openid_user_count').'@'.$split_app_name[0].'.com';
|
1232 |
}
|
|
|
1233 |
// remove white space from email
|
1234 |
$user_email = str_replace(' ', '', $user_email);
|
1235 |
|
|
|
1236 |
//account linking
|
1237 |
if ( get_option('mo_openid_account_linking_enable')){
|
1238 |
mo_openid_start_session();
|
1246 |
$_SESSION['social_app_name'] = $decrypted_app_name;
|
1247 |
$_SESSION['social_user_id'] = $decrypted_user_id;
|
1248 |
|
1249 |
+
echo mo_openid_account_linking_form();
|
|
|
|
|
|
|
1250 |
exit;
|
1251 |
}
|
1252 |
|
1253 |
$random_password = wp_generate_password( 10, false );
|
|
|
1254 |
$user_profile_url = $user_url;
|
1255 |
|
1256 |
+
if(isset($decrypted_app_name) && !empty($decrypted_app_name) && $decrypted_app_name=='facebook'){
|
1257 |
$user_url = '';
|
1258 |
}
|
1259 |
|
1267 |
'user_url' => $user_url,
|
1268 |
);
|
1269 |
|
|
|
1270 |
$user_id = wp_insert_user( $userdata);
|
1271 |
if(is_wp_error( $user_id )) {
|
1272 |
//print_r($user_id);
|
1305 |
else{
|
1306 |
|
1307 |
global $wpdb;
|
|
|
1308 |
$user_email = sanitize_email($decrypted_email);
|
1309 |
$username = strtolower(str_replace(" ","",$decrypted_user_name));
|
1310 |
|
1323 |
|
1324 |
if ((!isset($linked_email_id)) && (isset($email_user_id)) ){
|
1325 |
$linked_email_id = $email_user_id;
|
1326 |
+
mo_openid_insert_query($decrypted_app_name,$user_email,$linked_email_id,$decrypted_user_id);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1327 |
}
|
1328 |
|
1329 |
if(isset($linked_email_id)){
|
1360 |
$_SESSION['user_picture'] = $user_picture;
|
1361 |
$_SESSION['social_app_name'] = $decrypted_app_name;
|
1362 |
$_SESSION['social_user_id'] = $decrypted_user_id;
|
1363 |
+
echo mo_openid_account_linking_form();
|
|
|
|
|
|
|
1364 |
exit;
|
1365 |
}
|
1366 |
else {
|
1367 |
// this user is a guest
|
|
|
1368 |
// auto registration is enabled
|
1369 |
if(get_option('mo_openid_auto_register_enable')) {
|
1370 |
$random_password = wp_generate_password( 10, false );
|
1381 |
|
1382 |
$user_profile_url = $user_url;
|
1383 |
|
1384 |
+
if(isset($decrypted_app_name) && !empty($decrypted_app_name) && $decrypted_app_name=='facebook'){
|
1385 |
$user_url = '';
|
1386 |
}
|
1387 |
|
1428 |
}
|
1429 |
}
|
1430 |
|
1431 |
+
else if( isset( $_REQUEST['autoregister'] ) and strpos( $_REQUEST['autoregister'],'false') !== false ) {
|
1432 |
if(!is_user_logged_in()) {
|
1433 |
mo_openid_disabled_register_message();
|
1434 |
}
|
1435 |
}
|
1436 |
|
1437 |
+
else if( isset( $_REQUEST['option'] ) and strpos( $_REQUEST['option'], 'oauthredirect' ) !== false ) {
|
1438 |
|
1439 |
$appname = $_REQUEST['app_name'];
|
|
|
|
|
|
|
|
|
1440 |
|
1441 |
if(isset($_REQUEST['test']))
|
1442 |
setcookie("mo_oauth_test", true);
|
1486 |
exit;
|
1487 |
}
|
1488 |
|
1489 |
+
else if( strpos( $_SERVER['REQUEST_URI'], "/openidcallback") !== false ) {
|
1490 |
|
1491 |
if( is_user_logged_in()){
|
1492 |
return;
|
1724 |
if ( empty($email) || empty($user_name) ){
|
1725 |
global $wpdb;
|
1726 |
$db_prefix = $wpdb->prefix;
|
|
|
1727 |
$id_returning_user = $wpdb->get_var($wpdb->prepare("SELECT user_id FROM ".$db_prefix."mo_openid_linked_user where linked_social_app = \"%s\" AND identifier = %s",$social_app_name,$social_user_id));
|
1728 |
|
1729 |
$email_user_id = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->users where user_email = \"%s\"", $email));
|
1734 |
if((isset($id_returning_user)) || (isset($email_user_id))){
|
1735 |
if ((!isset($id_returning_user)) && (isset($email_user_id)) ){
|
1736 |
$id_returning_user = $email_user_id;
|
1737 |
+
mo_openid_insert_query($social_app_name,$email,$id_returning_user,$social_user_id);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1738 |
}
|
1739 |
$user = get_user_by('id', $id_returning_user );
|
1740 |
if(get_option('moopenid_social_login_avatar') && isset($user_picture))
|
1751 |
}
|
1752 |
// if new user and profile completion is enabled
|
1753 |
elseif (get_option('mo_openid_enable_profile_completion')){
|
1754 |
+
echo mo_openid_profile_completion_form($last_name, $first_name, $user_full_name, $user_url, $user_picture, $user_name, $email, $social_app_name, $social_user_id);
|
|
|
|
|
|
|
1755 |
exit;
|
1756 |
}
|
1757 |
// if new user and profile completion is disabled, auto create dummy data and register user
|
1790 |
$_SESSION['user_picture'] = $user_picture;
|
1791 |
$_SESSION['social_app_name'] = $social_app_name;
|
1792 |
$_SESSION['social_user_id'] = $social_user_id;
|
1793 |
+
echo mo_openid_account_linking_form();
|
|
|
|
|
|
|
1794 |
exit;
|
1795 |
}
|
1796 |
|
1798 |
|
1799 |
$user_profile_url = $user_url;
|
1800 |
|
1801 |
+
if(isset($social_app_name) && !empty($social_app_name) && $social_app_name=='facebook'){
|
1802 |
$user_url = '';
|
1803 |
}
|
1804 |
|
1846 |
//email and username are both returned..dont show profile completion
|
1847 |
else{
|
1848 |
global $wpdb;
|
|
|
1849 |
$user_email = sanitize_email($email);
|
1850 |
$username = strtolower(str_replace(" ","",$user_name));
|
1851 |
|
1862 |
mo_openid_start_session();
|
1863 |
if((isset($linked_email_id)) || (isset($email_user_id)) || (isset($existing_email_user_id)) ) { // user is a member
|
1864 |
if ((!isset($linked_email_id)) && (isset($email_user_id)) ){
|
|
|
1865 |
|
1866 |
+
$linked_email_id = $email_user_id;
|
1867 |
+
mo_openid_insert_query($social_app_name,$user_email,$linked_email_id,$social_user_id);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1868 |
}
|
1869 |
|
1870 |
if(isset($linked_email_id)){
|
1903 |
$_SESSION['user_picture'] = $user_picture;
|
1904 |
$_SESSION['social_app_name'] = $social_app_name;
|
1905 |
$_SESSION['social_user_id'] = $social_user_id;
|
1906 |
+
echo mo_openid_account_linking_form();
|
|
|
|
|
|
|
1907 |
exit;
|
1908 |
}
|
1909 |
else {
|
1913 |
$random_password = wp_generate_password( 10, false );
|
1914 |
|
1915 |
if( isset($username_user_id) ){
|
|
|
1916 |
$email_array = explode('@', $user_email);
|
1917 |
$username = $email_array[0];
|
1918 |
$username_user_id = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->users where user_login = %s", $username));
|
1924 |
|
1925 |
$user_profile_url = $user_url;
|
1926 |
|
1927 |
+
if(isset($social_app_name) && !empty($social_app_name) && $social_app_name=='facebook'){
|
1928 |
$user_url = '';
|
1929 |
}
|
1930 |
|
1939 |
);
|
1940 |
|
1941 |
$user_id = wp_insert_user( $userdata);
|
|
|
1942 |
if(is_wp_error( $user_id )) {
|
1943 |
//print_r($user_id);
|
1944 |
wp_die('There was an error in registration. Please contact your administrator.');
|
1977 |
}
|
1978 |
}
|
1979 |
|
1980 |
+
function mo_openid_validate_otp_form($username, $user_email, $transaction_id, $user_picture, $user_url, $last_name, $user_full_name ,$first_name, $decrypted_app_name, $decrypted_user_id){
|
1981 |
+
$path = mo_openid_get_wp_style();
|
1982 |
$html = '<head><link rel="stylesheet" href='.$path.' type="text/css" media="all" /></head>
|
1983 |
|
1984 |
<body class="login login-action-login wp-core-ui locale-en-us">
|
2044 |
return $html;
|
2045 |
}
|
2046 |
|
2047 |
+
function mo_openid_username_already_exists($last_name,$first_name,$user_full_name,$user_url,$user_picture,$username,$user_email, $decrypted_app_name, $decrypted_user_id){
|
2048 |
+
$path = mo_openid_get_wp_style();
|
2049 |
$html = '<style>.form-input-validation.is-error {color: #d94f4f;}</style><head><link rel="stylesheet" href='.$path.' type="text/css" media="all" /></head>
|
2050 |
|
2051 |
<body class="login login-action-login wp-core-ui locale-en-us">
|
2092 |
|
2093 |
}
|
2094 |
|
2095 |
+
function mo_openid_profile_completion_form($last_name,$first_name,$user_full_name,$user_url,$user_picture, $decrypted_user_name, $decrypted_email, $decrypted_app_name, $decrypted_user_id){
|
2096 |
+
$path = mo_openid_get_wp_style();
|
2097 |
$html = '<style>.form-input-validation.note {color: #d94f4f;}</style>
|
2098 |
<head><link rel="stylesheet" href='.$path.' type="text/css" media="all" /></head>
|
2099 |
<body class="login login-action-login wp-core-ui locale-en-us">
|
2140 |
return $html;
|
2141 |
}
|
2142 |
|
2143 |
+
function mo_openid_invalid_otp_form($first_name, $last_name, $user_full_name, $user_url, $user_picture, $decrypted_app_name, $decrypted_user_id, $username,$user_email, $transaction_id){
|
2144 |
+
$path = mo_openid_get_wp_style();
|
2145 |
$html = '<style>.form-input-validation.is-error {color: #d94f4f;}</style>
|
2146 |
<head><link rel="stylesheet" href='.$path.' type="text/css" media="all" /></head>
|
2147 |
|
2187 |
return $html;
|
2188 |
}
|
2189 |
|
2190 |
+
function mo_openid_account_linking_form(){
|
2191 |
+
$path = mo_openid_get_wp_style();
|
2192 |
$html = "<head><link rel=\"stylesheet\" href=".$path. " type='text/css' media='all' /><head>
|
2193 |
<body class='login login-action-login wp-core-ui locale-en-us'>
|
2194 |
<div style=\"position:fixed;background:#f1f1f1;\"></div>
|
2238 |
}
|
2239 |
|
2240 |
function mo_openid_link_account( $username, $user ){
|
2241 |
+
|
2242 |
if($user){
|
2243 |
$userid = $user->ID;
|
2244 |
}
|
|
|
|
|
|
|
2245 |
mo_openid_start_session();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2246 |
|
2247 |
$user_email = isset($_SESSION['user_email']) ? $_SESSION['user_email']:'';
|
2248 |
$social_app_identifier = isset($_SESSION['social_user_id']) ? $_SESSION['social_user_id']:'';
|
2249 |
$social_app_name = isset($_SESSION['social_app_name']) ? $_SESSION['social_app_name']:'';
|
2250 |
+
|
2251 |
+
//if user is coming through default wordpress login, do not proceed further and return
|
2252 |
+
if(isset($userid) && empty($social_app_identifier) && empty($social_app_name) ) {
|
2253 |
+
return;
|
2254 |
+
}
|
2255 |
+
elseif(!isset($userid)){
|
2256 |
+
wp_die('No user is returned.');
|
2257 |
+
}
|
2258 |
|
2259 |
global $wpdb;
|
|
|
2260 |
$db_prefix = $wpdb->prefix;
|
2261 |
+
$linked_email_id = $wpdb->get_var($wpdb->prepare("SELECT user_id FROM ".$db_prefix."mo_openid_linked_user where linked_email = \"%s\" AND linked_social_app = \"%s\"",$user_email,$social_app_name));
|
2262 |
|
2263 |
+
// if a user with given email and social app name doesn't already exist in the mo_openid_linked_user table
|
2264 |
+
if(!isset($linked_email_id) && !empty($user_email)){
|
2265 |
+
mo_openid_insert_query($social_app_name,$user_email,$userid,$social_app_identifier);
|
2266 |
+
}
|
2267 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2268 |
|
2269 |
+
function mo_openid_insert_query($social_app_name,$user_email,$userid,$social_app_identifier){
|
2270 |
+
global $wpdb;
|
2271 |
+
$db_prefix = $wpdb->prefix;
|
2272 |
+
$table_name = $db_prefix. 'mo_openid_linked_user';
|
2273 |
+
|
2274 |
+
$result = $wpdb->insert(
|
2275 |
+
$table_name,
|
2276 |
+
array(
|
2277 |
+
'linked_social_app' => $social_app_name,
|
2278 |
+
'linked_email' => $user_email,
|
2279 |
+
'user_id' => $userid,
|
2280 |
+
'identifier' => $social_app_identifier
|
2281 |
+
),
|
2282 |
+
array(
|
2283 |
+
'%s',
|
2284 |
+
'%s',
|
2285 |
+
'%d',
|
2286 |
+
'%s'
|
2287 |
+
)
|
2288 |
+
);
|
2289 |
+
if($result === false){
|
2290 |
+
/*$wpdb->show_errors();
|
2291 |
+
$wpdb->print_error();
|
2292 |
+
exit;*/
|
2293 |
+
wp_die('Error in insert query');
|
2294 |
}
|
2295 |
}
|
2296 |
|
2539 |
}
|
2540 |
}
|
2541 |
|
2542 |
+
function mo_openid_get_wp_style(){
|
2543 |
+
$path = site_url();
|
2544 |
+
$path .= '/wp-admin/load-styles.php?c=1&dir=ltr&load%5B%5D=dashicons,buttons,forms,l10n,login&ver=4.8.1';
|
2545 |
+
return $path;
|
2546 |
+
}
|
2547 |
+
|
2548 |
if(get_option('mo_openid_logout_redirection_enable') == 1){
|
2549 |
add_filter( 'logout_url', 'mo_openid_redirect_after_logout',0,1);
|
2550 |
}
|
2555 |
|
2556 |
add_action( 'init', 'mo_openid_login_validate' );
|
2557 |
//add_action( 'init', 'mo_openid_start_session' );
|
2558 |
+
add_action( 'wp_logout', 'mo_openid_end_session',1 );
|
2559 |
add_action( 'mo_user_register', 'mo_openid_update_role', 1, 2);
|
2560 |
add_action( 'wp_login', 'mo_openid_login_redirect', 10, 2);
|
2561 |
add_action( 'wp_login', 'mo_openid_link_account', 9, 2);
|
miniorange_openid_sso_settings.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
* Plugin Name: Social Login, Social Sharing by miniOrange
|
5 |
* Plugin URI: https://www.miniorange.com
|
6 |
* Description: Allow your users to login, comment and share with Facebook, Google, Twitter, LinkedIn etc using customizable buttons.
|
7 |
-
* Version: 6.
|
8 |
* Author: miniOrange
|
9 |
* Author URI: https://www.miniorange.com
|
10 |
* License: GPL2
|
4 |
* Plugin Name: Social Login, Social Sharing by miniOrange
|
5 |
* Plugin URI: https://www.miniorange.com
|
6 |
* Description: Allow your users to login, comment and share with Facebook, Google, Twitter, LinkedIn etc using customizable buttons.
|
7 |
+
* Version: 6.5.0
|
8 |
* Author: miniOrange
|
9 |
* Author URI: https://www.miniorange.com
|
10 |
* License: GPL2
|
miniorange_openid_sso_settings_page.php
CHANGED
@@ -3263,7 +3263,7 @@ function mo_openid_custom_app_config(){?>
|
|
3263 |
}
|
3264 |
else if(get_option('mo_openid_apps_list')){
|
3265 |
$appslist = get_option('mo_openid_apps_list');
|
3266 |
-
echo "<br><
|
3267 |
echo "<h3>Applications List</h3>";
|
3268 |
echo "<table class='tableborder'>";
|
3269 |
echo "<tr><th><b>Name</b></th><th>Action</th></tr>";
|
@@ -3281,7 +3281,7 @@ function mo_openid_custom_app_config(){?>
|
|
3281 |
echo "<p><u>Please Note :</u><br>Once an application is configured here, it will override the default app miniOrange uses.
|
3282 |
Please add an application here only if you don't want to use the default miniOrange application. <br>
|
3283 |
</p></div>";
|
3284 |
-
echo "<br><
|
3285 |
echo "<br><br><br><br><br><br><br>";
|
3286 |
|
3287 |
}?>
|
3263 |
}
|
3264 |
else if(get_option('mo_openid_apps_list')){
|
3265 |
$appslist = get_option('mo_openid_apps_list');
|
3266 |
+
echo "<br><input onclick='window.location.href=\"admin.php?page=mo_openid_settings&tab=custom_app&action=add\"' type='button' class='button button-primary button-large' style='float:right;text-align:center;' value='Add Application'>";
|
3267 |
echo "<h3>Applications List</h3>";
|
3268 |
echo "<table class='tableborder'>";
|
3269 |
echo "<tr><th><b>Name</b></th><th>Action</th></tr>";
|
3281 |
echo "<p><u>Please Note :</u><br>Once an application is configured here, it will override the default app miniOrange uses.
|
3282 |
Please add an application here only if you don't want to use the default miniOrange application. <br>
|
3283 |
</p></div>";
|
3284 |
+
echo "<br><input type='button' onclick='window.location.href=\"admin.php?page=mo_openid_settings&tab=custom_app&action=add\"' class='button button-primary button-large' style='margin-left:300px;text-align:center;' value='Add Application'>";
|
3285 |
echo "<br><br><br><br><br><br><br>";
|
3286 |
|
3287 |
}?>
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Donate link: https://www.miniorange.com
|
|
4 |
Tags: social login, social, facebook, twitter, login
|
5 |
Requires at least: 2.0.2
|
6 |
Tested up to: 4.9.4
|
7 |
-
Stable tag: 6.
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -165,6 +165,13 @@ Please email us at info@miniorange.com. You can also submit your query from the
|
|
165 |
|
166 |
|
167 |
== Changelog ==
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
168 |
= 6.4.1 =
|
169 |
* Fix for issue in sending OTP during registration
|
170 |
|
@@ -496,6 +503,13 @@ Please email us at info@miniorange.com. You can also submit your query from the
|
|
496 |
* First version of Social Login, Social Sharing plugin.
|
497 |
|
498 |
== Upgrade Notice ==
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
499 |
= 6.4.1 =
|
500 |
* Fix for issue in sending OTP during registration
|
501 |
|
4 |
Tags: social login, social, facebook, twitter, login
|
5 |
Requires at least: 2.0.2
|
6 |
Tested up to: 4.9.4
|
7 |
+
Stable tag: 6.5.0
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
165 |
|
166 |
|
167 |
== Changelog ==
|
168 |
+
= 6.5.0 =
|
169 |
+
* Fix for issue during WP default login (unset session variables on logout)
|
170 |
+
* Fix for issue during Facebook login (used correct variable names)
|
171 |
+
* Fix for empty email insertion in account linking table (added empty email check before insertion)
|
172 |
+
* Fixed 'Add Application' button UI
|
173 |
+
* Code cleanup
|
174 |
+
|
175 |
= 6.4.1 =
|
176 |
* Fix for issue in sending OTP during registration
|
177 |
|
503 |
* First version of Social Login, Social Sharing plugin.
|
504 |
|
505 |
== Upgrade Notice ==
|
506 |
+
= 6.5.0 =
|
507 |
+
* Fix for issue during WP default login (unset session variables on logout)
|
508 |
+
* Fix for issue during Facebook login (used correct variable names)
|
509 |
+
* Fix for empty email insertion in account linking table (added empty email check before insertion)
|
510 |
+
* Fixed 'Add Application' button UI
|
511 |
+
* Code cleanup
|
512 |
+
|
513 |
= 6.4.1 =
|
514 |
* Fix for issue in sending OTP during registration
|
515 |
|