From d12ce07730cea9399206a89890bbdc163ed540d5 Mon Sep 17 00:00:00 2001 From: resicovenba Date: Fri, 24 Nov 2017 11:04:52 +0530 Subject: [PATCH] master screen check --- Apollo/api/application/config/routes.php | 2 + .../controllers/Login_Controller.php | 29 +++++- Apollo/api/application/models/Login_model.php | 24 ++++- Apollo/assets/i18n/en.json | 3 +- Apollo/assets/js/config.constant.js | 2 + Apollo/assets/js/config.router.js | 8 ++ .../js/controllers/changePasswordCtrl.js | 73 ++++++++++++++ Apollo/assets/views/changePassword.html | 96 +++++++++++++++++++ Apollo/assets/views/dashboard.html | 2 +- Apollo/assets/views/partials/nav.html | 47 +++++---- Apollo/assets/views/partials/top-navbar.html | 8 +- 11 files changed, 264 insertions(+), 30 deletions(-) create mode 100644 Apollo/assets/js/controllers/changePasswordCtrl.js create mode 100644 Apollo/assets/views/changePassword.html diff --git a/Apollo/api/application/config/routes.php b/Apollo/api/application/config/routes.php index e4a20f1e..5d31a295 100644 --- a/Apollo/api/application/config/routes.php +++ b/Apollo/api/application/config/routes.php @@ -91,6 +91,8 @@ $route['addActivityDetails'] = 'University_Controller/addActivityDetails'; $route['getActivityDetails'] = 'University_Controller/getActivityDetails'; $route['updateActivityStatus'] = 'University_Controller/updateActivityStatus'; +$route['changePassword'] = 'Login_Controller/changePassword'; + diff --git a/Apollo/api/application/controllers/Login_Controller.php b/Apollo/api/application/controllers/Login_Controller.php index 3fa8f253..c635007f 100644 --- a/Apollo/api/application/controllers/Login_Controller.php +++ b/Apollo/api/application/controllers/Login_Controller.php @@ -56,8 +56,35 @@ class Login_Controller extends REST_Controller { 'status' => REST_Controller::HTTP_NOT_FOUND ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code } + } - + // change old password + public function changePassword_post() { + $oldPassword = $this->post('oldPassword'); + $newPassword = $this->post('newPassword'); + $userId = $this->post('UserId'); + echo $oldPassword; + echo $newPassword; + echo $userId; + exit(); + $date = date('Y-m-d H:i:s'); + $updateOn = $date; + $changePassword = $this->login_model->change_Password( $userId, $newPassword, $oldPassword, $updateOn);// Check if the users data store contains users (in case the database result returns NULL) + if ($changePassword) + { + $changePassword['status'] = REST_Controller::HTTP_OK; + // Set the response and exit + $this->response($changePassword, REST_Controller::HTTP_OK); // OK (200) being the HTTP response code + } + else + { + // Set the response and exit + $this->response([ + 'message' => 'No record were found', + 'status' => REST_Controller::HTTP_NOT_FOUND + ], REST_Controller::HTTP_NOT_FOUND); // NOT_FOUND (404) being the HTTP response code + } } } + \ No newline at end of file diff --git a/Apollo/api/application/models/Login_model.php b/Apollo/api/application/models/Login_model.php index b6638ce1..d8dd377a 100644 --- a/Apollo/api/application/models/Login_model.php +++ b/Apollo/api/application/models/Login_model.php @@ -73,10 +73,28 @@ class Login_model extends CI_Model } else { return $this->db->get('eventos')->result(); }*/ - 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; + } } \ No newline at end of file diff --git a/Apollo/assets/i18n/en.json b/Apollo/assets/i18n/en.json index bbe3b01e..560de865 100644 --- a/Apollo/assets/i18n/en.json +++ b/Apollo/assets/i18n/en.json @@ -18,7 +18,8 @@ "CALENDAR": "My Calendar", "MESSAGES": "My Messages", "LOCKSCREEN": "Lock Screen", - "LOGOUT": "Log Out" + "LOGOUT": "Log Out", + "CHANGEPASSWORD": "Change Password" } }, "offsidebar": { diff --git a/Apollo/assets/js/config.constant.js b/Apollo/assets/js/config.constant.js index 1136865e..b791b9ec 100644 --- a/Apollo/assets/js/config.constant.js +++ b/Apollo/assets/js/config.constant.js @@ -62,6 +62,8 @@ app.constant('JS_REQUIRES', { */ 'loginCtrl': 'assets/js/controllers/loginCtrl.js', + 'changePasswordCtrl': 'assets/js/controllers/changePasswordCtrl.js', + /*** * Session */ diff --git a/Apollo/assets/js/config.router.js b/Apollo/assets/js/config.router.js index 96aaebdf..6d2a9537 100644 --- a/Apollo/assets/js/config.router.js +++ b/Apollo/assets/js/config.router.js @@ -63,6 +63,14 @@ app.config(['$stateProvider', '$urlRouterProvider', '$controllerProvider', '$com ncyBreadcrumb: { label: 'Dashboard' } + }).state('app.changePassword', { + url: "/changePassword", + templateUrl: "assets/views/changePassword.html", + resolve: loadSequence('spin', 'ladda', 'angular-ladda', 'ngTable', 'changePasswordCtrl'), + title: "Change Password", + ncyBreadcrumb: { + label: 'Change Password' + } }).state('app.master', { url: '/master', template: '
', diff --git a/Apollo/assets/js/controllers/changePasswordCtrl.js b/Apollo/assets/js/controllers/changePasswordCtrl.js new file mode 100644 index 00000000..8eead5c8 --- /dev/null +++ b/Apollo/assets/js/controllers/changePasswordCtrl.js @@ -0,0 +1,73 @@ +'use strict'; +/*** controller for Wizard Form example***/ +app.controller('changePasswordCtrl', ["$scope", "$filter", "ngTableParams", "API_POINTS", "$http", "SweetAlert", "$state", 'md5', 'ipCookie', function ($scope, $filter, ngTableParams, apiPoint, $http, SweetAlert, $state, md5, ipCookie) { + $scope.myModel = { + curr: "", + password1: "", + password2: "" + }; + + $scope.currentStep = 1; + + // get local cliend details + var localDetail = JSON.parse(localStorage.getItem('localObj')); + var localDetails = ipCookie('cookiechk'); + + // Initial Value + $scope.form = { + + submit: function (form, myModel) { + 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 { + + var req = { + method: 'POST', + url: apiPoint.url + 'changePassword/', + headers: { + 'Content-Type': 'application/json' + }, + params: { + oldPassword: md5.createHash($scope.myModel.curr || ''), + newPassword: md5.createHash($scope.myModel.password1 || '') , + reqUserID: localDetails.localUserID, + } + }; + $http(req).then(function (response) { + if (response.data.status == true) { + // SweetAlert.swal("Hello!", "Password changed Succesfully"); + // $state.go($state.current, {}, { reload: true }); + $scope.myModel = { + curr: "", + password1: "", + password2: "" + }; + } else { + SweetAlert.swal("password Not Changed", "Please check the current password", "error"); + // $state.go($state.current, {}, { reload: true }); + } + }, function (error) { + //error function + }); + } + + }, + reset: function () { + } + }; + +}]); diff --git a/Apollo/assets/views/changePassword.html b/Apollo/assets/views/changePassword.html new file mode 100644 index 00000000..34f07e97 --- /dev/null +++ b/Apollo/assets/views/changePassword.html @@ -0,0 +1,96 @@ + + +
+
+
+

