otp password cobination

This commit is contained in:
venbatechnologies@gmail.com 2019-01-09 18:00:51 +05:30
parent 00a779266d
commit 84c0305438
4 changed files with 115 additions and 21 deletions

View File

@ -121,7 +121,9 @@ class Login_Controller extends REST_Controller {
*/
public function checkMobileNumber_post(){
$studentnum = $this->post('mobilenum');
$getstudent = $this->login_model->checkstudnetnumber($studentnum);
$otpcheck = $this->post('otpcheck');
$password = $this->post('pwd');
$getstudent = $this->login_model->checkstudnetnumber($studentnum,$otpcheck,$password);
if ($getstudent)
{
$getstudent['status'] = REST_Controller::HTTP_OK;

View File

@ -140,7 +140,7 @@ 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 'no _if';die();
// print_r($loginDetails);die();
$this->db->select('LO.MobileNumber, LO.ListCode, LO.ID, ST.IsActive,LO.StaffID,ST.BranchCode,SC.CallModuleAccess,SC.FinanceModuleAccess');
@ -312,7 +312,7 @@ class Login_model extends CI_Model
* Studnet Check function*
* created_by : sriram
*/
public function checkstudnetnumber($mobile){
public function checkstudnetnumber($mobile,$otpcheck,$password){
$this->db->select('t1.MobileNumber, t1.Password,t1.ListCode');
$this->db->from('' . LOGIN . ' as t1');
@ -371,23 +371,43 @@ class Login_model extends CI_Model
}
else if(($loginDetails->ListCode == ADMIN)||($loginDetails->ListCode == EMPLOYEE)||(($loginDetails->ListCode == TRAINEE)))
{
{
$result['loginstudent'] = false;
$result['loginstudent'] = true;
$result['loginemployee'] = true;
if($otpcheck == 1)
{
$adminpwd= md5($password);
}
$this->db->select('LO.MobileNumber, LO.ListCode, LO.ID,ST.BranchCode, ST.IsActive,LO.StaffID,ST.MobileNumber as Mobile');
$this->db->from('' . LOGIN . ' as LO');
$this->db->join('' . STAFF . ' as ST', 'LO.StaffID = ST.StaffID');
$this->db->where('LO.MobileNumber', $mobile);
if($otpcheck == 1)
{
$this->db->where('LO.Password', $adminpwd);
}
$this->db->where('ST.IsActive', 1);
$responseDetails = $this->db->get()->first_row();
//print_r($responseDetails);die();
if($otpcheck == 1)
{
//print_r($this->db->last_query());
}
if(!empty($responseDetails))
{
if($responseDetails->IsActive ==1){
$string2 = str_shuffle('1234567890');
$string2 = str_shuffle('1234567890');
$otp = substr($string2,0,6);
//$otp = '431528';
// //echo $otp;die;
@ -402,11 +422,20 @@ class Login_model extends CI_Model
// $query =1;
if($query == 1){
if($otpcheck == 1)
{
$sms = $this->smssend($mobileno,$otp);
}
$result['checkstudent'] = true;
$result['checkemp'] = true;
$result['loginstudent'] = false;
$result['loginemployee'] = true;
}else{
$result['checkstudent'] = false;
$result['checkemp'] = false;
}
@ -414,7 +443,13 @@ class Login_model extends CI_Model
$result['loginStatus'] = false;
$result['message'] = "Your login is de-activated.";
}
}
else {
$result['loginStatus'] = false;
$result['loginemployee'] = false;
$result['message'] = "Your login is de-activated.";
}
@ -433,12 +468,12 @@ class Login_model extends CI_Model
$result['checkstudent'] = false;
$result['message'] = "Your login is de-activated or don't have login.";
}
//print_r($result);die;
//print_r($result);die;
return $result;
}
public function smssend($mobile,$OTP) {
//echo $mobile;
$message ="Your One Time Password to Login to apollodec.com is $OTP. This is valid for 10 minutes.";
$mobile = "91$mobile";

View File

@ -25,6 +25,8 @@ app.controller('loginCtrl', ["$scope", "$http", "API_POINTS", "$state", '$rootSc
$scope.form = {
submit: function (form) {
// alert('in');
var firstError = null;
if (form.$invalid) {
var field = null, firstError = null;
@ -94,7 +96,7 @@ app.controller('loginCtrl', ["$scope", "$http", "API_POINTS", "$state", '$rootSc
// alert(response.data.message);
swal("Warning!", response.data.message, "warning");
$scope.show = true;
$(".alert").delay(200).addClass("in").fadeOut(3500);
//$(".alert").delay(200).addClass("in").fadeOut(3500);
}
});
}
@ -133,9 +135,13 @@ app.controller('loginCtrl', ["$scope", "$http", "API_POINTS", "$state", '$rootSc
* Checkstudent change function *
* created_by : sriram
*/
$scope.Empcheck = false;
$scope.checkMobileNumber = function (MobileNumber) {
//alert($scope.myModel.userMobile);
// var studentNumber = $scope.myModel.userMobile;
var otpcheck= MobileNumber;
if($scope.myModel.userMobile !=''){
// swal({
// title:"Please Wait..",
@ -147,27 +153,50 @@ app.controller('loginCtrl', ["$scope", "$http", "API_POINTS", "$state", '$rootSc
url:apiPoint.url + 'checkmobilenumber',
header:{'Content-Type':'application/json'},
data:{mobilenum:$scope.myModel.userMobile}
data:{mobilenum:$scope.myModel.userMobile,otpcheck:otpcheck,pwd:$scope.myModel.passwordemp}
};
$http(req).then(function(response){
//console.log(response);
//console.log(response);
swal.close();
if(response.data.loginstudent ==true){
if(response.data.checkstudent == true){
if((response.data.loginstudent ==true)||(response.data.loginemployee ==true)){
console.log('if');
if(response.data.checkstudent == true)
{
$scope.typeInput = 'text';
$scope.place = 'OTP';
$scope.icon = 'fa fa-key';
$scope.info = true;
}else{
}
else if(response.data.checkemp== true)
{
console.log('in');
$scope.Empcheck = true;
$scope.typeInput = 'text';
$scope.place = 'OTP';
$scope.icon = 'fa fa-key';
$scope.info = false;
}
else
{
swal("Warning!", response.data.message, "warning");
$scope.show = true;
$(".alert").delay(200).addClass("in").fadeOut(3500);
// $(".alert").delay(200).addClass("in").fadeOut(3500);
}
}else{
}else{
$scope.typeInput = 'password';
$scope.place = 'password';
$scope.icon = 'fa fa-lock';
$scope.info = false;
$scope.icon = 'fa fa-lock';
$scope.info = false;
swal("Warning!", response.data.message, "warning");
// $scope.show = true;
// $(".alert").delay(200).addClass("in").fadeOut(3500);
//alert(response.data.message);
}
});
}

View File

@ -379,6 +379,34 @@
<span class="error text-small block" ng-if="Form.mobilenumber.$error.maxlength || Form.mobilenumber.$error.minlength || Form.mobilenumber.$error.pattern">Enter a valid mobile number / Employee Id</span>
</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="password" id="inputPassword4" placeholder="password" 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-success btn" ng-click="checkMobileNumber(1);" tabindex="8">
Generate OTP
</button>
</div>
<div class="form-group" ng-class="{'has-error':Form.password.$dirty && Form.password.$invalid, 'has-success':Form.password.$valid}">
<span class="input-icon">