aad-sso-wordpress icon indicating copy to clipboard operation
aad-sso-wordpress copied to clipboard

How to get login and logout urls

Open leviatorkilsheyggi opened this issue 7 years ago • 4 comments

Hi

We are creating a custom landingpage for our users. We'll check if the user is signed in, and show a log in / log out button accordingly.

How do i get the login and logout urls? I see someone using: <?php $aad= AADSSO::get_instance($settings); $aad->get_login_url(); // and get_logout_url(); ?> What settings should be passed to get_instance()?

Update: We ended up with this:

	$user = null;
	if(is_user_logged_in()){
		$user = wp_get_current_user();
	}
	
	$auth = apply_filters( 'authenticate', $user ,null,null);
	
	//if( is_wp_error( $auth ) ) {
	//    echo '</br>'.$auth->get_error_message().'</br>';
	//}
	
	$stored_settings = get_option( 'aadsso_settings', null );
	$aad= AADSSO::get_instance($stored_settings);
	$loginUrl = $aad->get_login_url();

leviatorkilsheyggi avatar Mar 06 '18 16:03 leviatorkilsheyggi

We got this working, and it's great. One thing, though: Login only works when the replyurl is mysite.com/wp-login.php. When changing it to something else, the plugin signs into ad, and reports no error. So we 'fixed' it by blocking wp-admin for relevant roles, and redirecting them to the landingpage.

leviatorkilsheyggi avatar Mar 09 '18 13:03 leviatorkilsheyggi

Sorry for the delayed response. When you change the redirect URL, are you changing it in both this plugin's configuration and in the Azure AD app registration?

psignoret avatar Mar 26 '18 09:03 psignoret

Yes. Both places.

leviatorkilsheyggi avatar Mar 26 '18 10:03 leviatorkilsheyggi

What are you setting the redirect URL to? It's important that the URL you're redirecting to actually invoke the WordPress sign-in points where the plugin hooks into.

psignoret avatar Mar 26 '18 10:03 psignoret