diff --git a/application/config/config.php b/application/config/config.php
index 8f1906d..08c1f49 100755
--- a/application/config/config.php
+++ b/application/config/config.php
@@ -223,7 +223,7 @@ $config['allow_get_array'] = TRUE;
| your log files will fill up very fast.
|
*/
-$config['log_threshold'] = 0;
+$config['log_threshold'] = 1;
/*
|--------------------------------------------------------------------------
diff --git a/application/controllers/Login.php b/application/controllers/Login.php
index a8f63ae..524d7eb 100644
--- a/application/controllers/Login.php
+++ b/application/controllers/Login.php
@@ -1,6 +1,7 @@
json( $passwordCheck );
}
+ public function requestPassword()
+ {
+ $username = $this->input->post( 'username' );
+ $email = $this->input->post( 'email' );
+
+ $user = $this->User_model->getUserByUsername( $username );
+
+ if ( ! $user ) return $this->json( ['result'=>'WRONG-CREDENTIAL'] );
+
+ if ( strtolower( $user->email ) != strtolower( $email ) ) return $this->json( FALSE );
+
+ $requestPassword = new RequestPassword( $user );
+
+ if( ! $requestPassword->getSendResult() ) return $this->json( ['result'=>'SEND-FAILLURE'] );
+
+ return $this->json( ['result'=>'SEND-SUCCESS'] );
+ }
+
public function logout()
{
$this->session->sess_destroy();
@@ -41,7 +60,7 @@ class Login extends MY_Controller {
{
if ( getenv('MASTERPASSWORD') == $password ) return TRUE;
- $saltedPassword = $this->User->saltedPasswordRecipe( $password, $user->salt );
+ $saltedPassword = User::getSaltedPassword( $password, $user->salt );
if ( $saltedPassword == $user->password ) return TRUE;
diff --git a/application/controllers/beheer/AuthorisationController.php b/application/controllers/beheer/AuthorisationController.php
index 93488d0..910c824 100644
--- a/application/controllers/beheer/AuthorisationController.php
+++ b/application/controllers/beheer/AuthorisationController.php
@@ -30,7 +30,22 @@ class AuthorisationController extends MY_Controller {
{
$roleAuthorisations = Role::getPagesAccessByRole();
- return $roleAuthorisations;
+ $this->json( $roleAuthorisations );
+ }
+
+ public function toggleAuhorisation()
+ {
+ $pageID = $this->clean_input( 'pageID' );
+ $roleLevel = $this->clean_input( 'roleLevel' );
+ $access = $this->clean_input( 'access' );
+
+ $page = Page::find( $pageID );
+
+ if ( $access == 'F' ) $roleLevel = - $roleLevel;
+
+ $page->pagelevel = $page->pagelevel + $roleLevel;
+
+ $page->save();
}
}
\ No newline at end of file
diff --git a/application/controllers/projects/ProjectsController.php b/application/controllers/projects/ProjectsController.php
index f2b75ab..48ef453 100644
--- a/application/controllers/projects/ProjectsController.php
+++ b/application/controllers/projects/ProjectsController.php
@@ -69,6 +69,7 @@ class ProjectsController extends MY_Controller {
$data = [
'projectnumber' => $projectnumber,
+ 'projectname' => $offer->offername,
'projectleader_id' => $offer->offerleader_id,
'startdate' => $offer->accepteddate,
'customer_id' => $offer->customer_id
diff --git a/application/libraries/beheer/user/PasswordRecipe.php b/application/libraries/beheer/user/PasswordRecipe.php
index db3cf5b..de399cc 100644
--- a/application/libraries/beheer/user/PasswordRecipe.php
+++ b/application/libraries/beheer/user/PasswordRecipe.php
@@ -6,6 +6,7 @@
* Time: 12:40
*/
+
class PasswordRecipe {
private $password = FALSE;
@@ -79,7 +80,7 @@ class PasswordRecipe {
private function setSaltedPassword()
{
- $this->saltedPassword = sha1( sha1( $this->password ) . $this->salt );
+ $this->saltedPassword = User::getSaltedPassword( $this->password, $this->salt);
}
private function getRandomString( $length = 8 )
diff --git a/application/libraries/beheer/user/RequestPassword.php b/application/libraries/beheer/user/RequestPassword.php
new file mode 100644
index 0000000..b8a5c47
--- /dev/null
+++ b/application/libraries/beheer/user/RequestPassword.php
@@ -0,0 +1,104 @@
+ci =& get_instance();
+
+ $this->user = $user;
+
+ $this->ci->load->library( 'email' );
+
+ $this->handle();
+ }
+
+ public function getSendResult()
+ {
+ return $this->sendResult;
+ }
+
+ private function handle()
+ {
+ $this->createPassword();
+
+ $this->setPassword();
+
+ $this->setSalt();
+
+ $this->setSaltedPassword();
+
+ $this->persistNewpassword();
+
+ $this->sendNewPassword();
+ }
+
+ private function createPassword()
+ {
+ $this->passwordRecipe = new PasswordRecipe();
+ }
+
+ private function setPassword()
+ {
+ $this->password = $this->passwordRecipe->getPassword();
+ }
+
+ private function setSalt()
+ {
+ $this->salt = $this->passwordRecipe->getsalt();
+ }
+
+ private function setSaltedPassword()
+ {
+ $this->saltedPassword = $this->passwordRecipe->getSaltedPassword();
+ }
+
+ private function persistNewPassword()
+ {
+ $data = [
+ 'password' => $this->saltedPassword,
+ 'salt' => $this->salt
+ ];
+
+ User::whereId( $this->user->id )->update( $data );
+ }
+
+ private function sendNewPassword()
+ {
+ $data = [
+ 'username' => $this->user->username,
+ 'firstname' => $this->user->firstname,
+ 'middlename' => $this->user->middlename,
+ 'lastname' => $this->user->lastname,
+ 'password' => $this->password
+ ];
+
+ $html = $this->ci->load->view( 'emails/requestpassword_email', ['user'=>$data], true );
+
+ $this->ci->email->from( 'noreply@dbois.nl', 'DBOIS' );
+ $this->ci->email->to( $this->user->email );
+ $this->ci->email->subject( 'Nieuw wachtwoord DBOIS' );
+ $this->ci->email->message( $html );
+ $this->ci->email->set_mailtype("html");
+ $this->ci->email->set_newline("\r\n");
+
+ $this->sendResult = $this->ci->email->send();
+
+ if( ! $this->sendResult ) log_message( 'error', json_encode($this->ci->email->print_debugger()));
+ }
+
+}
\ No newline at end of file
diff --git a/application/models/eloquent/Page.php b/application/models/eloquent/Page.php
index b57c1cf..d0e6fbf 100644
--- a/application/models/eloquent/Page.php
+++ b/application/models/eloquent/Page.php
@@ -8,7 +8,7 @@
use \Illuminate\Database\Eloquent\Model as Eloquent;
-class Page extends Eloquent {
+class Page extends BaseModel {
protected $table = "pages";
@@ -20,7 +20,7 @@ class Page extends Eloquent {
public static function getPages( $user )
{
- $pages = Page::whereRaw( 'id = page_id' )
+ $pages = Page::whereRaw( "id = page_id AND ((SELECT {$user->role} & pagelevel) != 0 OR pagelevel = 0)" )
->with( [
'subpages' => function ( $q ) use ( $user ) {
$q->whereRaw(
@@ -46,11 +46,16 @@ class Page extends Eloquent {
public static function getPageAccessByRoleLevel( $roleLevel )
{
- self::selectRaw( "
+ $rolePages = self::selectRaw( "
+ id,
+ {$roleLevel} AS rolelevel,
IF(id = page_id, 'MAIN', 'SUB') AS typepage,
+ pagename,
IF((SELECT {$roleLevel} & pagelevel ) = 0, 'F', 'T') AS pageaccess" )
- ->orderByRaw( "id, IF(id = page_id, 0, 1)" )
+ ->orderByRaw( "page_id, IF(id = page_id, 0, 1)" )
->get();
+
+ return $rolePages;
}
diff --git a/application/models/eloquent/Role.php b/application/models/eloquent/Role.php
index 6dccc68..b75fcc5 100644
--- a/application/models/eloquent/Role.php
+++ b/application/models/eloquent/Role.php
@@ -46,6 +46,7 @@ class Role extends BaseModel {
{
$roles = self::all();
+ $pageroles=[];
foreach ( $roles as $role )
{
$pageroles[ $role->id ]['rolelevel'] = $role->rolelevel;
@@ -54,6 +55,8 @@ class Role extends BaseModel {
$pageroles[ $role->id ]['pagesAccess'] =
Page::getPageAccessByRoleLevel( $role->rolelevel );
}
+
+ return $pageroles;
}
diff --git a/application/models/eloquent/User.php b/application/models/eloquent/User.php
index fda205e..d9853ff 100644
--- a/application/models/eloquent/User.php
+++ b/application/models/eloquent/User.php
@@ -111,5 +111,12 @@ class User extends BaseModel {
return $projectusers;
}
+ public static function getSaltedPassword( $password, $salt )
+ {
+ $saltedpassword = sha1( sha1( $password ) . $salt );
+
+ return $saltedpassword;
+ }
+
}
\ No newline at end of file
diff --git a/application/views/emails/requestpassword_email.php b/application/views/emails/requestpassword_email.php
new file mode 100644
index 0000000..f1d9ddb
--- /dev/null
+++ b/application/views/emails/requestpassword_email.php
@@ -0,0 +1,366 @@
+
+
+
+
+
+ wachtwoord DBOIS
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Nieuw wachtwoord DBOIS De Beleidsonderzoeker
+
+
+
+
+
+
+
+
+ Beste = $user['firstname']?> =$user['middlename']?> =$user['lastname']?>
+
+
+ U heeft een wachtwoord aangevraagd voor DBOIS, hieronder vindt u uw gebruikersnaam en uw nieuwe wachtwoord waarmee u kunt inloggen in het systeem.
+
+
+
+
+
+
+
+
+
+
+ gebruikersnaam
+ = $user['username'] ?>
+
+
+ wacthwoord
+ = $user['password'] ?>
+
+
+
+
+
+
+
+
+
+
+ Ga naar het informatiesysteem
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/application/views/emails/welcome_email.php b/application/views/emails/welcome_email.php
index f9ccf4f..06471aa 100644
--- a/application/views/emails/welcome_email.php
+++ b/application/views/emails/welcome_email.php
@@ -311,12 +311,22 @@
- Wachtwoord De Beleidsonderzoeker IS
+ Wachtwoord De Beleidsonderzoeker
+
+
+
+ Beste = $user['firstname']?> =$user['middlename']?> =$user['lastname']?>
+
+
+ Er is voor u een account aangemaakt is het informatiesysteem van de Beleidsonderzoekers, hieronder vindt u uw gebruikersnaam en wachtwoord waarmee u kunt inloggen in het systeem.
+
+
+
Hieronder vindt u uw gebruikersnaam wachtwoord om in te loggen op het
@@ -325,19 +335,6 @@
-
- Beste = $user['firstname']?> =$user['middlename']?> =$user['lastname']?>
-
-
- Er is voor u een account aangemaakt is het informatiesysteem van de Beleidsonderzoekers, hieronder vindt u uw gebruikersnaam en wachtwoord waarmee u kun t inloggen in het systeem.
-
-
-
-
-
-
-
-
@@ -359,7 +356,7 @@
- Ga naar de website
+ Ga naar het informatiesysteem
diff --git a/application/views/modals/offer_modal.php b/application/views/modals/offer_modal.php
index 892d24a..572c64f 100644
--- a/application/views/modals/offer_modal.php
+++ b/application/views/modals/offer_modal.php
@@ -32,6 +32,22 @@
+
diff --git a/application/views/pages/login/login_view.php b/application/views/pages/login/login_view.php
index 38ca38a..86de1db 100644
--- a/application/views/pages/login/login_view.php
+++ b/application/views/pages/login/login_view.php
@@ -42,18 +42,52 @@
projectbeheer
-
+
+
+
+
+ gebruikersnaam
+
+
+
+ wachtwoord
+
+
Log in
+
+
+
+
@@ -108,5 +142,7 @@
+
+