Skip to content

Commit

Permalink
Merge pull request #82 from TwistPHP/development
Browse files Browse the repository at this point in the history
Release of v3.0.3
  • Loading branch information
ahosgood committed Mar 15, 2016
2 parents e8a8957 + 930e5b5 commit 219427c
Show file tree
Hide file tree
Showing 33 changed files with 2,543 additions and 285 deletions.
30 changes: 15 additions & 15 deletions .travis.yml
Expand Up @@ -4,10 +4,12 @@ php:
- 5.3
- 5.4
- 5.5
env GULP=ON
- 5.6
env COVERALLS=ON
- 7.0
#- hhvm
#- nightly
- hhvm
- nightly

services:
- mysql
Expand All @@ -24,26 +26,24 @@ before_install:
- mysql -V
- mysql -e "CREATE DATABASE IF NOT EXISTS travis_ci_twist_test;"
- mysql -e "SHOW DATABASES"
- if [ "$GULP" = 'ON' ]; then npm install; fi;

install: php ./tests/install.php
install:
- if [ "$COVERALLS" = 'ON' ]; then composer require satooshi/php-coveralls '~1.0'; fi;
- php ./tests/install.php

before_script:
- mkdir -p ./build/logs
- mysql -e "USE travis_ci_twist_test; SHOW TABLES;"
- ls -lah ./tests
- sed -i 's/Twist::ServeRoutes(false);/echo "TwistPHP Framework Loaded!\n\n";/g' ./tests/index.php

#script: phpunit --bootstrap ./tests/index.php \App\Models\ViewTest --verbose
script:
- phpunit ./tests/Database.php
- phpunit ./tests/Settings.php
- phpunit ./tests/Cache.php
- phpunit ./tests/Session.php
- phpunit ./tests/Views.php
- phpunit ./tests/User.php
- phpunit ./tests/Curl.php
- phpunit ./tests/Routes.php
- phpunit
- if [ "$GULP" = 'ON' ]; then gulp test; fi;

notifications:
on_success: never
#on_failure: always
on_failure: never
on_failure: always

after_success:
- if [ "$COVERALLS" = 'ON' ]; then ./vendor/bin/coveralls -v; fi;
2 changes: 1 addition & 1 deletion README.md
@@ -1,6 +1,6 @@
# [TwistPHP](https://twistphp.com/) ![TwistPHP logo](http://static.twistphp.com/logo/square/32.png)

