Browse Source

Forgot Password Added & UI Improvements

Added Forgot password section and made improvements on the UI.
causefx 9 years ago
parent
commit
5ad85df607

File diff suppressed because it is too large
+ 0 - 0
bower_components/bootstrap/dist/css/bootstrap.min.css


File diff suppressed because it is too large
+ 0 - 0
bower_components/iconpick/dist/css/fontawesome-iconpicker.min.css


+ 41 - 0
check.php

@@ -35,6 +35,46 @@ function check($extension) {
     
 }
 
+function checkFunction($function) {
+    
+    if (function_exists($function)) : 
+    
+        echo '<div class="panel panel-success">';
+        echo '<div class="panel-heading">';
+        echo '<h3 class="panel-title">'. $function . '</h3>';
+        echo '</div>';
+        echo '<div style="color: gray" class="panel-body">';
+        echo $function . ' is loaded and ready to rock-n-roll!  Good 2 Go!';
+    
+        if($function == "MAIL") :
+            
+            echo '<br/> **Please make sure you can send email prior to installing as this is needed for password resets**';
+        
+        endif;
+    
+        echo '</div></div>'; 
+    
+    else :
+    
+        echo '<div class="panel panel-danger">';
+        echo '<div class="panel-heading">';
+        echo '<h3 class="panel-title">'. $function . '</h3>';
+        echo '</div>';
+        echo '<div style="color: gray" class="panel-body">';
+        echo $function . ' is NOT loaded!  Please install it before proceeding'; 
+    
+        if($function == "MAIL") :
+            
+            echo '<br/> **If you do not want to use password resets, this is okay not being installed**  EDIT LINE 31 on user.php to "false" [const use_mail = false]';
+        
+        endif;
+    
+        echo '</div></div>'; 
+    
+    endif;  
+    
+}
+
 function getFilePermission($file) {
         
     if (file_exists($file)) :
@@ -125,6 +165,7 @@ $folder = USER_HOME;
                 
                 check("PDO_SQLITE");
                 check("PDO");
+                checkFunction("MAIL");
 
                 getFilePermission($db);
                 getFilePermission($folder);

+ 12 - 11
css/style.css

@@ -1090,7 +1090,7 @@ body {
   background: #fff;
   -webkit-border-radius: 3px;
           border-radius: 3px;
-  margin-bottom: 30px;
+  margin-bottom: 10px;
   overflow: hidden;
   -webkit-box-shadow: 0 1px 1px 0 rgba(0, 0, 0, 0.05);
           box-shadow: 0 1px 1px 0 rgba(0, 0, 0, 0.05);
@@ -1110,7 +1110,7 @@ body {
 }
 
 .big-box {
-  padding: 20px;
+  padding: 15px;
 }
 
 .biggest-box {
@@ -1258,7 +1258,7 @@ body {
 
 .member-info {
   font-weight: 400;
-  margin-top: 20px;
+  margin-top: 10px;
 }
 
 .member-info img {
@@ -2400,8 +2400,8 @@ table.dataTable.no-footer, table.dataTable thead th, table.dataTable thead td {
   border-bottom: 0;
   border-top: 0;
   border-right: 0;
-  -webkit-border-radius: 0;
-          border-radius: 0;
+  -webkit-border-radius: 4px;
+          border-radius: 4px;
   margin-bottom: 3px;
   background: #F3F3F3;
 }
@@ -2424,7 +2424,7 @@ table.dataTable.no-footer, table.dataTable thead th, table.dataTable thead td {
 }
 
 .todo .action-btns a span {
-  color: #585050;
+  color: #FFFFFF;
 }
 
 .todo .checked-todo {
@@ -2508,7 +2508,7 @@ a.thumbnail.active, a.thumbnail:focus, a.thumbnail:hover {
 }
 
 .form-inline .form-group {
-  margin-right: 20px;
+  margin-right: 10px;
 }
 
 .form-inline .btn {
@@ -4446,6 +4446,7 @@ body .ns-effect-loadingcircle {
 .grids .row [class^=col-] {
   background: #d3dde0;
   border: 1px solid #cbd3d5;
+  border-radius: 5px;
 }
 
 /*Buttons*/
@@ -5879,13 +5880,13 @@ label {
   position: fixed;
   top: 56px;
   bottom: 0;
-  width: 240px !important;
+  width: 420px !important;
   z-index: 1;
-  right: -245px;
+  right: -425px;
   -webkit-box-shadow: -1px 1px 5px 0px rgba(0, 0, 0, 0.13);
           box-shadow: -1px 1px 5px 0px rgba(0, 0, 0, 0.13);
-  -webkit-transition: all, .5s;
-          transition: all, .5s;
+  -webkit-transition: all, 1s;
+          transition: all, 1s;
 }
 
 .members-sidebar .messages {

+ 116 - 41
index.php

@@ -471,7 +471,7 @@ $userpic = md5( strtolower( trim( $USER->email ) ) );
                                 
                             <?php endif; ?>
                                 
-                                <i class="userpic"><img style="border-radius: 50px;" src="https://www.gravatar.com/avatar/<?=$userpic;?>?s=40&d=mm" class="userpic"></i> 
+                                <i class="userpic"><img src="https://www.gravatar.com/avatar/<?=$userpic;?>?s=40&d=mm" class="img-circle"></i> 
                                 
                             </a>
                             
@@ -631,6 +631,10 @@ $userpic = md5( strtolower( trim( $USER->email ) ) );
                 
                                         <br><br><br>
                                         <h2 class="text-center">Looks like you don't have access.</h2>
+                                        
+                                        <?php if(!$USER->authenticated) : ?>
+                                        <button style="background:<?=$topbar;?>;" type="submit" class="btn log-in btn-block btn-primary text-uppercase waves waves-effect waves-float"><text style="color:<?=$topbartext;?>;">Login</text></button>
+                                        <?php endif; ?>
         						                                    
                                     </div>
                                 
@@ -653,63 +657,95 @@ $userpic = md5( strtolower( trim( $USER->email ) ) );
             <!--Welcome notification-->
             <div id="welcome"></div>
             
-            <div id="members-sidebar" class="gray-bg members-sidebar">
+            <div id="members-sidebar" style="background: <?=$sidebar;?>;" class="members-sidebar">
                 
-                <h4 class="pull-left zero-m"><?php echo strtoupper($USER->username); ?> Options</h4>
+                <h4 class="pull-left zero-m">Options</h4>
                 
                 <span class="close-members-sidebar"><i class="fa fa-remove pull-right"></i></span>
                 
                 <div class="clearfix"><br/></div>
                 
                 <?php if($USER->authenticated) : ?>
+                
+                <div class="content-box profile-sidebar box-shadow">
+                
+                    <img src="https://www.gravatar.com/avatar/<?=$userpic;?>?s=100&d=mm" class="img-responsive img-circle center-block" alt="user" https:="" www.gravatar.com="" avatar="">
+                
+                    <div class="profile-usertitle">
+                
+                        <div class="profile-usertitle-name">
+                
+                            <?php echo strtoupper($USER->username); ?>
+                
+                        </div>
+                
+                        <div class="profile-usertitle-job">
+                
+                            <?php echo strtoupper($USER->role); ?>
+                
+                        </div>
+                
+                    </div>
+                
+                    <div id="buttonsDiv" class="profile-userbuttons">
+                
+                        <button id="editInfo" type="button" class="btn btn-primary text-uppercase waves waves-effect waves-float">Edit Info</button>
+                
+                        <button type="button" class="logout btn btn-warning waves waves-effect waves-float">Logout</button>
+                
+                    </div>
+                    
+                    <div id="editInfoDiv" style="display: none" class="profile-usertitle">
                          
-                <form class="content-form form-inline" name="update" id="update" action="" method="POST">
+                        <form class="content-form form-inline" name="update" id="update" action="" method="POST">
 
-                    <input type="hidden" name="op" value="update"/>
-                    <input type="hidden" name="sha1" value=""/>
-                    <input type="hidden" name="role" value="<?php echo $USER->role; ?>"/>
+                            <input type="hidden" name="op" value="update"/>
+                            <input type="hidden" name="sha1" value=""/>
+                            <input type="hidden" name="role" value="<?php echo $USER->role; ?>"/>
 
-                    <div class="form-group">
+                            <div class="form-group">
 
-                        <input autocomplete="off" type="text" value="<?php echo $USER->email; ?>" class="form-control" name="email" placeholder="E-mail Address">
+                                <input autocomplete="off" type="text" value="<?php echo $USER->email; ?>" class="form-control" name="email" placeholder="E-mail Address">
 
-                    </div>
+                            </div>
 
-                    <br><br>
+                            <div class="form-group">
 
-                    <div class="form-group">
+                                <input autocomplete="off" type="password" class="form-control" name="password1" placeholder="Password">
 
-                        <input autocomplete="off" type="password" class="form-control" name="password1" placeholder="Password">
+                            </div>
 
-                    </div>
+                            <div class="form-group">
 
-                    <br><br>
+                                <input autocomplete="off" type="password" class="form-control" name="password2" placeholder="Password Again">
 
-                    <div class="form-group">
+                            </div>
 
-                        <input autocomplete="off" type="password" class="form-control" name="password2" placeholder="Password Again">
+                            <br>
 
-                    </div>
+                            <div class="form-group">
 
-                    <br><br>
+                                <input type="button" class="btn btn-success text-uppercase waves-effect waves-float" value="Update" onclick="User.processUpdate()"/>
+                                
+                                <button id="goBackButtons" type="button" class="btn btn-primary text-uppercase waves waves-effect waves-float">Go Back</button>
 
-                    <div class="form-group">
+                            </div>
 
-                        <input type="button" class="btn btn-success text-uppercase waves-effect waves-float" value="Update" onclick="User.processUpdate()"/>
+                        </form>
 
                     </div>
-
-                </form> 
+                    
+                </div>
 
                 <?php endif;?>
-                
+
             </div>
 
         </div>
         <?php if(!$USER->authenticated) : ?>
         <div class="login-modal modal fade">
             
-            <div style="background:<?=$topbar;?>;" class="table-wrapper">
+            <div style="background:<?=$sidebar;?>;" class="table-wrapper">
                 
                 <div class="table-row">
                     
@@ -725,18 +761,22 @@ $userpic = md5( strtolower( trim( $USER->email ) ) );
                             
                             <div class="content-box">
                                 
-                                <div style="background:<?=$topbartext;?>;" class="biggest-box">
+                                <div style="background:<?=$topbar;?>;" class="biggest-box">
 
-                                    <h1 style="color:<?=$topbar;?>;" class="zero-m text-uppercase">Welcome</h1>
+                                    <h1 style="color:<?=$topbartext;?>;" class="zero-m text-uppercase">Welcome</h1>
 
                                 </div>
                                 
                                 <div class="big-box text-left login-form">
-                                    
-                                    <h4 class="text-center">Login</h4>
+
+                                    <?php if($USER->error!="") : ?>
+                                    <p class="error">Error: <?php echo $USER->error; ?></p>
+                                    <?php endif; ?>
                                     
                                     <form name="log in" id="login" action="" method="POST" data-smk-icon="glyphicon-remove-sign">
                                         
+                                        <h4 class="text-center">Login</h4>
+                                        
                                         <div class="form-group">
                                             
                                             <input type="hidden" name="op" value="login">
@@ -764,9 +804,26 @@ $userpic = md5( strtolower( trim( $USER->email ) ) );
 
                                         </div>
 
-                                        <button id="loginSubmit" style="background:<?=$topbartext;?>;" type="submit" class="btn btn-block btn-info text-uppercase waves" value="log in" onclick="User.processLogin()"><text style="color:<?=$topbar;?>;">Login</text></button>
+                                        <button id="loginSubmit" style="background:<?=$topbar;?>;" type="submit" class="btn btn-block btn-info text-uppercase waves" value="log in" onclick="User.processLogin()"><text style="color:<?=$topbartext;?>;">Login</text></button>
+
+                                    </form> 
+                                    
+                                    <button id="switchForgot" class="btn btn-block btn-info text-uppercase waves">Forgot Password</button>
+                                    
+                                    <form style="display: none;" name="forgotPassword" id="forgotPassword" action="" method="POST" data-smk-icon="glyphicon-remove-sign">
+                                        
+                                        <h4 class="text-center">Forgot Password</h4>
+                                        
+                                        <div class="form-group">
+                                            
+                                            <input type="hidden" name="op" value="reset">
+                                            <input type="text" class="form-control material" name="email" placeholder="E-mail" autocorrect="off" autocapitalize="off" value="" autofocus required>
+                                        
+                                        </div>
+
+                                        <button style="background:<?=$topbar;?>;" type="submit" class="btn btn-block btn-info text-uppercase waves" value="reset password"><text style="color:<?=$topbartext;?>;">Reset Password</text></button>
 
-                                    </form>                                   
+                                    </form> 
                                     
                                 </div>
                             
@@ -807,9 +864,9 @@ $userpic = md5( strtolower( trim( $USER->email ) ) );
 			
                                         <h3 style="color:<?=$topbar;?>;" class="zero-m text-uppercase">Do you want to logout?</h3>
                                         
-                                        <a style="color:<?=$topbar;?>;" href="#" id="logoutSubmit" class="i-block" data-dismiss="modal">Yes</a>
+                                        <a style="color:<?=$topbar;?>;" id="logoutSubmit" class="i-block" data-dismiss="modal">Yes</a>
                                         
-                                        <a style="color:<?=$topbar;?>;" href="#" class="i-block" data-dismiss="modal">No</a>
+                                        <a style="color:<?=$topbar;?>;" class="i-block" data-dismiss="modal">No</a>
                                 
                                     </form>
                                     
@@ -893,6 +950,28 @@ $userpic = md5( strtolower( trim( $USER->email ) ) );
             
         });
             
+        $("#editInfo").click(function(){
+
+            $( "div[id^='editInfoDiv']" ).toggle();
+            $( "div[id^='buttonsDiv']" ).toggle();
+     
+        });
+            
+        $("#goBackButtons").click(function(){
+
+            $( "div[id^='editInfoDiv']" ).toggle();
+            $( "div[id^='buttonsDiv']" ).toggle();
+     
+        });
+            
+        $("#switchForgot").click(function(){
+
+            $( "form[id^='login']" ).toggle();
+            $( "form[id^='forgotPassword']" ).toggle();
+            $("#switchForgot").toggle();
+     
+        });
+            
         //Sign in
         $(".log-in").click(function(e){
             
@@ -965,7 +1044,7 @@ $userpic = md5( strtolower( trim( $USER->email ) ) );
             
             if (defaultTab == null){
              
-                $( "div[id^='tabEmpty" ).show();
+                $("div[id^='tabEmpty']").show();
                 
             }
             
@@ -974,17 +1053,14 @@ $userpic = md5( strtolower( trim( $USER->email ) ) );
         }); 
             
         $(function () {
-            
+            <?php if(!empty($USER->info_log)) : ?>
             $.smkAlert({
                 position: 'top-left',
-                text: '<?php if(!empty($USER->info_log)) : 
-                    echo printArray($USER->info_log); 
-                    elseif(empty($USER->info_log)) :
-                    echo "Welcome Guest!";
-                    endif;?>',
+                text: '<?php echo printArray($USER->info_log);?>',
                 type: 'info'
                 
             });
+            <?php endif; ?>
             
             <?php if(!empty($USER->error_log)) : ?>
             $.smkAlert({
@@ -993,7 +1069,6 @@ $userpic = md5( strtolower( trim( $USER->email ) ) );
                 type: 'warning'
                 
             });
-            
             <?php endif; ?>
 
         });

File diff suppressed because it is too large
+ 124 - 67
settings.php


+ 31 - 16
user.php

@@ -28,7 +28,7 @@
 			// notification emails to work. Also note that password resetting doesn't work
 			// unless mail notification is turned on.
 
-			const use_mail = false;
+			const use_mail = true;
 
 			// This value should point to a directory that is not available to web users.
 			// If your documents are in ./public_html, for instance., then put database
@@ -77,14 +77,14 @@
 
 			// You'll probably want to change this to something sensible. If your site is
 			// www.sockmonkey.com, then you want this to be "sockmonkey.com"
-			const DOMAIN_NAME = "localhost";
+			const DOMAIN_NAME = "Organizr";
 
 			// This is going to be the "from" address
-			const MAILER_NAME = "noreply@localhost";
+			const MAILER_NAME = "noreply@organizr";
 
 			// if you want people to be able to reply to a real address, override
 			// this variable to "yourmail@somedomain.ext" here.
-			const MAILER_REPLYTO = "noreply@localhost";
+			const MAILER_REPLYTO = "noreply@organizr";
 
 		// =======================================================================
 		// 	Don't modify any variables beyond this point =)
@@ -355,7 +355,7 @@ EOT;
 
 			// step 1: someone could have bypassed the javascript validation, so validate again.
 			if(preg_match(User::emailregexp, $email)==0) {
-				$this->info("registration error: email address did not pass validation");
+				$this->info("email address did not pass validation");
 				return false; }
 
 			// step 2: if validation passed, see if there is a matching user, and reset the password if there is
@@ -373,6 +373,7 @@ EOT;
 			$dbpassword = $this->token_hash_password($username, $sha1, $token);
 			$update = "UPDATE users SET password = '$dbpassword' WHERE email= '$email'";
 			$this->database->exec($update);
+            $this->info("Email has been sent with new password");
 
 			// step 3: notify the user of the new password
 			$from = User::MAILER_NAME;
@@ -427,7 +428,7 @@ EOT;
 		{
 			$cleaned = $this->clean_SQLite_string($username);
 			$validated = ($cleaned != "" && $cleaned==$username);
-			if(!$validated) { $this->error = "user name did not pass validation."; }
+			if(!$validated) { $this->error = "user name did not pass validation."; $this->error("user name did not pass validation."); }
 			return $validated;
 		}
 
@@ -464,6 +465,10 @@ EOT;
                 }else{
                     
                     $this->error("cookie token mismatch for $username");
+                    unset($_COOKIE['Organizr']);
+                    setcookie('Organizr', '', time() - 3600, '/');
+                    unset($_COOKIE['OrganizrU']);
+                    setcookie('OrganizrU', '', time() - 3600, '/');
                     return false;
                     
                 }
@@ -538,6 +543,7 @@ EOT;
 				foreach($this->database->query($query) as $data) {
 					$this->info("user account for $username not created.");
 					$this->error = "this user name is already being used by someone else.";
+                    $this->error("this user name is already being used by someone else.");
 					return false; }}
 			else{	$query = "SELECT username FROM users";
 				$usernames = array();
@@ -545,6 +551,7 @@ EOT;
 				if(in_array($this->homogenise_username($username), $usernames)) {
 					$this->info("user account for $username not created.");
 					$this->error = "this user name is not allowed, because it is too similar to other user names.";
+                    $this->error("this user name is not allowed, because it is too similar to other user names.");
 					return false; }}
 
 			// Is email address already in use? (see notes on safe reporting)
@@ -552,11 +559,12 @@ EOT;
 			foreach($this->database->query($query) as $data) {
 				$this->info("user account for $username not created.");
 				$this->error = "this email address is already in use by someone else.";
+                $this->error("this email address is already in use by someone else.");
 				return false; }
 
 			// This user can be registered
 			$insert = "INSERT INTO users (username, email, password, token, role, active, last) ";
-			$insert .= "VALUES ('$username', '$email', '$dbpassword', '', '$newRole', 'true', '" . time() . "') ";
+			$insert .= "VALUES ('$username', '$email', '$dbpassword', '', '$newRole', 'false', '') ";
 			$this->database->exec($insert);
 			$query = "SELECT * FROM users WHERE username = '$username'";
 			foreach($this->database->query($query) as $data) {
@@ -570,6 +578,7 @@ EOT;
 				if($registration_callback !== false) { $registration_callback($username, $email, $dir); }
 				return true; }
 			$this->error = "unknown database error occured.";
+            $this->error("unknown database error occured.");
 			return false;
 		}
 
@@ -593,21 +602,24 @@ EOT;
 					$this->setSession($username, $this->update_user_token($username, $sha1, false));
 					// authentication passed - 2) signal authenticated
                     if($remember == "true") {
-                        setcookie("Organizr", $this->update_user_token($username, $sha1, true), time() + (86400 * 7), "/");
+                        setcookie("Organizr", $this->get_user_token($username), time() + (86400 * 7), "/");
                         setcookie("OrganizrU", $username, time() + (86400 * 7), "/");
                         
                     }
-					return true; }
+					$this->info("Welcome $username");
+                    return true; 
+                    
+                }
 				// authentication failed
 				$this->info("password mismatch for $username");
-				if(User::unsafe_reporting) { $this->error = "incorrect password for $username."; }
-				else { $this->error = "the specified username/password combination is incorrect."; }
+				if(User::unsafe_reporting) { $this->error = "incorrect password for $username."; $this->error("incorrect password for $username."); }
+				else { $this->error = "the specified username/password combination is incorrect."; $this->error("the specified username/password combination is incorrect."); }
 				return false; }
 
 			// authentication could not take place
 			$this->info("there was no user $username in the database");
-			if(User::unsafe_reporting) { $this->error = "user $username is unknown."; }
-			else { $this->error = "you either did not correctly input your username, or password (... or both)."; }
+			if(User::unsafe_reporting) { $this->error = "user $username is unknown."; $this->error("user $username is unknown."); }
+			else { $this->error = "you either did not correctly input your username, or password (... or both)."; $this->error("you either did not correctly input your username, or password (... or both)."); }
 			return false;
 		}
 
@@ -653,8 +665,11 @@ EOT;
 		{
 			$delete = "DELETE FROM users WHERE username = '$username'";
 			$this->database->exec($delete);
-			$this->info("removed $username from the system");
+			$this->info("removed $username from the Organizr");
 			//$this->resetSession();
+            $dir = USER_HOME . $username;
+            if(!rmdir($dir)) { $this->error("could not delete user directory $dir"); }
+            $this->info("deleted user directory $dir");
 			return true;
 		}
 
@@ -727,7 +742,7 @@ EOT;
 		{
 			$update = "UPDATE users SET active = 'true', last = '" . time() . "' WHERE username = '$username'";
 			$this->database->exec($update);
-			$this->info("$username has been marked currently active.");
+			//$this->info("$username has been marked currently active.");
 			return true;
 		}
 
@@ -750,7 +765,7 @@ EOT;
 					$this->logout_user($username);
 					$this->error("$username was active but timed out (timeout set at " . User::time_out . " seconds, difference was $diff seconds)");
 					return false; }
-				$this->info("$username is active");
+				//$this->info("$username is active");
 				return true; }
 
 			$this->error("$username is not active");

Some files were not shown because too many files changed in this diff