diff --git a/Apollo/api/application/controllers/Forget_Controller.php b/Apollo/api/application/controllers/Forget_Controller.php new file mode 100644 index 00000000..3da21f75 --- /dev/null +++ b/Apollo/api/application/controllers/Forget_Controller.php @@ -0,0 +1,82 @@ +methods['forgetlogin_get']['limit'] = 500; // 500 requests per hour per user/key + $this->methods['forgetlogin_post']['limit'] = 500; // 500 requests per hour per user/key + + $this->methods['forgetlogin_delete']['limit'] = 50; // 50 requests per hour per user/key + + $this->load->model('Forgot_model', 'forgot_model'); + + } + + + public function forgetlogin_post() + { + //$userMobile = $this->post('userMobile'); + $details['MobileNumber'] = $this->post('userMobile'); + // $details['Password'] = $this->post('password'); + + + function generateRandomString($length = 8) { + $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; + $charactersLength = strlen($characters); + $randomString = ''; + for ($i = 0; $i < $length; $i++) { + $randomString .= $characters[rand(0, $charactersLength - 1)]; + } + return $randomString; + } + $password= generateRandomString(); + $details['Password'] = md5($password); + + $loginDetails = $this->forgot_model->forget($details, $password);// Check if the users data store contains users (in case the database result returns NULL) + if ($loginDetails) + { + $loginDetails['status'] = REST_Controller::HTTP_OK; + //Set the response and exit + $this->response($loginDetails, 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 + } + + + } + +} + diff --git a/Apollo/api/application/models/Forgot_model.php b/Apollo/api/application/models/Forgot_model.php new file mode 100644 index 00000000..ed744dca --- /dev/null +++ b/Apollo/api/application/models/Forgot_model.php @@ -0,0 +1,138 @@ + 7594aacdb21d8a9b29f71ea9163a5730 + */ + // + function forget($user=null, $password) + { + $this->db->select('ID,Emailid,MobileNumber,Password'); + $this->db->where('MobileNumber', $user['MobileNumber']); + + + + $forgotDetails = $this->db->get('T_Login')->first_row(); + //print_r ($forgotDetails) ; + //exit(); + + // $result = $query->result_array(); + if($forgotDetails){ + + $existUserID=$forgotDetails->ID; + $this->db->where('ID', $existUserID); + $upatePassword=$this->db->update('T_Login', $user); + // print_r ($upatePassword) ; + //exit(); + if($upatePassword) { + $result['forgotstatus'] = true; + $result['resPass'] = $password; + $result['message'] = "Password updated successfully"; + } + else{ + $result['forgotstatus'] = false; + $result['message'] = "Something went wrong!"; + } + + + } + else { + $result['forgotstatus'] = false; + $result['message'] = "User is not exist!"; + } + + return $result; + } + // public function change_Password( $userId, $newPassword, $oldPassword, $updateOn) { + // $this->db->select('Password'); + // $this->db->from(LOGIN); + // $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'"; + // if($this->db->query($sql) == '1'){ + // $result['changePassStatus'] = true; + // $result['message'] = "Your Password Successfully changed !!"; + // } else { + // $result['changePassStatus'] = false; + // $result['message'] = "Please try Again !!"; + // } + // } else { + // $result['changePassStatus'] = false; + // $result['message'] = "Your Current Password miss match, Please try Again !!"; + // } + // return $result; + // } + +// + +// + //public function login($mobile = null) + //{ + // $this->db->select('MobileNumber'); + //$this->db->where('MobileNumber', $mobile); + //$this->db->where('IsActive', 1); + //$//loginDetails = $this->db->get(LOGIN)->first_row(); + //if($loginDetails){ + //if($mobile == $loginDetails->MobileNumber){ + + //if($password == $loginDetails->Password){ + //print_r($loginDetails);exit(); + //$this->db->select('t1.MobileNumber, t1.ListCode, t1.ID, t2.BranchCode'); + //$this->db->from(''.LOGIN.' as t1'); + //$this->db->where('t1.MobileNumber', $mobile); + //$this->db->join(''.STAFF.' as t2', 't1.StaffID = t2.StaffID', 'LEFT'); + //$responseDetails = $this->db->get()->first_row(); + //$result['loginStatus'] = true; + + //$result['details'] = $responseDetails; + + //} + //else { + //$result['loginStatus'] = false; + /* $result['message'] = "Please Enter Valid Password !!"; + } + } + else{ + $result['loginStatus'] = false; + $result['message'] = "Please Enter Register Mobile Number !!"; + } + } + else { + $result['loginStatus'] = false; + $result['message'] = "Something Went Wrong, Please try Again !!"; + } + + /*$this->db->join('areas a', 'a.id = e.id_area', 'inner'); + $this->db->join('horario h', 'h.id = e.id_horario', 'inner'); + $this->db->join('dia d', 'd.id = e.id_data', 'inner'); + $this->db->join('tipo_evento t', 't.id = e.id_tipo', 'inner'); + $this->db->join('campus c', 'c.id = e.id_unidade', 'inner'); + if ( $id != null ){ + $this->db->where('e.id', $id); + return $this->db->get('eventos')->first_row(); + } else { + return $this->db->get('eventos')->result(); + }*/ + + //return $result; + + // } + + +} \ No newline at end of file diff --git a/Apollo/assets/js/controllers/forgetCtrl.js b/Apollo/assets/js/controllers/forgetCtrl.js new file mode 100644 index 00000000..a9fe7935 --- /dev/null +++ b/Apollo/assets/js/controllers/forgetCtrl.js @@ -0,0 +1,91 @@ +'use strict'; +/** + * controllers for ng-table + * Simple table with sorting and filtering on AngularJS + */ + +app.controller('forgotCtrl', ["$scope", "$http", "API_POINTS", "$state", '$rootScope', '$cookies', 'md5','ipCookie', 'SweetAlert', function ($scope, $http, apiPoint, $state, $rootScope, $cookies, md5, ipCookie, SweetAlert) { + + /** + * login details capture + * by : srk + */ + // + + $scope.myModel = { + 'userMobile': '', + + }; + + + $scope.show = false; + + $scope.responseData = ''; + + $scope.forgotForm = { + submit: function (form) { + //alert("hi"); + var firstError = null; + if (form.$invalid) { + var field = null, firstError = null; + for (field in form) { + if (field[0] != '$') { + if (firstError === null && !form[field].$valid) { + firstError = form[field].$name; + } + if (form[field].$pristine) { + form[field].$dirty = true; + } + } + } + angular.element('.ng-invalid[name=' + firstError + ']').focus(); + } else { + $scope.spin = ''; + var req = { + method: 'POST', + url: apiPoint.url + 'forgetlogin/', + headers: { + 'Content-Type': 'application/json' + }, + data: { + userMobile: $scope.myModel.userMobile, + // password: md5.createHash($scope.myModel.password || '') + } + }; + $http(req).then(function (response) { + if (response.data.forgotstatus == true) { + // $scope.responseData = response.data.forgotstatus; + //alert(response.data.message); + swal("Success!",response.data.resPass, "success"); + $state.go('login.signin'); + } else { + //alert(response.data.message); + swal("Failed!", response.data.message, "error"); + + // $scope.show = true; + // $(".alert").delay(200).addClass("in").fadeOut(3500); + } + }); + + // + + // + + } + }, + reset: function (form) { + $scope.myModel = angular.copy($scope.master); + form.$setPristine(true); + } + } +}]); + + + + + + + + +// forgetLogin -> Number(9876543210) -> (is he/she exist) yes---> genetate(md5(venba@123)) --> response(true check your mail, venba@123) +// no --> response(not exist) \ No newline at end of file diff --git a/Apollo/assets/js/controllers/loginCtrl.js b/Apollo/assets/js/controllers/loginCtrl.js index dbb4ec66..f8c5339a 100644 --- a/Apollo/assets/js/controllers/loginCtrl.js +++ b/Apollo/assets/js/controllers/loginCtrl.js @@ -1,6 +1,6 @@ 'use strict'; /** - * controllers for ng-table + * controllers for ng-table//commentgit * Simple table with sorting and filtering on AngularJS */ diff --git a/Apollo/assets/views/login_forgot.html b/Apollo/assets/views/login_forgot.html index 789a49f6..27e5cb66 100644 --- a/Apollo/assets/views/login_forgot.html +++ b/Apollo/assets/views/login_forgot.html @@ -5,25 +5,32 @@ {{app.name}} -
-
+
+ + +
Forget Password? -

- Enter your e-mail address below to reset your password. +

+ Enter your Registered Mobile Number below to reset your password.

-
- - - -
+
+ + + + + + mobile number is required. +
+
Log-In -