Skip to content

Commit

Permalink
fix: fixed key name and if cond
Browse files Browse the repository at this point in the history
  • Loading branch information
affrncsp committed Apr 23, 2024
1 parent bf7ee70 commit 15c80ac
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions includes/wp-affinidi-login-callback.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@
$user_id = null;

if (email_exists($userInfo['email']) == false) {
if (affinidi_login_users_can_signup() == 0) {
if (affinidi_login_users_can_signup()) {
wp_safe_redirect(add_query_arg(array('message' => 'affinidi_login_only'), esc_url($user_redirect)));
exit;
}
Expand All @@ -149,7 +149,7 @@
$random_password = wp_generate_password($length = 16, $extra_special_chars = true);
$user_data = [
'user_email' => $userInfo['email'],
'user_login' => (!empty($userInfo['first_name']) ? $userInfo['first_name'] : $userInfo['email']), // default to mail if not present
'user_login' => $userInfo['email'], // default to mail
'user_pass' => $random_password,
'last_name' => $userInfo['last_name'],
'first_name' => $userInfo['first_name'],
Expand Down Expand Up @@ -184,11 +184,10 @@
* we should check the user by email. This may be the case when the users are preregistered outside of OAuth
*/
if (!$user) {
// Get the user by name
$user = get_user_by('login', $userInfo['given_name']);
// Get the user by email using login
$user = get_user_by('login', $userInfo['email']);
}


if (!$user) {
// redirect user with error code
wp_safe_redirect(add_query_arg(array('message' => 'affinidi_login_failed'), esc_url($user_redirect)));
Expand Down

0 comments on commit 15c80ac

Please sign in to comment.