summaryrefslogtreecommitdiff
path: root/app/php/components
diff options
context:
space:
mode:
authoremkael <emkael@tlen.pl>2016-03-10 17:11:11 +0100
committeremkael <emkael@tlen.pl>2016-03-10 17:11:11 +0100
commitbb786c1e19aeaa44b81b47265a284e8737c09e65 (patch)
treed9896a7d27adc3197ca0d0b3ac7114396a52f5d3 /app/php/components
parent94fb52459898989ea2158e6b90440632724a1679 (diff)
* login box as a component
Diffstat (limited to 'app/php/components')
-rw-r--r--app/php/components/LoginBox.php23
-rw-r--r--app/php/components/LoginBox.tpl29
2 files changed, 52 insertions, 0 deletions
diff --git a/app/php/components/LoginBox.php b/app/php/components/LoginBox.php
new file mode 100644
index 0000000..33bbcc1
--- /dev/null
+++ b/app/php/components/LoginBox.php
@@ -0,0 +1,23 @@
+<?php
+
+class LoginBox extends TTemplateControl {
+
+ public function loginUser($sender, $param) {
+ if ($this->Page->IsValid) {
+ $this->Response->redirect(
+ $this->Application->getModule('auth')->ReturnUrl
+ ?: $this->Service->constructUrl(NULL)
+ );
+ }
+ }
+
+ public function validatePassword($sender, $param) {
+ $param->IsValid = $this->Application->getModule('auth')->login(
+ $this->Login->Text,
+ $this->Password->Text
+ );
+ }
+
+}
+
+?>
diff --git a/app/php/components/LoginBox.tpl b/app/php/components/LoginBox.tpl
new file mode 100644
index 0000000..c602b88
--- /dev/null
+++ b/app/php/components/LoginBox.tpl
@@ -0,0 +1,29 @@
+Username:
+<com:TTextBox ID="Login"
+ ValidationGroup="LoginGroup" />
+<com:TRequiredFieldValidator
+ ControlToValidate="Login"
+ Display="Dynamic"
+ ErrorMessage="Username cannot be empty"
+ ValidationGroup="LoginGroup" />
+<br />
+Password:
+<com:TTextBox ID="Password"
+ TextMode="Password"
+ ValidationGroup="LoginGroup" />
+<com:TRequiredFieldValidator
+ ControlToValidate="Password"
+ Display="Dynamic"
+ ErrorMessage="Password cannot be empty"
+ ValidationGroup="LoginGroup" />
+<com:TCustomValidator
+ ControlToValidate="Password"
+ OnServerValidate="validatePassword"
+ Display="Dynamic"
+ ErrorMessage="Username and password don't match"
+ ValidationGroup="LoginGroup" />
+<br />
+<com:TButton
+ Text="Login"
+ OnCommand="loginUser"
+ ValidationGroup="LoginGroup" />