password expiry :issue no 1597
This commit is contained in:
parent
61081c10cf
commit
911fdb2353
@ -121,6 +121,8 @@ $route['updateActivityDetails'] = 'University_Controller/updateActivityDetails';
|
||||
|
||||
$route['changePassword'] = 'Login_Controller/changePassword';
|
||||
|
||||
$route['changePasswordLogin'] = 'Login_Controller/changePasswordLogin';
|
||||
|
||||
// student
|
||||
$route['insertStudent'] = 'Student_Controller/addStudent';
|
||||
$route['getStudentUniversity'] = 'Student_Controller/getStudentUniversity';
|
||||
|
||||
@ -162,10 +162,37 @@ class Login_Controller extends REST_Controller {
|
||||
'message' => 'No users were found',
|
||||
'status' => REST_Controller::HTTP_NOT_FOUND
|
||||
], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function changePasswordLogin_post()
|
||||
{
|
||||
$updata['emp_Ph'] = $this->post('UserId');
|
||||
$updata['oldPassword'] = $this->post('oldPassword');
|
||||
$updata['newPassword'] = $this->post('newPassword');
|
||||
$date = date('Y-m-d');
|
||||
$updata['Password_Date'] = $date;
|
||||
|
||||
$updatepassword = $this->login_model->UpdateLoginPassword($updata);
|
||||
if ($updatepassword)
|
||||
{
|
||||
$updatepassword['status'] = REST_Controller::HTTP_OK;
|
||||
// Set the response and exit
|
||||
$this->response($updatepassword, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code
|
||||
}
|
||||
else
|
||||
{
|
||||
// Set the response and exit
|
||||
$this->response([
|
||||
'message' => 'No users were found',
|
||||
'status' => REST_Controller::HTTP_NOT_FOUND
|
||||
], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
|
||||
}
|
||||
|
||||
|
||||
|
||||
//print_r($updata);
|
||||
}
|
||||
}
|
||||
|
||||
@ -370,6 +370,9 @@ class Employee_model extends CI_Model
|
||||
public function add_employee($empArr, $createdBy, $imageName, $imageSource, $imageSize)
|
||||
{
|
||||
//print_r($empArr);exit();
|
||||
|
||||
$time = date('Y-m-d');
|
||||
$dateTime = $time;
|
||||
if( $imageSource == '') { // add employee without image
|
||||
$imageNameDb = 'default.jpeg';
|
||||
$empArr['ProfilePicPath'] = "employee/".$imageNameDb;
|
||||
@ -393,6 +396,7 @@ class Employee_model extends CI_Model
|
||||
$loginArr['EmailId'] = $empArr['EmailID'];
|
||||
$loginArr['IsActive'] = $empArr['IsActive'];
|
||||
$loginArr['CreatedBy'] = $createdBy;
|
||||
$loginArr['Password_Date']= $dateTime;
|
||||
$loginArr['Password'] = ENCR_PASSWORD;
|
||||
$this->db->insert(LOGIN, $loginArr);
|
||||
if ($this->db->affected_rows() == '1') {
|
||||
|
||||
@ -150,7 +150,44 @@ class Login_model extends CI_Model
|
||||
$this->db->where('IsActive','1');
|
||||
$details = $this->db->get()->first_row();
|
||||
|
||||
//print_r($details);
|
||||
// print_r($details);die();
|
||||
|
||||
$time = date('Y-m-d');
|
||||
$dateTime = $time;
|
||||
|
||||
$password_date = new DateTime($details->Password_Date);
|
||||
$today_date = new DateTime($dateTime);
|
||||
$diff=date_diff($password_date,$today_date);
|
||||
|
||||
// echo $diff->format("%R%a days");
|
||||
|
||||
// $datediff = $diff->format("%d days");
|
||||
|
||||
//echo $datediff;
|
||||
|
||||
|
||||
$start = strtotime($details->Password_Date);
|
||||
$end = strtotime($dateTime);
|
||||
|
||||
$days_between = ceil(abs($end - $start) / 86400);
|
||||
|
||||
|
||||
|
||||
if(!empty($details))
|
||||
{
|
||||
|
||||
if($days_between>'+30')
|
||||
{
|
||||
|
||||
$result['loginStatus'] =false;
|
||||
$result['passwordStatus'] =false;
|
||||
$result['message'] = "Please Change the Password !!";
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
// echo 'invalid';
|
||||
|
||||
if($details)
|
||||
{
|
||||
|
||||
@ -192,6 +229,10 @@ class Login_model extends CI_Model
|
||||
$result['loginStatus'] =true;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
$result['pwdcheck']=false;
|
||||
@ -205,6 +246,8 @@ class Login_model extends CI_Model
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/// die();
|
||||
// print_r($loginDetails);die();
|
||||
|
||||
@ -276,6 +319,40 @@ class Login_model extends CI_Model
|
||||
if ($password == $loginDetails->Password) {
|
||||
/// echo 'SUPER_ADMIN';die();
|
||||
|
||||
|
||||
|
||||
$this->db->select('*');
|
||||
$this->db->from('T_Login');
|
||||
$this->db->where('MobileNumber',$mobile);
|
||||
$this->db->where('Password',$password);
|
||||
$this->db->where('IsActive','1');
|
||||
$details = $this->db->get()->first_row();
|
||||
|
||||
$time = date('Y-m-d');
|
||||
$dateTime = $time;
|
||||
|
||||
$password_date = new DateTime($details->Password_Date);
|
||||
$today_date = new DateTime($dateTime);
|
||||
$diff=date_diff($password_date,$today_date);
|
||||
$start = strtotime($details->Password_Date);
|
||||
$end = strtotime($dateTime);
|
||||
|
||||
$days_between = ceil(abs($end - $start) / 86400);
|
||||
|
||||
if($days_between>'+30')
|
||||
{
|
||||
|
||||
$result['loginStatus'] =false;
|
||||
$result['passwordStatus'] =false;
|
||||
$result['message'] = "Please Change the Password !!";
|
||||
}
|
||||
|
||||
|
||||
else
|
||||
{
|
||||
|
||||
|
||||
|
||||
$superadminpwd= md5($password);
|
||||
|
||||
$this->db->select('t1.MobileNumber, t1.ListCode, t1.ID, t2.BranchCode, t2.FinanceModuleAccess,t2.CallModuleAccess');
|
||||
@ -325,6 +402,19 @@ class Login_model extends CI_Model
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
else
|
||||
{
|
||||
$result['loginStatus'] = false;
|
||||
@ -442,7 +532,11 @@ class Login_model extends CI_Model
|
||||
$this->db->where('ID', $userId);
|
||||
$loginDetails = $this->db->get()->first_row();
|
||||
if ($loginDetails->Password == $oldPassword) {
|
||||
$sql = "UPDATE ".LOGIN." SET Password='$newPassword', UpdatedBy='$userId', UpdatedOn='$updateOn' WHERE ID='$userId'";
|
||||
|
||||
$date = date('Y-m-d');
|
||||
$Password_Date = $date;
|
||||
|
||||
$sql = "UPDATE ".LOGIN." SET Password='$newPassword', UpdatedBy='$userId', UpdatedOn='$updateOn',Password_Date='$Password_Date' WHERE ID='$userId'";
|
||||
if($this->db->query($sql) == '1'){
|
||||
$result['changePassStatus'] = true;
|
||||
$result['message'] = "Your Password Successfully changed !!";
|
||||
@ -700,6 +794,47 @@ $this->db->insert_batch('T_BroadcastStatus', $data);
|
||||
|
||||
|
||||
|
||||
public function UpdateLoginPassword($updata)
|
||||
{
|
||||
$this->db->select('*');
|
||||
$this->db->from('T_Login');
|
||||
$this->db->where('MobileNumber',$updata['emp_Ph']);
|
||||
$this->db->where('Password',$updata['oldPassword']);
|
||||
$searchDetails = $this->db->get();
|
||||
|
||||
$details = $searchDetails->result();
|
||||
|
||||
//print_r($details);
|
||||
|
||||
if($details)
|
||||
{
|
||||
|
||||
//$data['MobileNumber'] = $updata['emp_Ph'];
|
||||
$data['Password'] = $updata['newPassword'];
|
||||
$data['Password_Date'] = $updata['Password_Date'];
|
||||
$this->db->where('MobileNumber', $updata['emp_Ph']);
|
||||
//$this->db->where('Password',$updata['oldPassword']);
|
||||
$this->db->update(LOGIN, $data);
|
||||
|
||||
|
||||
$result['updateStatus'] = true;
|
||||
$result['message'] = "Updated Successfully.";
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
|
||||
$result['updateStatus'] = false;
|
||||
$result['message'] = "Please Enter Correct Correct Details.";
|
||||
}
|
||||
|
||||
return $result;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -139,7 +139,8 @@
|
||||
"LOGIN": "Login",
|
||||
"REGISTRATION": "Registration",
|
||||
"FORGOT": "Forgot Password",
|
||||
"LOCKSCREEN": "Lock Screen"
|
||||
"LOCKSCREEN": "Lock Screen",
|
||||
"Login_pwdchange":"Login_pwdchange"
|
||||
},
|
||||
"tracking": {
|
||||
"MAIN": "CALL TRACKING",
|
||||
|
||||
@ -69,6 +69,8 @@ app.constant('JS_REQUIRES', {
|
||||
|
||||
'changePasswordCtrl': 'assets/js/controllers/changePasswordCtrl.js',
|
||||
|
||||
'change_loginpwdCtrl': 'assets/js/controllers/change_loginpwdCtrl.js',
|
||||
|
||||
/***
|
||||
* Session
|
||||
*/
|
||||
|
||||
@ -44,6 +44,10 @@ app.config(['$stateProvider', '$urlRouterProvider', '$controllerProvider', '$com
|
||||
url: '/signin',
|
||||
templateUrl: "assets/views/login_login.html",
|
||||
resolve: loadSequence('loginCtrl')
|
||||
}).state('login.Login_pwdchange', {
|
||||
url: '/Login_pwdchange',
|
||||
templateUrl: "assets/views/changelogin_password.html",
|
||||
resolve: loadSequence('change_loginpwdCtrl')
|
||||
}).state('login.forgot', {
|
||||
url: '/forgot',
|
||||
templateUrl: "assets/views/login_forgot.html",
|
||||
|
||||
6
Apollo/assets/js/controllers/change_loginpwdCtrl.js
Normal file
6
Apollo/assets/js/controllers/change_loginpwdCtrl.js
Normal file
@ -0,0 +1,6 @@
|
||||
'use strict';
|
||||
/*** controller for Wizard Form example***/
|
||||
app.controller('change_loginpwdCtrl', ["$scope", "$filter", "ngTableParams", "API_POINTS", "$http", "SweetAlert", "$state", 'md5', 'ipCookie', function ($scope, $filter, ngTableParams, apiPoint, $http, SweetAlert, $state, md5, ipCookie) {
|
||||
|
||||
|
||||
}]);
|
||||
@ -71,6 +71,8 @@ app.controller('loginCtrl', ["$scope", "$http", "API_POINTS", "$state", '$rootSc
|
||||
}
|
||||
};
|
||||
$http(req).then(function (response) {
|
||||
// console.log(response.data);return false;
|
||||
|
||||
if (response.data.loginStatus == true) {
|
||||
|
||||
|
||||
@ -118,12 +120,24 @@ app.controller('loginCtrl', ["$scope", "$http", "API_POINTS", "$state", '$rootSc
|
||||
else{
|
||||
// $window.location.reload();
|
||||
$state.go('app.dashboard');
|
||||
|
||||
//$state.go('login.Login_pwdchange');
|
||||
// $window.location.reload();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
}
|
||||
else if((response.data.loginStatus == false) &&(response.data.passwordStatus==false))
|
||||
{
|
||||
console.log('else if')
|
||||
|
||||
$state.go('login.Login_pwdchange');
|
||||
}
|
||||
|
||||
|
||||
|
||||
else {
|
||||
// alert(response.data.message);
|
||||
if($scope.Empcheck == false)
|
||||
{
|
||||
@ -320,4 +334,81 @@ $scope.EmpLogin=function(myModel)
|
||||
});
|
||||
}
|
||||
}
|
||||
}]);
|
||||
|
||||
|
||||
$scope.myPwdModel = {
|
||||
curr: "",
|
||||
newpassword: "",
|
||||
empid:""
|
||||
};
|
||||
|
||||
|
||||
$scope.ChangePassword = function (Form,myPwdModel)
|
||||
{
|
||||
var userId = myPwdModel.empid;
|
||||
var oldPassword = myPwdModel.curr;
|
||||
var newPassword = myPwdModel.newpassword
|
||||
//var passwordLength = newPassword.length;
|
||||
|
||||
//console.log(passwordLength)
|
||||
if((userId == undefined)||(oldPassword =="")||(oldPassword == undefined)||(newPassword == undefined))
|
||||
{
|
||||
|
||||
swal("Please Enter all the Fields, New Password Should Consist 8 letters!", "", "warning");
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
var req = {
|
||||
method: 'POST',
|
||||
url: apiPoint.url + 'changePasswordLogin/',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
data: {
|
||||
oldPassword: md5.createHash(oldPassword || ''),
|
||||
newPassword: md5.createHash(newPassword || '') ,
|
||||
UserId: userId,
|
||||
}
|
||||
};
|
||||
|
||||
$http(req).then(function (response) {
|
||||
|
||||
console.log(response.data)
|
||||
if (response.data.changePassStatus == true)
|
||||
{
|
||||
swal(" Success", message, "success");
|
||||
form.$setPristine(true);
|
||||
$scope.myModel = {
|
||||
curr: "",
|
||||
password1: "",
|
||||
password2: ""
|
||||
};
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
swal("Error",response.data.message, "error");
|
||||
}
|
||||
|
||||
|
||||
},
|
||||
function (error) {
|
||||
//error function
|
||||
});
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}]);
|
||||
|
||||
|
||||
|
||||
|
||||
@ -81,7 +81,7 @@ app.controller('sessionCtrl', ["$scope", "$localStorage", "$state", 'ipCookie',
|
||||
let remTime = Math.floor((dateNowTime-lastActiveTime)/ 1000);
|
||||
idletime = remTime;
|
||||
// converting from milliseconds to seconds
|
||||
// console.log("Idle since "+remTime+" Seconds Last active at "+this.lastActiveTime);
|
||||
console.log("Idle since "+remTime+" Seconds Last active at "+this.lastActiveTime);
|
||||
if(remTime>'10800')
|
||||
{
|
||||
console.log('inremtime')
|
||||
|
||||
72
Apollo/assets/views/changelogin_password.html
Normal file
72
Apollo/assets/views/changelogin_password.html
Normal file
@ -0,0 +1,72 @@
|
||||
<section id="page-title">
|
||||
<div class="row">
|
||||
<div class="col-sm-8">
|
||||
<h1 class="mainTitle" style="color:red;">Your Password Expired!! Please Change Password</h1>
|
||||
</div>
|
||||
<!-- <div ncy-breadcrumb></div>-->
|
||||
</div>
|
||||
</section>
|
||||
|
||||
|
||||
<div ng-controller="loginCtrl" class="container-fluid container-fullw bg-white">
|
||||
<div class="row">
|
||||
<div class="col-md-8">
|
||||
<div>
|
||||
<form name="Form" id="form" novalidate>
|
||||
<div id="wizard" class="swMain">
|
||||
<div id="step-1">
|
||||
<div class="row">
|
||||
<div class="col-md-5">
|
||||
|
||||
</div>
|
||||
<div class="col-md-7">
|
||||
<fieldset>
|
||||
<legend>Change Password</legend>
|
||||
<div class="row">
|
||||
|
||||
<div class="form-group">
|
||||
<label class="control-label">EMP ID/Phone Number <span class="symbol required"></span></label>
|
||||
|
||||
<input type="text" placeholder="Enter EMPID/Phone number" class="form-control" name="empid" ng-model="myPwdModel.empid"
|
||||
required/>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>Current Password <span class="symbol required"></span></label>
|
||||
<input type="password" placeholder="Enter Current Password" class="form-control" name="passwords" ng-model="myPwdModel.curr"
|
||||
required/>
|
||||
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label">New Password <span class="symbol required"></span></label>
|
||||
<input type="password" placeholder="Enter new Password" class="form-control" name="password1" ng-model="myPwdModel.newpassword"
|
||||
required/>
|
||||
|
||||
</div>
|
||||
|
||||
<!-- <div class="form-group">
|
||||
<label class="control-label">Confirm New Password <span class="symbol required"></span></label>
|
||||
<input type="password" placeholder="Confirm Password" class="form-control" name="password2" ng-model="myPwdModel.password2"
|
||||
compare-to="myPwdModel.password" required/>
|
||||
|
||||
</div> -->
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div class="pull-right">
|
||||
<button type="submit" ng-click="ChangePassword(Form,myPwdModel);" class="btn btn-success btn-o">Submit</button>
|
||||
|
||||
</div>
|
||||
|
||||
</fieldset>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
Loading…
Reference in New Issue
Block a user