login page change

This commit is contained in:
venbatechnologies@gmail.com 2019-02-08 17:04:47 +05:30
parent f4fd16470c
commit e51ae24fb4
5 changed files with 365 additions and 76 deletions

View File

@ -188,6 +188,9 @@ $route['filterYear'] = 'Dashboard_Controller/filterYear';
/*login page announcement*/
$route['getLoginAnnouncementDetails'] = 'Login_Controller/getLoginAnnouncementDetails';
$route['VerifyEmpOTP'] = 'Login_Controller/VerifyEmpOTP';
/* status */
$route['addStatusDetails'] = 'Status_Controller/addStatusDetails';
$route['getStatusDetails'] = 'Status_Controller/getStatusDetails';

View File

@ -139,5 +139,33 @@ class Login_Controller extends REST_Controller {
], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code
}
}
public function VerifyEmpOTP_post()
{
$EmpID = $this->post('EmpID');
$OTP = $this->post('OTP');
$Password = $this->post('Password');
$getstudent = $this->login_model->Emplogin($EmpID,$OTP,$Password);
if ($getstudent)
{
$getstudent['status'] = REST_Controller::HTTP_OK;
// Set the response and exit
$this->response($getstudent, 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
}
}
}

View File

@ -32,7 +32,7 @@ class Login_model extends CI_Model
$loginDetails = $this->db->get(LOGIN)->first_row();
// print_r($this->db->last_query());die();
// print_r($loginDetails);
//print_r($loginDetails);die();
if($loginDetails) {
$mobileno= $loginDetails->MobileNumber;
@ -140,66 +140,131 @@ class Login_model extends CI_Model
//echo 'NO_SUPER_ADMIN';die();
if ($mobile == $loginDetails->MobileNumber || strtoupper($mobile) == strtoupper($loginDetails->StaffID))
{
//echo 'no _if';die();
// echo $mobile;
// echo $password;
$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();
//print_r($details);
if($details)
{
$this->db->select('MobileNumber');
$this->db->from('T_StaffDetails');
$this->db->where('StaffID',$loginDetails->StaffID);
$searchDetails = $this->db->get();
// print_r($searchDetails->result());die();
$contact ='';
foreach($searchDetails->result() as $mo)
{
$contact = $mo->MobileNumber;
}
$string2 = str_shuffle('1234567890');
$otp = substr($string2,0,6);
//$otp = '431528';
$save['OTP'] = $otp;
$save['UpdatedOn'] = date('Y-m-d H:i:s');
$this->db->where('MobileNumber',$mobile);
$query = $this->db->update('T_Login',$save);
$mobileno = $contact;
if($query == 1)
{
$sms = $this->smssend($mobileno,$otp);
}
$result['details'] = 'role check';
$result['pwdcheck']=true;
$result['loginemployee']=true;
$result['loginStatus'] =true;
}
else
{
$result['pwdcheck']=false;
$result['loginemployee']=false;
$result['loginStatus'] =false;
$result['message'] = "Please Check the Password !!";
}
/// die();
// print_r($loginDetails);die();
$this->db->select('LO.MobileNumber, LO.ListCode, LO.ID, ST.IsActive,LO.StaffID,ST.BranchCode,SC.CallModuleAccess,SC.FinanceModuleAccess');
$this->db->from('' . LOGIN . ' as LO');
$this->db->join('' . STAFF . ' as ST', 'LO.StaffID = ST.StaffID');
$this->db->join('' . STAFF_BRANCH . ' as SC', 'SC.StaffID = ST.StaffID');
$this->db->join('' . BRANCH . ' as BR', 'BR.BranchCode = SC.BranchCode');
$this->db->where('LO.MobileNumber', $mobile);
$this->db->where('LO.OTP',$password);
$this->db->where('ST.IsActive', 1);
// $this->db->where('BR.Is_StudentWebAccessActive', 1);
$responseDetails = $this->db->get()->first_row();
// $this->db->select('LO.MobileNumber, LO.ListCode, LO.ID, ST.IsActive,LO.StaffID,ST.BranchCode,SC.CallModuleAccess,SC.FinanceModuleAccess');
// $this->db->from('' . LOGIN . ' as LO');
// $this->db->join('' . STAFF . ' as ST', 'LO.StaffID = ST.StaffID');
// $this->db->join('' . STAFF_BRANCH . ' as SC', 'SC.StaffID = ST.StaffID');
// $this->db->join('' . BRANCH . ' as BR', 'BR.BranchCode = SC.BranchCode');
// $this->db->where('LO.MobileNumber', $mobile);
// $this->db->where('LO.OTP',$password);
// $this->db->where('ST.IsActive', 1);
// // $this->db->where('BR.Is_StudentWebAccessActive', 1);
// $responseDetails = $this->db->get()->first_row();
// print_r($responseDetails);die();
// // print_r($responseDetails);die();
//print_r($this->db->last_query());die();
// //print_r($this->db->last_query());die();
if($responseDetails)
{
// if($responseDetails)
// {
$save['OTP'] = '';
$this->db->where('MobileNumber',$mobile);
$this->db->where('StaffID',$mobile);
// $this->db->where('ListCode',ADMIN);
// $this->db->or_where('ListCode',EMPLOYEE);
// $this->db->or_where('ListCode',TRAINEE);
$this->db->update('T_Login',$save);//print_r($this->db->last_query());die();
if($responseDetails->IsActive == 1)
{
$result['loginStatus'] = true;
$result['details'] = $responseDetails;
}
else
{
$result['loginStatus'] = false;
$result['loginemployee'] = false;
$result['checkemp'] = false;
$result['message'] = "Please Enter The Correct OTP.";
}
}
// $save['OTP'] = '';
// $this->db->where('MobileNumber',$mobile);
// $this->db->where('StaffID',$mobile);
// // $this->db->where('ListCode',ADMIN);
// // $this->db->or_where('ListCode',EMPLOYEE);
// // $this->db->or_where('ListCode',TRAINEE);
// $this->db->update('T_Login',$save);//print_r($this->db->last_query());die();
// if($responseDetails->IsActive == 1)
// {
// $result['loginStatus'] = true;
// $result['details'] = $responseDetails;
// }
// else
// {
// $result['loginStatus'] = false;
// $result['loginemployee'] = false;
// $result['checkemp'] = false;
// $result['message'] = "Please Enter The Correct OTP.";
// }
// }
else
{
$result['loginStatus'] = false;
$result['loginemployee'] = false;
$result['checkemp'] = false;
$result['message'] = "Please Enter The Correct OTP.";
}
// else
// {
// $result['loginStatus'] = false;
// $result['loginemployee'] = false;
// $result['checkemp'] = false;
// $result['message'] = "Please Enter The Correct OTP.";
// }
}
// }
else
{ // echo 'no _else';die();
$result['loginStatus'] = false;
$result['loginemployee'] = false;
$result['checkemp'] = false;
$result['message'] = "Please Enter Register Mobile Number !!";
// else
// { // echo 'no _else';die();
// $result['loginStatus'] = false;
// $result['loginemployee'] = false;
// $result['checkemp'] = false;
// $result['message'] = "Please Enter Register Mobile Number !!";
}
}
@ -294,6 +359,83 @@ class Login_model extends CI_Model
}
public function Emplogin($EmpID,$OTP,$Password)
{
$this->db->select('MobileNumber');
$this->db->from('T_StaffDetails');
$this->db->where('StaffID',$EmpID);
$searchDetails = $this->db->get();
// print_r($searchDetails->result());die();
$contact ='';
foreach($searchDetails->result() as $mo)
{
$contact = $mo->MobileNumber;
}
$this->db->select('LO.MobileNumber, LO.ListCode, LO.ID, ST.IsActive,LO.StaffID,ST.BranchCode,SC.CallModuleAccess,SC.FinanceModuleAccess');
$this->db->from('' . LOGIN . ' as LO');
$this->db->join('' . STAFF . ' as ST', 'LO.StaffID = ST.StaffID');
$this->db->join('' . STAFF_BRANCH . ' as SC', 'SC.StaffID = ST.StaffID');
$this->db->join('' . BRANCH . ' as BR', 'BR.BranchCode = SC.BranchCode');
$this->db->where('LO.MobileNumber', $EmpID);
$this->db->where('LO.OTP',$OTP);
$this->db->where('LO.Password',$Password);
$this->db->where('ST.IsActive', 1);
// $this->db->where('BR.Is_StudentWebAccessActive', 1);
$responseDetails = $this->db->get()->first_row();
// print_r($responseDetails);die();
//print_r($this->db->last_query());die();
if($responseDetails)
{
$save['OTP'] = '';
$this->db->where('MobileNumber',$EmpID);
$this->db->where('StaffID',$EmpID);
$this->db->update('T_Login',$save);
if($responseDetails->IsActive == 1)
{
$result['loginStatus'] = true;
$result['details'] = $responseDetails;
}
else
{
$result['loginStatus'] = false;
$result['loginemployee'] = false;
$result['checkemp'] = false;
$result['message'] = "Please Enter The Correct OTP.";
}
}
else
{
$result['loginStatus'] = false;
$result['loginemployee'] = false;
$result['checkemp'] = false;
$result['message'] = "Please Enter The Correct OTP.";
}
return $result;
//}
}
public function change_Password( $userId, $newPassword, $oldPassword, $updateOn) {
$this->db->select('Password');
$this->db->from(LOGIN);

View File

@ -11,7 +11,8 @@ app.controller('loginCtrl', ["$scope", "$http", "API_POINTS", "$state", '$rootSc
*/
$scope.myModel = {
'userMobile': '',
'password': ''
'password': '',
'passwordemp':''
};
$scope.typeInput = 'password';
@ -23,11 +24,16 @@ app.controller('loginCtrl', ["$scope", "$http", "API_POINTS", "$state", '$rootSc
$scope.responseData = '';
$scope.form = {
submit: function (form) {
// $scope.form = {
$scope.Login=function(myModel)
{
// alert($scope.Empcheck);
//alert('in');return false;
var firstError = null;
if (form.$invalid) {
var field = null, firstError = null;
@ -64,11 +70,25 @@ app.controller('loginCtrl', ["$scope", "$http", "API_POINTS", "$state", '$rootSc
};
$http(req).then(function (response) {
if (response.data.loginStatus == true) {
$scope.responseData = response.data.details;
//console.log($scope.responseData)
if($scope.responseData == 'role check')
{
$scope.Empcheck = true;
swal("Your OTP is sent !", response.data.message);
}
/*
* After logined user details store to local client detail
*/
else
{
var localDateTime = new Date();
$scope.localStore = {
"localUserID": $scope.responseData.ID,
@ -87,12 +107,19 @@ app.controller('loginCtrl', ["$scope", "$http", "API_POINTS", "$state", '$rootSc
if($scope.responseData.ListCode=='R001'){
$state.go('app.studentView');
}
else if($scope.responseData.ListCode !='R004')
{
console.log('in')
}
else{
// $window.location.reload();
$state.go('app.dashboard');
// $window.location.reload();
}
}
} else {
// alert(response.data.message);
if($scope.Empcheck == false)
@ -110,12 +137,12 @@ app.controller('loginCtrl', ["$scope", "$http", "API_POINTS", "$state", '$rootSc
}
});
}
},
reset: function (form) {
$scope.myModel = angular.copy($scope.master);
form.$setPristine(true);
}
}
// reset: function (form) {
// $scope.myModel = angular.copy($scope.master);
// form.$setPristine(true);
// }
//}
$scope.myInterval = 2000; // load when html page load
@ -141,6 +168,64 @@ app.controller('loginCtrl', ["$scope", "$http", "API_POINTS", "$state", '$rootSc
}
});
}
$scope.EmpLogin=function(myModel)
{
//console.log(myModel)
var empid= myModel.userMobile;
var password = myModel.password;
var otp = myModel.passwordemp;
var md5password = md5.createHash(password);
var verify = {
method: 'POST',
url: apiPoint.url + 'VerifyEmpOTP/',
headers: { 'Content-Type': 'application/json' },
data: {EmpID:empid,Password:md5password,OTP:otp}
};
$http(verify).then(function (response)
{
if (response.data.loginStatus == true)
{
if (response.data.loginStatus == true)
{
$scope.responseData = response.data.details;
var localDateTime = new Date();
$scope.localStore = {
"localUserID": $scope.responseData.ID,
"localBranchID": $scope.responseData.BranchCode,
'localType': $scope.responseData.ListCode,
'is_DayBookApproval_Access': $scope.responseData.FinanceModuleAccess,
'is_CalltrackApproval_Access': $scope.responseData.CallModuleAccess,
'localOn': localDateTime,
'status': 'active'
}
ipCookie('cookiechk', $scope.localStore, { expires: 21 });
localStorage.setItem('localObj', JSON.stringify($scope.localStore));
$state.go('app.dashboard');
}
}
});
}
/**
* Checkstudent change function *
* created_by : sriram
@ -149,10 +234,7 @@ app.controller('loginCtrl', ["$scope", "$http", "API_POINTS", "$state", '$rootSc
$scope.Empcheck = false;
$scope.OTP_or_PWD = 0;
$scope.checkMobileNumber = function (MobileNumber) {
//alert($scope.myModel.userMobile);
// var studentNumber = $scope.myModel.userMobile;
// alert(MobileNumber);
$scope.OTP_or_PWD = MobileNumber;
@ -173,7 +255,7 @@ app.controller('loginCtrl', ["$scope", "$http", "API_POINTS", "$state", '$rootSc
$http(req).then(function(response){
//alert(otpcheck);
console.log(response)
//console.log(response)
if(otpcheck == undefined)
{
swal.close();
@ -189,15 +271,15 @@ console.log(response)
$scope.info = true;
}
else if(response.data.checkemp== true)
else if(response.data.pwdcheck== true)
{
// console.log('in');
console.log('in');
$scope.Empcheck = true;
$scope.typeInput = 'text';
$scope.place = 'OTP';
$scope.icon = 'fa fa-key';
$scope.info = false;
// $scope.Empcheck = true;
//$scope.typeInput = 'text';
//$scope.place = 'OTP';
//$scope.icon = 'fa fa-key';
//$scope.info = false;
}
else

View File

@ -381,7 +381,7 @@
<!--
<div class="form-group" ng-class="{'has-error':Form.passwordemp.$dirty && Form.passwordemp.$invalid, 'has-success':Form.passwordemp.$valid}" ng-if="Empcheck">
<span class="input-icon">
@ -396,7 +396,7 @@
<button class="btn btn-success" ng-click="checkMobileNumber(1);" tabindex="8">
Generate OTP
</button>
</div>
</div> -->
@ -404,7 +404,7 @@
<div class="form-group" ng-class="{'has-error':Form.password.$dirty && Form.password.$invalid, 'has-success':Form.password.$valid}">
<span class="input-icon">
<input type="{{typeInput}}" id="inputPassword3" placeholder="{{place}}" class="form-control heighLight underline" name="password" ng-model="myModel.password"
<input type="password" id="inputPassword3" placeholder="Password" class="form-control heighLight underline" name="password" ng-model="myModel.password"
ng-minlength="6" required/>
<i style="color: black;" class="{{icon}}"></i>
<span class="error text-small block" ng-if="Form.password.$dirty && Form.password.$invalid"> {{place}} Required</span></span>
@ -413,10 +413,44 @@
<div class="form-group">
<span ng-if="info == false"><a class="forgot" ui-sref="login.forgot" style="color: black;">I forgot my password </a></span>
<span ng-if="info != false" style="color: black;">OTP Valid for 10 minutes only</span>
<button type="submit" class="btn btn-warning pull-right submitlogin">
<!-- <button type="submit" class="btn btn-warning pull-right submitlogin">
Login <i class="fa fa-arrow-circle-right"></i>
</button>
</button> -->
<button class="btn btn pull-right" ng-click="Login(myModel);" tabindex="8">
Login
</button>
</div>
<div class="form-group" ng-class="{'has-error':Form.passwordemp.$dirty && Form.passwordemp.$invalid, 'has-success':Form.passwordemp.$valid}" ng-if="Empcheck">
<span class="input-icon">
<input type="text" id="inputPassword4" placeholder="OTP" class="form-control heighLight underline" name="passwordemp" ng-model="myModel.passwordemp"
ng-minlength="6" required/>
<i style="color: black;" class="fa fa-lock"></i>
<span class="error text-small block" ng-if="Form.passwordemp.$dirty && Form.passwordemp.$invalid"> Password Required</span></span>
</div>
<div class="form-group" ng-if="Empcheck">
<button class="btn btn pull-right" ng-click="EmpLogin(myModel);" tabindex="8">
Verify
</button>
</div>
<!--<div class="new-account">
Don't have an account yet?
<a ui-sref="login.registration">