Skip to content

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also .

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also .
...
Checking mergeability… Don’t worry, you can still create the pull request.
  • 8 commits
  • 9 files changed
  • 0 commit comments
  • 1 contributor
Showing with 110 additions and 3 deletions.
  1. +1 −0 atk4
  2. +1 −0 atk4-addons
  3. +1 −0 config-default.php
  4. +14 −2 lib/Frontend.php
  5. +12 −0 page/account.php
  6. +30 −1 page/index.php
  7. +29 −0 page/signup.php
  8. +9 −0 page/video.php
  9. +13 −0 templates/default/page/index.html
View
1 atk4
View
1 atk4-addons
View
1 config-default.php
@@ -5,6 +5,7 @@
$config['url_postfix']='';
$config['url_prefix']='?page=';
+$config['auth']['key']='secret';
# Agile Toolkit attempts to use as many default values for config file,
# and you only need to add them here if you wish to re-define default
View
16 lib/Frontend.php
@@ -12,10 +12,22 @@ function init(){
->setParent($this->pathfinder->base_location);
$this->add('jUI');
- $this->js()->_load('atk4_univ');
+ $this->js()
+ ->_load('atk4_univ')
+ ->_load('ui.atk4_notify')
+ ;
$this->dbConnect();
+ $this->auth=$this->add('RentalAuth');
+ $this->auth->allow('demo','demo');
+
$menu = $this->add('Menu',null,'Menu');
- $menu->addMenuItem('Manager','mgr');
+ if($this->auth){
+ $menu->addMenuItem('Home','video');
+ $menu->addMenuItem('account');
+ $menu->addMenuItem('logout');
+ }else{
+ $menu->addMenuItem('Home','index');
+ }
}
}
View
12 page/account.php
@@ -0,0 +1,12 @@
+<?php
+class page_account extends Page {
+ function init(){
+ parent::init();
+
+ $this->api->auth->check();
+
+ $model = $this->add('Model_Customer');
+ $model->getField('email')->system(true);
+ $this->add('FormAndSave')->setModel($model)->loadData($this->api->auth->get('id'));
+ }
+}
View
31 page/index.php
@@ -2,6 +2,35 @@
class page_index extends Page {
function init(){
parent::init();
- $this->add('H2')->set('Welcome to DVD Rental');
+
+ $form = $this->add('Form',null,'LoginForm');
+ $form->setFormClass('vertical');
+ $form->addField('line','login');
+ $form->addfield('password','password');
+ $form->addSubmit('Login');
+ $form->addButton('Sign-up')->js('click')
+ ->univ()->location($this->api->getDestinationURL('signup'));
+
+ if($form->isSubmitted()){
+
+ $auth=$this->api->auth;
+ $l=$form->get('login');
+ $p=$form->get('password');
+
+ // Manually encrypt password
+ $enc_p = $auth->encryptPassword($p,$l);
+
+ // Manually verify login
+ if($auth->verifyCredintials($l,$enc_p)){
+
+ // Manually log-in
+ $auth->login($l);
+ $form->js()->univ()->redirect('video')->execute();
+ }
+ $form->getElement('password')->displayFieldError('Incorrect login');
+ }
+ }
+ function defaultTemplate(){
+ return array('page/index');
}
}
View
29 page/signup.php
@@ -0,0 +1,29 @@
+<?php
+class page_signup extends Page {
+ function init(){
+ parent::init();
+
+ if($this->api->auth->isLoggedIn())$this->api->redirect('video');
+
+ $model=$this->add('Model_Customer');
+ $model->addField('password')->type('password')->mandatory(true);
+
+ $form = $this->add('MVCForm');
+ $form->setModel($model);
+ $form->addField('password','confirm_password');
+ $form->addSubmit();
+
+ $form->onSubmit(function($form){
+ if($form->get('password') != $form->get('confirm_password'))
+ throw $form->exception('Passwords do not match')->setField('confirm_password');
+
+ $form->set('password',
+ $form->api->auth->encryptPassword($form->get('password'),$form->get('email')));
+
+ $form->update();
+
+ $form->js()->hide('slow')->univ()->successMessage('Registered successfully')->execute();
+ });
+ }
+}
+
View
9 page/video.php
@@ -0,0 +1,9 @@
+<?php
+class page_video extends Page {
+ function init(){
+ parent::init();
+ $this->api->auth->check();
+
+ $this->add('MVCGrid')->setModel('Movie');
+ }
+}
View
13 templates/default/page/index.html
@@ -0,0 +1,13 @@
+<div class="g-row">
+ <div class="g-8">
+ <p>Welcome to the DVD rental program. Lorem ipsum dolor sit amet</p>
+ <?$Content?>
+ </div>
+ <div class="g-2">
+ <h4>Customer Login</h3>
+ <?$LoginForm?>
+
+ <div style="float: left"><?$LoginButton?></div>
+ <div style="float: right"><?$RegisterLink?><br/><?$ForgotLink?></div>
+ </div>
+</div>

No commit comments for this range

Something went wrong with that request. Please try again.