Skip to content
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 implicit wf in subdirectories, added custom JS #72

Merged
merged 1 commit into from
May 28, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ Single Sign On for Enterprises + Social Login + User/Passwords. For all your Wor

Demo: <http://auth0wp.azurewebsites.net>

Documentation: <https://auth0.com/docs/cms>

## Installation

Before you start, **make sure the admin user has a valid email that you own**, read the Technical Notes for more information.
Expand Down
7 changes: 5 additions & 2 deletions WP_Auth0.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
* Plugin Name: Wordpress Auth0 Integration
* Description: Implements the Auth0 Single Sign On solution into Wordpress
* Version: 1.2.6
* Version: 1.2.7
* Author: Auth0
* Author URI: https://auth0.com
*/
Expand All @@ -12,7 +12,7 @@
define('WPA0_PLUGIN_URL', trailingslashit(plugin_dir_url(__FILE__) ));
define('WPA0_LANG', 'wp-auth0');
define('AUTH0_DB_VERSION', 2);
define('WPA0_VERSION', '1.2.6');
define('WPA0_VERSION', '1.2.7');

class WP_Auth0 {
public static function init(){
Expand Down Expand Up @@ -265,6 +265,9 @@ public static function buildSettings($settings)
if (self::IsValid($settings,'custom_css')) {
$options_obj['custom_css'] = $settings['custom_css'];
}
if (self::IsValid($settings,'custom_js')) {
$options_obj['custom_js'] = $settings['custom_js'];
}
if (self::IsValid($settings,'social_big_buttons')) {
$options_obj['socialBigButtons'] = self::GetBoolean($settings['social_big_buttons']);
}
Expand Down
7 changes: 7 additions & 0 deletions lib/WP_Auth0_Admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ public static function init_admin(){
array('id' => 'wpa0_default_login_redirection', 'name' => 'Login redirection URL', 'function' => 'render_default_login_redirection'),
array('id' => 'wpa0_verified_email', 'name' => 'Requires verified email', 'function' => 'render_verified_email'),
array('id' => 'wpa0_allow_signup', 'name' => 'Allow signup', 'function' => 'render_allow_signup'),
array('id' => 'wpa0_custom_js', 'name' => 'Customize the Login Widget with custom JS', 'function' => 'render_custom_js'),
//array('id' => 'wpa0_auto_provisioning', 'name' => 'Auto Provisioning', 'function' => 'render_auto_provisioning'),
array('id' => 'wpa0_auth0_implicit_workflow', 'name' => 'Auth0 Implicit flow', 'function' => 'render_auth0_implicit_workflow'),
array('id' => 'wpa0_auto_login', 'name' => 'Auto Login (no widget)', 'function' => 'render_auto_login'),
Expand Down Expand Up @@ -169,6 +170,12 @@ public static function render_custom_css(){
echo '<br/><span class="description">' . __('This should be a valid CSS to customize the Auth0 login widget. ', WPA0_LANG) . '<a target="_blank" href="https://github.com/auth0/wp-auth0#can-i-customize-the-login-widget">' . __('More info', WPA0_LANG) . '</a></span>';
}

public static function render_custom_js(){
$v = WP_Auth0_Options::get( 'custom_js' );
echo '<textarea name="' . WP_Auth0_Options::OPTIONS_NAME . '[custom_js]" id="wpa0_custom_js">' . esc_attr( $v ) . '</textarea>';
echo '<br/><span class="description">' . __('This should be a valid JS to customize the Auth0 login widget to, for example, add custom buttons. ', WPA0_LANG) . '<a target="_blank" href="https://auth0.com/docs/hrd#3">' . __('More info', WPA0_LANG) . '</a></span>';
}

public static function render_username_style(){
$v = WP_Auth0_Options::get( 'username_style' );
echo '<input type="radio" name="' . WP_Auth0_Options::OPTIONS_NAME . '[username_style]" id="wpa0_username_style_email" value="email" ' . (esc_attr( $v ) == 'email' ? 'checked="true"' : '') . '"/>';
Expand Down
1 change: 1 addition & 0 deletions lib/WP_Auth0_Options.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ private static function defaults(){
'extra_conf' => '',
'remember_last_login' => true,
'custom_css' => '',
'custom_js' => '',
'auth0_implicit_workflow' => false,
'gravatar' => true,
'jwt_auth_integration' => false,
Expand Down
5 changes: 5 additions & 0 deletions templates/a0-widget-setup-form.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
$extra_conf = isset($instance[ 'extra_conf' ]) ? $instance[ 'extra_conf' ] : '';
$remember_last_login = isset($instance[ 'remember_last_login' ]) ? $instance[ 'remember_last_login' ] : '';
$custom_css = isset($instance[ 'custom_css' ]) ? $instance[ 'custom_css' ] : '';
$custom_js = isset($instance[ 'custom_js' ]) ? $instance[ 'custom_js' ] : '';

?>

Expand Down Expand Up @@ -140,6 +141,10 @@ class="button-secondary"><?php echo _e( 'Choose Icon' ); ?></a>
name="<?php echo $this->get_field_name( 'custom_css' ); ?>">
<?php echo esc_attr( $custom_css ); ?>
</textarea>
<textarea class="widefat" id="<?php echo $this->get_field_id( 'custom_js' ); ?>"
name="<?php echo $this->get_field_name( 'custom_js' ); ?>">
<?php echo esc_attr( $custom_js ); ?>
</textarea>
<br/><span class="description">
<?php echo __('This should be a valid CSS to customize the Auth0 login widget.', WPA0_LANG); ?>
<a target="_blank" href="https://github.com/auth0/wp-auth0#can-i-customize-the-login-widget"><?php echo __('More info', WPA0_LANG); ?></a>
Expand Down
8 changes: 7 additions & 1 deletion templates/auth0-login-form.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@

callback = function(err,profile, token) {

post('/index.php?auth0=implicit', {
post(<?php echo site_url('/index.php?auth0=implicit'); ?>, {
token:token,
state:'<?php echo $state; ?>'
}, 'POST');
Expand All @@ -130,6 +130,12 @@

var lock = new Auth0Lock('<?php echo $client_id; ?>', '<?php echo $domain; ?>');

<?php if(isset($options_obj['custom_js'])) { ?>

<?php echo $options_obj['custom_js'];?>

<?php } ?>

function a0ShowLoginModal() {
var options = <?php echo $options; ?>;

Expand Down