summaryrefslogtreecommitdiff
path: root/demos/chat/protected/pages/Login.php
diff options
context:
space:
mode:
Diffstat (limited to 'demos/chat/protected/pages/Login.php')
-rw-r--r--demos/chat/protected/pages/Login.php40
1 files changed, 40 insertions, 0 deletions
diff --git a/demos/chat/protected/pages/Login.php b/demos/chat/protected/pages/Login.php
new file mode 100644
index 00000000..831ab925
--- /dev/null
+++ b/demos/chat/protected/pages/Login.php
@@ -0,0 +1,40 @@
+<?php
+
+class Login extends TPage
+{
+ /**
+ * Check that the username is not already taken.
+ * @param TControl custom validator that created the event.
+ * @param TServerValidateEventParameter validation parameters.
+ */
+ function checkUsername($sender, $param)
+ {
+ $manager = $this->Application->Modules['users'];
+ if($manager->usernameExists($this->username->Text))
+ $param->IsValid = false;
+ }
+
+ /**
+ * Create and login a new user, then redirect to the requested page.
+ * @param TControl button control that created the event.
+ * @param TEventParameter event parameters.
+ */
+ function createNewUser($sender, $param)
+ {
+ if($this->Page->IsValid)
+ {
+ $manager = $this->Application->Modules['users'];
+ $manager->addNewUser($this->username->Text);
+
+ //do manual login
+ $user = $manager->getUser($this->username->Text);
+ $auth = $this->Application->Modules['auth'];
+ $auth->updateSessionUser($user);
+ $this->Application->User = $user;
+
+ $this->Response->redirect($auth->ReturnUrl);
+ }
+ }
+}
+
+?> \ No newline at end of file