forgot password
This commit is contained in:
parent
b2e81c9e12
commit
1d249219ad
82
Apollo/api/application/controllers/Forget_Controller.php
Normal file
82
Apollo/api/application/controllers/Forget_Controller.php
Normal file
@ -0,0 +1,82 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||||
|
|
||||||
|
// This can be removed if you use __autoload() in config.php OR use Modular Extensions
|
||||||
|
/** @noinspection PhpIncludeInspection */
|
||||||
|
require_once APPPATH . '/libraries/REST_Controller.php';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is an example of a few basic user interaction methods you could use
|
||||||
|
* all done with a hardcoded array
|
||||||
|
*
|
||||||
|
* @package CodeIgniter
|
||||||
|
* @subpackage Rest Server
|
||||||
|
* @category Controller
|
||||||
|
* @author
|
||||||
|
* @license MIT
|
||||||
|
* @link
|
||||||
|
*/
|
||||||
|
class Forget_Controller extends REST_Controller {
|
||||||
|
|
||||||
|
function __construct()
|
||||||
|
{
|
||||||
|
// Construct the parent class
|
||||||
|
parent::__construct();
|
||||||
|
|
||||||
|
|
||||||
|
// Configure limits on our controller methods
|
||||||
|
// Ensure you have created the 'limits' table and enabled 'limits' within application/config/rest.php
|
||||||
|
$this->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
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
138
Apollo/api/application/models/Forgot_model.php
Normal file
138
Apollo/api/application/models/Forgot_model.php
Normal file
@ -0,0 +1,138 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Created by PhpStorm.
|
||||||
|
* User: karthi
|
||||||
|
* Date: 11/9/17
|
||||||
|
* Time: 5:28 PM
|
||||||
|
*/
|
||||||
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||||
|
|
||||||
|
class Forgot_model extends CI_Model {
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* get user login details
|
||||||
|
* params:email,password
|
||||||
|
* created by karthi
|
||||||
|
* */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Default login venba@123 -> 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;
|
||||||
|
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
91
Apollo/assets/js/controllers/forgetCtrl.js
Normal file
91
Apollo/assets/js/controllers/forgetCtrl.js
Normal file
@ -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)
|
||||||
@ -5,20 +5,27 @@
|
|||||||
<img ng-src="{{app.layout.logo}}" alt="{{app.name}}"/>
|
<img ng-src="{{app.layout.logo}}" alt="{{app.name}}"/>
|
||||||
</div>
|
</div>
|
||||||
<!-- start: FORGOT BOX -->
|
<!-- start: FORGOT BOX -->
|
||||||
<div class="box-forgot">
|
<div class="box-forget" ng-controller="forgotCtrl">
|
||||||
<form class="form-forgot">
|
<!--<form name="myForm" class="form-forgot" novalidate class="form-inline" ng-submit="form.submit(Form)" method="post">-->
|
||||||
|
|
||||||
|
<form class="form-forrgot" ng-submit="forgotForm.submit(form)" name="form" id= "form" novalidate method="POST">
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<legend>
|
<legend>
|
||||||
Forget Password?
|
Forget Password?
|
||||||
</legend>
|
</legend>
|
||||||
<p>
|
<p style="color: sandybrown;">
|
||||||
Enter your e-mail address below to reset your password.
|
Enter your Registered Mobile Number below to reset your password.
|
||||||
</p>
|
</p>
|
||||||
<div class="form-group">
|
<div class="form-group" ng-class="{'has-error':form.mobilenumber.$dirty && form.mobilenumber.$invalid, 'has-success':form.mobilenumber.$valid}">
|
||||||
<span class="input-icon">
|
<span class="input-icon">
|
||||||
<input type="email" class="form-control" name="email" placeholder="Email">
|
<input type="text" class="form-control" ng-model="myModel.userMobile" name="mobilenumber" placeholder="MobileNumber"
|
||||||
<i class="fa fa-envelope-o"></i> </span>
|
required>
|
||||||
|
|
||||||
|
<i class="fa fa-mobile"></i>
|
||||||
|
</span>
|
||||||
|
<span class="error text-small block" ng-if="form.mobilenumber.$dirty && form.mobilenumber.$error.required"> mobile number is required. </span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-actions">
|
<div class="form-actions">
|
||||||
<a class="btn btn-primary btn-o" ui-sref="login.signin">
|
<a class="btn btn-primary btn-o" ui-sref="login.signin">
|
||||||
<i class="fa fa-chevron-circle-left"></i> Log-In
|
<i class="fa fa-chevron-circle-left"></i> Log-In
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user