Skip to content
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
20 changes: 16 additions & 4 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.0.0
* Version: 1.0.1
* Author: 1337 ApS
* Author URI: http://1337.dk
*/
Expand Down Expand Up @@ -249,6 +249,8 @@ private static function dieWithVerifyEmail($userinfo, $data) {
$domain = WP_Auth0_Options::get( 'domain' );
$token = $data->id_token;
$email = $userinfo->email;
$connection = $userinfo->identities[0]->connection;
$userId = $userinfo->user_id;
include WPA0_PLUGIN_DIR . 'templates/verify-email.php';

$html = ob_get_clean();
Expand All @@ -257,10 +259,20 @@ private static function dieWithVerifyEmail($userinfo, $data) {

}
private static function login_user( $userinfo, $data ){
// If the userinfo has an unverified email, and in the options we require a verified email
// If the userinfo has no email or an unverified email, and in the options we require a verified email
// notify the user he cant login until he does so.
if (!$userinfo->email_verified && WP_Auth0_Options::get( 'requires_verified_email' )) {
self::dieWithVerifyEmail($userinfo, $data);
if (WP_Auth0_Options::get( 'requires_verified_email' )){
if (empty($userinfo->email)) {
$msg = __('This account does not have an email associated. Please login with a different provider.', WPA0_LANG);
$msg .= '<br/><br/>';
$msg .= '<a href="' . site_url() . '">' . __('← Go back', WPA0_LANG) . '</a>';

wp_die($msg);
}
if (!$userinfo->email_verified) {
self::dieWithVerifyEmail($userinfo, $data);
}

}

// See if there is a user in the auth0_user table with the user info client id
Expand Down
8 changes: 8 additions & 0 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@ Before you start, make sure the admin user has a valid email that you own, read
1. In `settings` - `Auth0 Settings` edit the *Domain*, *Client ID* and *Client Secret* from your auth0 dashboard
1. Go to your auth0 dashboard, edit your application and add this to the available callbacks http://<your-domain>/index.php?auth0=1

== Screenshots ==

1. The new login page
2. The admin to configure the plugin
3. Auth0 admin to create a new Application
4. You can enable or disable social plugins
5. This is what happens if you are in the admin and your session expires
6. You can configure enterprise connections

== Technical Notes ==

Expand Down
Binary file added screenshot-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added screenshot-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added screenshot-3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added screenshot-4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added screenshot-5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added screenshot-6.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
38 changes: 21 additions & 17 deletions templates/verify-email.php
Original file line number Diff line number Diff line change
@@ -1,28 +1,32 @@
<?php echo __('Please verify your email and log in again.', WPA0_LANG);?>
<a id="resend"><?php echo __('Resend verification email.', WPA0_LANG);?> </a>
<br/>
<strong><a id="resend" href="#"><?php echo __('Resend verification email.', WPA0_LANG);?> </a></strong>
<br/><br/>
<a href="<?php echo wp_login_url()?>"> <?php echo __('← Login', WPA0_LANG) ?> </a>
<script src="http://cdnjs.cloudflare.com/ajax/libs/reqwest/1.1.0/reqwest.min.js" type="text/javascript"></script>
<script type="text/javascript">
function resendEmail() {
var xmlhttp = null;
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp = new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}

var url = "https://<?php echo $domain ?>/api/users/send_verification_email";
var data = '{"email" : "<?php echo $email ?>", "connection" : "Username-Password-Authentication"}';
xmlhttp.open("POST", url, true);
xmlhttp.setRequestHeader("Authorization", "Bearer <?php echo $token ?>");
xmlhttp.setRequestHeader("Content-Type", "application/json");
xmlhttp.send(data);
reqwest({
url: 'https://<?php echo $domain ?>/api/users/<?php echo $userId ?>/send_verification_email',
type: 'html',
// data: '{"email" : "<?php echo $email ?>", "connection" : "<?php echo $connection?>"}',
data: '{}',
method: 'post',
contentType: 'application/json',
headers: {
'Authorization': "Bearer <?php echo $token ?>"
},
error: function (err) {
alert("Sorry, something went wrong");
},
success: function (resp) {
alert("An email was sent to <?php echo $email?>" );

}
});
}
document.getElementById("resend").onclick = function () {
resendEmail();
alert("An email was sent to <?php echo $email?>" );
}
</script>