| 1 |
lars |
1 |
<?php
|
|
|
2 |
|
|
|
3 |
class LoginUser extends TPage
|
|
|
4 |
{
|
|
|
5 |
/**
|
|
|
6 |
* Validates whether the username and password are correct.
|
|
|
7 |
* This method responds to the TCustomValidator's OnServerValidate event.
|
|
|
8 |
* @param mixed event sender
|
|
|
9 |
* @param mixed event parameter
|
|
|
10 |
*/
|
|
|
11 |
public function validateUser($sender,$param)
|
|
|
12 |
{
|
|
|
13 |
$authManager=$this->Application->getModule('auth');
|
|
|
14 |
if(!$authManager->login($this->Username->Text,$this->Password->Text))
|
|
|
15 |
$param->IsValid=false; // tell the validator that validation fails
|
|
|
16 |
}
|
|
|
17 |
|
|
|
18 |
/**
|
|
|
19 |
* Redirects the user's browser to appropriate URL if login succeeds.
|
|
|
20 |
* This method responds to the login button's OnClick event.
|
|
|
21 |
* @param mixed event sender
|
|
|
22 |
* @param mixed event parameter
|
|
|
23 |
*/
|
|
|
24 |
public function loginButtonClicked($sender,$param)
|
|
|
25 |
{
|
|
|
26 |
if($this->Page->IsValid) // all validations succeed
|
|
|
27 |
{
|
|
|
28 |
// obtain the URL of the privileged page that the user wanted to visit originally
|
|
|
29 |
$url=$this->Application->getModule('auth')->ReturnUrl;
|
|
|
30 |
if(empty($url)) // the user accesses the login page directly
|
|
|
31 |
$url=$this->Service->DefaultPageUrl;
|
|
|
32 |
$this->Response->redirect($url);
|
|
|
33 |
}
|
|
|
34 |
}
|
|
|
35 |
}
|
|
|
36 |
|
|
|
37 |
?>
|