New onsite patient portal, take 4.
[openemr.git] / portal / patient / libs / Controller / SecureAppController.php
blob69249146ad81f28ef5ccb57d7c60f896f5e7a827
1 <?php
2 /** @package Cargo::Controller */
4 /** import supporting libraries */
5 require_once("AppBaseController.php");
6 require_once("App/SecureApp.php");
8 /**
9 * SecureAppController is a sample controller to demonstrate
10 * one approach to authentication in a Phreeze app
12 * From phreeze package
13 * @license http://www.gnu.org/copyleft/lesser.html LGPL
15 * @package Cargo::Controller
16 * @author ClassBuilder
17 * @version 1.0
19 class SecureAppController extends AppBaseController
22 /**
23 * Override here for any controller-specific functionality
25 protected function Init()
27 parent::Init();
29 // TODO: add controller-wide bootstrap code
32 /**
33 * This page requires SecureApp::$PERMISSION_USER to view
35 public function UserPage()
37 $this->RequirePermission(SecureApp::$PERMISSION_USER,
38 'SecureApp.LoginForm',
39 'Login is required to access the secure user page',
40 'You do not have permission to access the secure user page');
42 $this->Assign("currentUser", $this->GetCurrentUser());
44 $this->Assign('page','userpage');
45 $this->Render("SecureApp");
48 /**
49 * This page requires SecureApp::$PERMISSION_ADMIN to view
51 public function AdminPage()
53 $this->RequirePermission(SecureApp::$PERMISSION_ADMIN,
54 'SecureApp.LoginForm',
55 'Login is required to access the admin page',
56 'Admin permission is required to access the admin page');
58 $this->Assign("currentUser", $this->GetCurrentUser());
60 $this->Assign('page','adminpage');
61 $this->Render("SecureApp");
64 /**
65 * Display the login form
67 public function LoginForm()
69 $this->Assign("currentUser", $this->GetCurrentUser());
71 $this->Assign('page','login');
72 $this->Render("SecureApp");
75 /**
76 * Process the login, create the user session and then redirect to
77 * the appropriate page
79 public function Login()
81 $user = new SecureApp();
83 if ($user->Login(RequestUtil::Get('username'), RequestUtil::Get('password')))
85 // login success
86 $this->SetCurrentUser($user);
87 $this->Redirect('SecureApp.UserPage');
89 else
91 // login failed
92 $this->Redirect('SecureApp.LoginForm','Unknown username/password combination');
96 /**
97 * Clear the user session and redirect to the login page
99 public function Logout()
101 $this->ClearCurrentUser();
102 $this->Redirect("SecureApp.LoginForm","You are now logged out");