Change Password

+
+
+
+
+ + +
+
+
+ + +
+ +
+
+ + + +
+
+
+
+ + +
+
+
+
+ + Change Password + +
+ +
+ + + Password is required. + Enter at least 8 characters + +
+ +
+ + + Password is required. + Enter at least 8 characters + Ok! +
+
+ + + Repeat password is required! + Passwords do not match! + Passwords match! +
+
+ +
+ + +
+ +
+ +
+
+
+ + + +
+ +
+ +
+
+
+
+ \ No newline at end of file diff --git a/Apollo/assets/views/dashboard.html b/Apollo/assets/views/dashboard.html index 2c8d547a..265aaa7c 100644 --- a/Apollo/assets/views/dashboard.html +++ b/Apollo/assets/views/dashboard.html @@ -20,7 +20,7 @@

Something awesome is coming soon

-

We are building something very cool stay turned and be patient. your patience will be well paid

+

We are building something very cool stay tuned and be patient. your patience will be well paid

diff --git a/Apollo/assets/views/partials/nav.html b/Apollo/assets/views/partials/nav.html index 327a0802..70ba902c 100644 --- a/Apollo/assets/views/partials/nav.html +++ b/Apollo/assets/views/partials/nav.html @@ -1,15 +1,15 @@ - + - + - + @@ -71,7 +78,7 @@
-
+
Dashboard
@@ -114,16 +121,16 @@
- CALL TRACKING + CALL TRACKING
- + - + +