Commit 3e6e9e0f40e312e874e9807fd6f270935443b9be

Authored by Anchit Jindal
1 parent 0ed3fc0f72
Exists in master

validate user exists

app/partials/accountSetting/accountSetting.Controller.js
... ... @@ -82,6 +82,20 @@
82 82 $scope.accountdata = {};
83 83 $('#demo-modal').css('display', '');
84 84 }
  85 +
  86 + $scope.checkEmail = function(email, type) {
  87 + console.log(type)
  88 + AccountSettingService.checkEmail(email).then(function(result) {
  89 + if(result.status == 'ACTIVE'){
  90 + toastr.error('Email already exists.', {
  91 + closeButton: true
  92 + })
  93 + if(type == 'additional'){
  94 + $scope.accountdata.userName = '';
  95 + }
  96 + }
  97 + })
  98 + }
85 99  
86 100 $scope.additionalAccnObj = {};
87 101 $scope.createAddAccount = function(){
... ...
app/partials/accountSetting/accountSetting.Service.js
... ... @@ -61,6 +61,24 @@
61 61 })
62 62 return deferred.promise;
63 63 }
  64 +
  65 + this.checkEmail = function(email) {
  66 +
  67 + var deferred = $q.defer();
  68 + $http({
  69 + method : 'GET',
  70 + url : BASE_URL.url + '/user/email/status?email=' + email,
  71 + headers : {
  72 + 'Content-Type' : 'application/json'
  73 + },
  74 + }).then(function(result) {
  75 + deferred.resolve(result.data);
  76 + }, function(result) {
  77 + //console.log(result.data)
  78 + deferred.resolve(result.data);
  79 + })
  80 + return deferred.promise;
  81 + }
64 82  
65 83 this.updateUserProfile = function(data) {
66 84  
... ...
app/partials/accountSetting/accountSetting.html
... ... @@ -12,7 +12,7 @@
12 12  
13 13 <form role="form">
14 14 <div class="col-sm-6">
15   - <div class="form-group"><label>Email Username</label> <input type="email" placeholder="Username" ng-model="userData.email" class="form-control"></div>
  15 + <div class="form-group"><label>Email Username</label> <input type="email" placeholder="Username" ng-model="userData.email" ng-blur="checkEmail(userData.email, 'user')" class="form-control"></div>
16 16 <div class="form-group"><label>First Name</label> <input type="text" placeholder="First Name" ng-model="userData.firstName" class="form-control"></div>
17 17 <div class="form-group"><label>Last Name</label> <input type="text" placeholder="Last Name" ng-model="userData.lastName" class="form-control"></div>
18 18 </div>
... ... @@ -193,7 +193,7 @@
193 193  
194 194 <div class="col-md-6">
195 195 <div class="pull-left" style="width: calc(140% - 170px);">
196   - <input type="email" ng-model="accountdata.userName" placeholder="XYZfbo@gmail.com" class="form-control" required >
  196 + <input type="email" ng-model="accountdata.userName" ng-blur="checkEmail(accountdata.userName, 'additional')" placeholder="XYZfbo@gmail.com" class="form-control" required >
197 197 </div>
198 198  
199 199 <div class="clearfix"></div>
... ...