Skip to content

Commit

Permalink
Redirect User to CO dashboard in member of only one CO
Browse files Browse the repository at this point in the history
  • Loading branch information
ioigoume committed Sep 7, 2020
1 parent 21e1509 commit bfd2830
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- Changed the way we load plugins from config. This extention will allow plugins to inject bootstrapping and routes
- Increased CO Localization text field capacity.
- Improved user's graphical interaction during Enrollment Flow
- Redirect User to CO dashboard if member in only one CO.

### Fixed
- Prevent users from submitting multiple registration requests
Expand Down
10 changes: 9 additions & 1 deletion app/Controller/UsersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,15 @@ public function login() {
// Note we're performing CO specific work here, even though we're not in a CO context yet.

$this->OrgIdentitySource->syncByIdentifier($u);


if(count($cos) === 1 && $this->Auth->redirectUrl() === '/') {
$args = array();
$args['plugin'] = null;
$args['controller'] = 'co_dashboards';
$args['action'] = 'dashboard';
$args['co'] = $co["co_id"];
$this->redirect($args);
}
$this->redirect($this->Auth->redirectUrl());
} else {
// This is an API user. We don't do anything special at the moment, other
Expand Down
7 changes: 7 additions & 0 deletions app/webroot/auth/login/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,13 @@
exit;
}

// XXX if we define no redirect path, e.g. to an internal path: co_dashboards/configuration/co:2 then CAKEPHP thinks that should come back here
// XXX as a result adds to the SESSION auth/login as the redirect path after login. This causes the login to happen twice for the case we are
// XXX visiting the COmanage homepage
if(empty($_SESSION["Auth"]["redirect"])) {
$_SESSION["Auth"]["redirect"] = '/';
}

?>
<!DOCTYPE html>
<html lang="en">
Expand Down

0 comments on commit bfd2830

Please sign in to comment.