MAW-880: Plugin Cleanup
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
<?php include plugin_dir_path(__FILE__).'/../includes/widget.php'; ?>
|
||||
|
||||
<script>
|
||||
<?php include plugin_dir_path(__FILE__).'/../includes/initialize-widget.js.php'; ?>
|
||||
|
||||
oktaSignIn.authClient.session.exists()
|
||||
.then(function(exists) {
|
||||
if(exists) {
|
||||
oktaSignIn.authClient.token.getWithoutPrompt({
|
||||
responseType: ['id_token'],
|
||||
})
|
||||
.then(function(tokens){
|
||||
window.location.href = '<?php echo wp_login_url() ?>' + '?log_in_from_id_token=' + tokens.tokens.idToken.value;
|
||||
});
|
||||
}
|
||||
});
|
||||
</script>
|
||||
@@ -0,0 +1,9 @@
|
||||
<div class="wrap">
|
||||
<h1>Okta Sign-In Widget</h1>
|
||||
|
||||
<form method="post" action="options.php">
|
||||
<?php settings_fields( 'okta-sign-in-widget' ); ?>
|
||||
<?php do_settings_sections( 'okta-sign-in-widget' ); ?>
|
||||
<?php submit_button(); ?>
|
||||
</form>
|
||||
</div>
|
||||
@@ -0,0 +1,67 @@
|
||||
<?php include plugin_dir_path(__FILE__).'/../includes/widget.php'; ?>
|
||||
|
||||
<style type="text/css">
|
||||
body {
|
||||
font-family: montserrat,Arial,Helvetica,sans-serif;
|
||||
}
|
||||
|
||||
#wordpress-login{
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
#wordpress-login a{
|
||||
font-size:10px;
|
||||
color: #999;
|
||||
text-decoration:none;
|
||||
}
|
||||
|
||||
#error {
|
||||
max-width: 500px;
|
||||
margin: 20px auto;
|
||||
padding: 20px;
|
||||
border: 1px #d93934 solid;
|
||||
border-radius: 6px;
|
||||
}
|
||||
#error h2 {
|
||||
color: #d93934;
|
||||
}
|
||||
</style>
|
||||
|
||||
<?php if(isset($_GET['error'])): ?>
|
||||
<div id="error">
|
||||
<h2>Error: <?php echo htmlspecialchars($_GET['error']) ?></h2>
|
||||
<p><?php echo htmlspecialchars($_GET['error_description']) ?></p>
|
||||
</div>
|
||||
<?php endif ?>
|
||||
|
||||
<div id="primary" class="content-area">
|
||||
<div id="okta-login-container"></div>
|
||||
<?php if(get_option('okta-allow-wordpress-login')): ?>
|
||||
<div id="wordpress-login"><a href="<?php echo wp_login_url(); ?>?wordpress_login=true">Login via Wordpress</a></div>
|
||||
<?php endif ?>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
<?php include plugin_dir_path(__FILE__).'/../includes/initialize-widget.js.php'; ?>
|
||||
|
||||
oktaSignIn.authClient.token.getUserInfo().then(function(user) {
|
||||
console.log("Already logged in");
|
||||
oktaSignIn.authClient.tokenManager.get('idToken').then(function(idToken){
|
||||
window.location = '<?php echo wp_login_url() ?>?log_in_from_id_token='+idToken.value;
|
||||
});
|
||||
}, function(error) {
|
||||
oktaSignIn.showSignInToGetTokens({
|
||||
el: '#okta-login-container'
|
||||
}).then(function(tokens) {
|
||||
oktaSignIn.authClient.tokenManager.setTokens(tokens);
|
||||
|
||||
oktaSignIn.remove(); // Remove the widget from the DOM
|
||||
|
||||
const idToken = tokens.idToken;
|
||||
window.location = '<?php echo wp_login_url() ?>?log_in_from_id_token='+idToken.value;
|
||||
|
||||
}).catch(function(err) {
|
||||
console.error(err);
|
||||
});
|
||||
});
|
||||
</script>
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php include plugin_dir_path(__FILE__).'/../includes/widget.php'; ?>
|
||||
|
||||
<script>
|
||||
<?php include plugin_dir_path(__FILE__).'/../includes/initialize-widget.js.php'; ?>
|
||||
|
||||
oktaSignIn.authClient.tokenManager.get('idToken').then(function(idToken){
|
||||
if(idToken) {
|
||||
oktaSignIn.authClient.signOut({
|
||||
idToken: idToken,
|
||||
postLogoutRedirectUri: '<?php echo home_url() ?>'
|
||||
});
|
||||
} else {
|
||||
window.location = '<?php echo home_url() ?>';
|
||||
}
|
||||
});
|
||||
</script>
|
||||
Reference in New Issue
Block a user