-
Notifications
You must be signed in to change notification settings - Fork 96
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix user profile saving #573
Conversation
} | ||
|
||
return false; | ||
return $profile ? WP_Auth0_Serializer::unserialize( $profile ) : false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Simplifying the return here.
|
||
$currentauth0_user = get_auth0userinfo( $current_user->ID ); | ||
|
||
$currentauth0_user = get_auth0userinfo( get_current_user_id() ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just need the ID here so switched to get_current_user_id()
.
$data->auth0_id = WP_Auth0_UsersRepo::get_meta( $current_user->ID, 'auth0_id' ); | ||
|
||
return $data; | ||
return (object) array( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Type juggling to simplify object creation.
|
||
return $data; | ||
return (object) array( | ||
'auth0_obj' => get_auth0userinfo( get_current_user_id() ), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just need the ID here so switched to get_current_user_id()
.
Also changed object get to get_auth0userinfo()
so all these functions pass through a single one (was also doing the same job here).
public function update_auth0_object( $user_id, $userinfo ) { | ||
global $wpdb; | ||
update_user_meta( $user_id, $wpdb->prefix . 'auth0_id', ( isset( $userinfo->user_id ) ? $userinfo->user_id : $userinfo->sub ) ); | ||
update_user_meta( $user_id, $wpdb->prefix . 'auth0_obj', WP_Auth0_Serializer::serialize( $userinfo ) ); | ||
$auth0_user_id = isset( $userinfo->user_id ) ? $userinfo->user_id : $userinfo->sub; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Simplify auth0_user_id
setting.
$auth0_user_id = isset( $userinfo->user_id ) ? $userinfo->user_id : $userinfo->sub; | ||
update_user_meta( $user_id, $wpdb->prefix . 'auth0_id', $auth0_user_id ); | ||
$userinfo_encoded = WP_Auth0_Serializer::serialize( $userinfo ); | ||
$userinfo_encoded = wp_slash( $userinfo_encoded ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actual fix mentioned in the Changes section of the description.
@@ -0,0 +1,87 @@ | |||
<?php |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No called anywhere, just a helper for creating new tests.
7fd479b
to
4ba4b26
Compare
$userinfo = $this->getUserinfo(); | ||
|
||
// Specially-encoded characters: ¥ £ € ¢ ₡ ₢ ₣ ₤ ₥ ₦ ₪ ₯ | ||
$userinfo->encodedValue1 = '\u00a5 \u00a3 \u20ac \u00a2 \u20a1 \u20a2 \u20a3 \u20a4 \u20a5 \u20a6 \u20aa \u20af'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actual problematic data here. Others before are just to confirm that things are stored and retrieved as expected.
852663a
to
7f818d5
Compare
7f818d5
to
427ccf0
Compare
Codecov Report
@@ Coverage Diff @@
## master #573 +/- ##
============================================
+ Coverage 21.15% 21.27% +0.11%
Complexity 1313 1313
============================================
Files 51 51
Lines 4282 4278 -4
============================================
+ Hits 906 910 +4
+ Misses 3376 3368 -8
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some nice clean up
Changes
wp_slash()
processing before saving the user profile from Auth0WP_Auth0.php
tests/suiteTemplate.php
References
Testing
Tests were added before changes to confirm all current behavior as well as broken behavior.
Checklist