[![Master build status](https://img.shields.io/travis/TwistPHP/TwistPHP/master.svg?label=master%20build)](https://travis-ci.org/TwistPHP/TwistPHP) [![Development build status](https://img.shields.io/travis/TwistPHP/TwistPHP/development.svg?label=development%20build)](https://travis-ci.org/TwistPHP/TwistPHP) [![Join the chat at https://gitter.im/TwistPHP/TwistPHP](https://img.shields.io/gitter/room/TwistPHP/TwistPHP.svg)](https://gitter.im/TwistPHP/TwistPHP) ![Licence](https://img.shields.io/badge/Licence-GPLv3-brightgreen.svg)
[![Master build status](https://img.shields.io/travis/TwistPHP/TwistPHP/master.svg?label=master%20build)](https://travis-ci.org/TwistPHP/TwistPHP) [![Development build status](https://img.shields.io/travis/TwistPHP/TwistPHP/development.svg?label=development%20build)](https://travis-ci.org/TwistPHP/TwistPHP) [![Coveralls](https://img.shields.io/coveralls/TwistPHP/TwistPHP.svg)](https://coveralls.io/github/TwistPHP/TwistPHP) [![Join the chat at https://gitter.im/TwistPHP/TwistPHP](https://img.shields.io/gitter/room/TwistPHP/TwistPHP.svg)](https://gitter.im/TwistPHP/TwistPHP) ![Licence](https://img.shields.io/badge/Licence-GPLv3-brightgreen.svg)

## A fresh, new open source PHP MVC micro framework

Expand Down
6 changes: 3 additions & 3 deletions composer.json
@@ -1,8 +1,8 @@
{
"name": "twistphp/twistphp",
"type": "library",
"description": "The TwistPHP MVC micro framework",
"keywords": ["framework","twistphp","MVC"],
"type": "project",
"description": "TwistPHP is an open source PHP MVC framework built from the ground up",
"keywords": ["framework","twistphp","MVC","PHP"],
"homepage": "https://twistphp.com",
"license": "LGPL",
"support": {
Expand Down
25 changes: 21 additions & 4 deletions dist/twist/Classes/Error.class.php
Expand Up @@ -201,6 +201,12 @@ public static function handleException($resException,$arrError = array()){
self::handleError($arrTags['type_code'],$arrTags['message'],$arrTags['file'],$arrTags['line']);
}

//Output the correct
$strHttpProtocol = ("HTTP/1.1" === $_SERVER["SERVER_PROTOCOL"]) ? 'HTTP/1.1' : 'HTTP/1.0';

//Output a 500 Error response for an exception page (this page should not have a 200 status code)
header(sprintf('%s %d Internal Server Error',$strHttpProtocol,500),true,500);

if(TWIST_AJAX_REQUEST){

header( 'Cache-Control: no-cache, must-revalidate' );
Expand Down Expand Up @@ -283,15 +289,26 @@ public static function handleFatal(){
* Output a 404 page to the user
*/
public static function handle404(){
self::errorPage(404);
self::response(404);
}

/**
* Output a response code and a custom message if required to the user, this function handles all HTTP response codes.
* @param $intErrorCode
* @param null $strCustomDescription
* Output HTTP error response code, This function has been deprecated in favour of the response() method
* @param int $intErrorCode
* @param null|string $strCustomDescription
* @alias response
* @deprecated
*/
public static function errorPage($intErrorCode,$strCustomDescription = null){
self::response($intErrorCode,$strCustomDescription);
}

/**
* Output HTTP error response code and a custom message if required to the user, this function handles all HTTP response codes.
* @param int $intErrorCode
* @param null|string $strCustomDescription
*/
public static function response($intErrorCode,$strCustomDescription = null){

$strReturn = 'Unknown';
$strDescription = '';
Expand Down
157 changes: 97 additions & 60 deletions dist/twist/Core/Controllers/BaseUser.controller.php
Expand Up @@ -351,64 +351,101 @@ public function register(){
/**
* Process the users registration request and then redirect onto the relevant page.
*/
public function POSTregister(){

//Process the register user request
if(array_key_exists('register',$_POST) && $_POST['register'] != ''){

$resUser = $this->resUser->create();
$resUser->email($_POST['email']);
$resUser->firstname($_POST['firstname']);
$resUser->surname($_POST['lastname']);
$resUser->level(10);

$blContinue = true;

if(\Twist::framework()->setting('USER_REGISTER_PASSWORD')){

if($_POST['password'] === $_POST['confirm_password']){
$arrResponse = $resUser->password($_POST['password']);

if(!$arrResponse['status']){
\Twist::Session()->data('site-register_error_message',$arrResponse['message']);
$blContinue = false;
}
}else{
\Twist::Session()->data('site-register_error_message','Your password and confirm password do not match');
$blContinue = false;
}
}else{
$resUser->resetPassword();
}

//If the password configuration has passed all checks then continue
if($blContinue){
$intUserID = $resUser->commit();

if($intUserID > 0){

//AUTO_LOGIN
if(\Twist::framework()->setting('USER_REGISTER_PASSWORD') && !\Twist::framework()->setting('USER_EMAIL_VERIFICATION') && \Twist::framework()->setting('USER_AUTO_AUTHENTICATE')){

//@todo redirect - test or work out best way of doing this
//$this->resUser->afterLoginRedirect(); --- set the value that this function uses, authenticate will do the redirect

//Authenticate the user (log them in)
$this->resUser->authenticate($_POST['email'],$_POST['password']);

//@todo redirect - test or work out best way of doing this
$this->resUser->afterLoginRedirect();
}else{
\Twist::Session()->data('site-register_message','Thank you for your registration, your password has been emailed to you');
unset( $_POST['email'] );
unset( $_POST['firstname'] );
unset( $_POST['lastname'] );
unset( $_POST['register'] );
}
}else{
\Twist::Session()->data('site-register_error_message','Failed to register user');
}
}
}
}
public function POSTregister(){

//Process the register user request
if(array_key_exists('register',$_POST) && $_POST['register'] != ''){

$resValidator = \Twist::Validate()->createTest();
$resValidator->checkString('firstname');
$resValidator->checkString('lastname');
$resValidator->checkEmail('email');

if(\Twist::framework()->setting('USER_REGISTER_PASSWORD')){
$resValidator->checkComparison('password', 'confirm_password');
}

$arrResult = $resValidator->test($_POST);

if($resValidator->success()){

$resUser = $this->resUser->create();
$resUser->email($_POST['email']);
$resUser->firstname($_POST['firstname']);
$resUser->surname($_POST['lastname']);
$resUser->level(10);

$blContinue = true;

if(\Twist::framework()->setting('USER_REGISTER_PASSWORD')){

if($_POST['password'] === $_POST['confirm_password']){
$arrResponse = $resUser->password($_POST['password']);

if(!$arrResponse['status']){
\Twist::Session()->data('site-register_error_message',$arrResponse['message']);
$blContinue = false;
}
}else{
\Twist::Session()->data('site-register_error_message','Your password and confirm password do not match');
$blContinue = false;
}
}else{
$resUser->resetPassword();
}

//If the password configuration has passed all checks then continue
if($blContinue){
$intUserID = $resUser->commit();

if($intUserID > 0){

if(\Twist::framework()->setting('USER_REGISTER_PASSWORD')){

if(\Twist::framework()->setting('USER_EMAIL_VERIFICATION')){
//Tell the user that they must first verify their account
\Twist::Session()->data('site-login_message','Thank you for your registration, please verify your account using the code we have emailed to you');
}elseif(\Twist::framework()->setting('USER_AUTO_AUTHENTICATE')){
//Authenticate the user (log them in)
$this->resUser->authenticate($_POST['email'],$_POST['password']);
}else{
\Twist::Session()->data('site-login_message','Thank you for your registration, please login to access your account');
}

}else{

unset( $_POST['email'] );
unset( $_POST['firstname'] );
unset( $_POST['lastname'] );
unset( $_POST['register'] );

if(\Twist::framework()->setting('USER_EMAIL_VERIFICATION')){
\Twist::Session()->data('site-login_message','Thank you for your registration, your password and verification code has been emailed to you');
}else{
\Twist::Session()->data('site-login_message','Thank you for your registration, your password has been emailed to you');
}
}

//Go to Login Page
\Twist::redirect('./login');

}else{
\Twist::Session()->data('site-register_error_message','Registration failed, you might already be registered');
}
}
}else{

$strErrorMessage = '';
foreach($arrResult['results'] as $arrEachResult){
if(!$arrEachResult['status']){
$strErrorMessage .= $arrEachResult['message']."<br>";
}
}

\Twist::Session()->data('site-register_error_message',$strErrorMessage);
}
}

return $this->register();
}
}

0 comments on commit 219427c

Please sign in to comment.