-
Notifications
You must be signed in to change notification settings - Fork 92
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
A0 widget #16
A0 widget #16
Changes from 32 commits
2f616bc
e5867b5
21d10b6
b5a36ec
dd2c202
9c5ff93
e49b940
8af498e
b823c8d
49a7b54
68e09ae
479c34c
9973cbc
cc89ecb
345cc9d
58d1bf6
2bae772
8349e67
d088c60
a2a362d
0d0c582
84f5d09
30facef
f9c6784
3a39a9f
2c62c15
347dc53
b2b5275
7529736
f975bfc
a3b8157
594a97d
1544fc8
106a829
607c4ae
41434d5
f53f4b5
7b683e5
7cdd8e5
2a77e29
362f6a9
a48ce05
e35b5b3
d4ea519
bfa0c97
3147493
d10006c
2e57d26
ac6159f
75ebd3d
36640dd
d6f6be9
fcc4a42
fa7c512
8d4e4cb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,6 +34,44 @@ For both scenarios you may configure in the WP admin whether is mandatory that t | |
|
||
You can access the rich user profile information coming from the Identity Providers. **WordPress** defines a function called `get_currentuserinfo` to populate the global variable `current_user` with the logged in `WP_User`. Similary we define `get_currentauth0userinfo` that populates `current_user` and `currentauth0_user` with the information of the Normalized profile. | ||
|
||
### Enabling dual (Auth0 and Wordpress) login | ||
|
||
You can enable the standard Wordpress login by turning on the "WordPress login enabled" setting (enabled by default). This will make visible a link on the login page to swap between both. | ||
|
||
### Using the plugin widget | ||
|
||
You can enable the Auth0 as a Wordpress widget in order to show it in the sidebar. The widget inherits the plugin settings and it can be overrided with its own settings. | ||
|
||
Also, a new layout setting is enabled in order to be shown as a modal. Enabling the "Show as modal" setting, a button which trigger the modal is generated. | ||
|
||
### Using the login widget as a shortcode | ||
|
||
Also, you can use the Auth0 widget as a shortcode in your posts. | ||
|
||
The way to use it is just adding the following: | ||
|
||
[auth0] | ||
|
||
And can be customized by adding the following parameters: | ||
|
||
* form_title: string | ||
* dict: string, should be a the language or a valid json with the translation (see https://github.com/auth0/lock/wiki/Auth0Lock-customization#dict-stringobject) | ||
* social_big_buttons: boolean | ||
* gravatar: boolean | ||
* username_style: string, "email" or "username" | ||
* remember_last_login: boolean | ||
* icon_url: string (valid url) | ||
* extra_conf: string, valid json | ||
* show_as_modal: boolean | ||
* modal_trigger_name: string, button text | ||
|
||
Example: | ||
|
||
[auth0 show_as_modal="true" social_big_buttons="true" modal_trigger_name="Login button: This text is configurable!"] | ||
|
||
|
||
All the details about the parameters on the lock wiki (https://github.com/auth0/lock/wiki/Auth0Lock-customization#dict-stringobject) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Link to the main wiki instead of |
||
|
||
## FAQs | ||
|
||
### What should I do if I end up with two accounts for the same user? | ||
|
@@ -66,6 +104,24 @@ For a complete list look at https://docs.auth0.com/identityproviders | |
|
||
If you get this error, make sure you are requesting the Email attribute from each provider in the Auth0 Dashboard under Connections -> Social (expand each provider). Take into account that not all providers return Email addresses for users (e.g. Twitter). If this happens, you can always add an Email address to any logged in user through the Auth0 Dashbaord (pr API). See Users -> Edit. | ||
|
||
### The form_title setting is ignored when I set up the dict setting | ||
|
||
Internally, the plugin uses the dict setting to change the Auth0 widget title. When you set up the dict field it overrides the form_title one. | ||
|
||
To change the form_title in this case, you need to add the following attribute to the dict json: | ||
|
||
{ | ||
signin:{ | ||
title: "The desired form title" | ||
} | ||
} | ||
|
||
### How can I set up the settings that are not provided in the settings page? | ||
|
||
We added a new field called "Extra settings" that allows you to add a json object with all the settings you want to configure. | ||
|
||
Have in mind that all the "Extra settings" that we allow to set up in the plugin settings page will be overrided. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Link here to Lock customization wiki as well |
||
|
||
## Screenshots | ||
|
||
![](https://raw.githubusercontent.com/auth0/wp-auth0/master/screenshot-1.png) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
/** | ||
* Plugin Name: Wordpress Auth0 Integration | ||
* Description: Implements the Auth0 Single Sign On solution into Wordpress | ||
* Version: 1.0.8 | ||
* Version: 1.1.0 | ||
* Author: Auth0 | ||
* Author URI: https://auth0.com | ||
*/ | ||
|
@@ -61,6 +61,7 @@ public static function wp_register_widget() { | |
|
||
public static function wp_enqueue(){ | ||
$activated = absint(WP_Auth0_Options::get( 'active' )); | ||
|
||
if(!$activated) { | ||
return; | ||
} | ||
|
@@ -69,10 +70,15 @@ public static function wp_enqueue(){ | |
} | ||
|
||
public static function shortcode( $atts ){ | ||
|
||
$settings = WP_Auth0::buildSettings($atts); | ||
$settings[ 'show_as_modal' ] = (isset($atts[ 'show_as_modal' ]) && strtolower($atts[ 'show_as_modal' ]) == 'true' ? 1 : false); | ||
$settings[ 'modal_trigger_name' ] = (isset($atts[ 'modal_trigger_name' ]) ? $atts[ 'modal_trigger_name' ] : 'Login'); | ||
|
||
ob_start(); | ||
|
||
require_once WPA0_PLUGIN_DIR . 'templates/login-form.php'; | ||
renderAuth0Form(false); | ||
renderAuth0Form(false, $settings); | ||
|
||
$html = ob_get_clean(); | ||
return $html; | ||
|
@@ -116,12 +122,79 @@ public static function render_back_to_auth0() { | |
|
||
} | ||
|
||
public static function render_auth0_login_css() { ?> | ||
protected static function GetBoolean($value) | ||
{ | ||
return ($value == 1 || strtolower($value) == 'true'); | ||
} | ||
|
||
protected static function IsValid($array, $key) | ||
{ | ||
return (isset($array[$key]) && trim($array[$key]) != ''); | ||
} | ||
|
||
public static function buildSettings($settings) | ||
{ | ||
$options_obj = array(); | ||
|
||
if (isset($settings['form_title']) && | ||
(!isset($settings['dict']) || (isset($settings['dict']) && trim($settings['dict']) == '')) && | ||
trim($settings['form_title']) != '') { | ||
$options_obj['dict'] = array( | ||
"signin" => array( | ||
"title" => $settings['form_title'] | ||
) | ||
); | ||
} | ||
elseif (isset($settings['dict']) && trim($settings['dict']) != '') { | ||
if ($oDict = json_decode($settings['dict'], true)) { | ||
$options_obj['dict'] = $oDict; | ||
} | ||
else{ | ||
$options_obj['dict'] = $settings['dict']; | ||
} | ||
} | ||
|
||
if (self::IsValid($settings,'social_big_buttons')) { | ||
$options_obj['socialBigButtons'] = self::GetBoolean($settings['social_big_buttons']); | ||
} | ||
if (self::IsValid($settings,'gravatar')) { | ||
$options_obj['gravatar'] = self::GetBoolean($settings['gravatar']); | ||
} | ||
|
||
if (self::IsValid($settings,'username_style')) { | ||
$options_obj['usernameStyle'] = $settings['username_style']; | ||
} | ||
|
||
if (self::IsValid($settings,'remember_last_login')) { | ||
$options_obj['rememberLastLogin'] = self::GetBoolean($settings['remember_last_login']); | ||
} | ||
|
||
if (self::IsValid($settings,'show_icon') && isset($settings['icon_url'])) { | ||
$options_obj['icon'] = self::GetBoolean($settings['show_icon']) ? $settings['icon_url'] : ''; | ||
} | ||
|
||
if (isset($settings['extra_conf']) && trim($settings['extra_conf']) != '') { | ||
$extra_conf_arr = json_decode($settings['extra_conf'], true); | ||
$options_obj = array_merge( $extra_conf_arr, $options_obj ); | ||
} | ||
|
||
return $options_obj; | ||
|
||
} | ||
|
||
public static function render_auth0_login_css() { | ||
$activated = absint(WP_Auth0_Options::get( 'active' )); | ||
|
||
if(!$activated) { | ||
return; | ||
} | ||
?> | ||
<link rel='stylesheet' href='<?php echo plugins_url( 'assets/css/login.css', __FILE__ ); ?>' type='text/css' /> | ||
<?php } | ||
<?php | ||
} | ||
|
||
public static function render_form( $html ){ | ||
$activated = absint(WP_Auth0_Options::get( 'active' )); | ||
$activated = absint(WP_Auth0_Options::get( 'active' )) == 1; | ||
|
||
if(!$activated) | ||
return $html; | ||
|
@@ -357,11 +430,10 @@ public static function wp_init(){ | |
self::setup_rewrites(); | ||
|
||
$cdn_url = WP_Auth0_Options::get('cdn_url'); | ||
|
||
if (strpos($cdn_url, 'w2/auth0-widget') !== false) | ||
if (strpos($cdn_url, 'auth0-widget-5') !== false) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How will we be able to update Lock version as well in every future WP update if we want? Something like this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is to upgrade from auth0-widget-5 to lock. Right now, it is tied to lock-6.min.js and will be updated until the next major release. If we want to force the update, I added an internal version counter (other than the AUTH0_DB_VERSION) to manage the settings updates. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Great! Martin Gontovnikas Twitter: @mgonto (https://twitter.com/mgonto) On Monday, 6 de October de 2014 at 11:49, Germán Lena wrote:
|
||
{ | ||
WP_Auth0_Options::set( 'cdn_url', '//cdn.auth0.com/js/lock-6.min.js' ); | ||
WP_Auth0_Options::set( 'version', 1 ); | ||
//WP_Auth0_Options::set( 'version', 1 ); | ||
} | ||
|
||
// Initialize session | ||
|
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.
Can you put a picture of how to active Auth0 Widget and where you see the configs?