| 24383 |
amit.gupta |
1 |
$(function() {
|
|
|
2 |
$(".add-auth-user").live('click', function() {
|
|
|
3 |
console.log("Add Auth User clicked......");
|
|
|
4 |
loadAddAuthUser("main-content");
|
|
|
5 |
});
|
|
|
6 |
$(".change-auth-user-password").live('click', function() {
|
|
|
7 |
console.log("change auth user password clicked......");
|
|
|
8 |
loadChangeAuthUserPassword("main-content");
|
|
|
9 |
});
|
|
|
10 |
|
|
|
11 |
$(".reset-password").live('click', function() {
|
|
|
12 |
console.log("reset-password clicked......");
|
|
|
13 |
var emailId=$(this).data('id');
|
|
|
14 |
console.log(emailId);
|
|
|
15 |
if (confirm("Are you sure you want to reset password of Auth userEmail=!"+emailId) == true) {
|
|
|
16 |
resetAuthUserPassword("main-content",emailId);
|
|
|
17 |
}
|
|
|
18 |
});
|
|
|
19 |
$(".change-password").live(
|
|
|
20 |
'click',
|
|
|
21 |
function() {
|
|
|
22 |
console.log("change-password button clicked......");
|
|
|
23 |
var oldPassword = $("#currentPassword").val();
|
|
|
24 |
var newPassword = $("#newPassword").val();
|
|
|
25 |
var confirmPassword = $("#confirmPassword").val();
|
|
|
26 |
if (oldPassword == "" || oldPassword == null
|
|
|
27 |
|| oldPassword == undefined) {
|
|
|
28 |
alert("oldPassword cann't be blank");
|
|
|
29 |
return;
|
|
|
30 |
}
|
|
|
31 |
if (newPassword == "" || newPassword == null
|
|
|
32 |
|| newPassword == undefined) {
|
|
|
33 |
alert("lastName cann't be blank");
|
|
|
34 |
return;
|
|
|
35 |
}
|
|
|
36 |
if (confirmPassword == "" || confirmPassword == null
|
|
|
37 |
|| confirmPassword == undefined) {
|
|
|
38 |
alert("confirmPassword cann't be blank");
|
|
|
39 |
return;
|
|
|
40 |
}
|
|
|
41 |
if (confirmPassword == newPassword) {
|
|
|
42 |
if (confirm("Are you sure you want to change user password!") == true) {
|
|
|
43 |
changeAuthUserPassword(oldPassword,newPassword);
|
|
|
44 |
}
|
|
|
45 |
} else {
|
|
|
46 |
alert("new Password and confirm Password must be match");
|
|
|
47 |
}
|
|
|
48 |
});
|
|
|
49 |
$(".create-auth-user")
|
|
|
50 |
.live(
|
|
|
51 |
'click',
|
|
|
52 |
function() {
|
|
|
53 |
console.log("Create Auth User button clicked......");
|
|
|
54 |
var emailId = $("#authUserEmail").val();
|
|
|
55 |
var firstName = $("#authUserFirstName").val();
|
|
|
56 |
var lastName = $("#authUserLastName").val();
|
|
|
57 |
var mobileNumber = $("#authUserMobileNumber").val();
|
|
|
58 |
|
|
|
59 |
if (emailId == "" || emailId == null
|
|
|
60 |
|| emailId == undefined) {
|
|
|
61 |
alert("emailId cann't be blank");
|
|
|
62 |
return;
|
|
|
63 |
}
|
|
|
64 |
validateEmail(emailId);
|
|
|
65 |
if (firstName == "" || firstName == null
|
|
|
66 |
|| firstName == undefined) {
|
|
|
67 |
alert("firstName cann't be blank");
|
|
|
68 |
return;
|
|
|
69 |
}
|
|
|
70 |
if (lastName == "" || lastName == null
|
|
|
71 |
|| lastName == undefined) {
|
|
|
72 |
alert("lastName cann't be blank");
|
|
|
73 |
return;
|
|
|
74 |
}
|
|
|
75 |
if (mobileNumber == "" || mobileNumber == null
|
|
|
76 |
|| mobileNumber == undefined) {
|
|
|
77 |
alert("mobileNumber cann't be blank");
|
|
|
78 |
return;
|
|
|
79 |
}
|
|
|
80 |
if (mobileNumber.length != 10) {
|
|
|
81 |
|
|
|
82 |
alert("required 10 digits, match requested format!");
|
|
|
83 |
return;
|
|
|
84 |
}
|
|
|
85 |
if (confirm("Are you sure you want to create Auth user!") == true) {
|
|
|
86 |
addAuthUser(emailId, firstName, lastName,
|
|
|
87 |
mobileNumber);
|
|
|
88 |
}
|
|
|
89 |
});
|
|
|
90 |
$("#authUsers-paginated .next").live(
|
|
|
91 |
'click',
|
|
|
92 |
function() {
|
|
|
93 |
|
|
|
94 |
loadPaginatedNextItems('/getPaginatedAuthUser', null,
|
|
|
95 |
'authUsers-paginated', 'auth-user-table',
|
|
|
96 |
'auth-user-details-container');
|
|
|
97 |
$(this).blur();
|
|
|
98 |
});
|
|
|
99 |
|
|
|
100 |
$("#authUsers-paginated .previous").live(
|
|
|
101 |
'click',
|
|
|
102 |
function() {
|
|
|
103 |
|
|
|
104 |
loadPaginatedPreviousItems('/getPaginatedAuthUser', null,
|
|
|
105 |
'authUsers-paginated', 'auth-user-table',
|
|
|
106 |
'auth-user-details-container');
|
|
|
107 |
$(this).blur();
|
|
|
108 |
});
|
|
|
109 |
|
|
|
110 |
});
|
|
|
111 |
|
|
|
112 |
function loadChangeAuthUserPassword(domId) {
|
|
|
113 |
doGetAjaxRequestHandler(context + "/changePassword", function(response) {
|
|
|
114 |
$('#' + domId).html(response);
|
|
|
115 |
});
|
|
|
116 |
}
|
|
|
117 |
function changeAuthUserPassword(oldPassword, newPassword) {
|
|
|
118 |
var params = {
|
|
|
119 |
"oldPassword" : oldPassword,
|
|
|
120 |
"newPassword" : newPassword
|
|
|
121 |
}
|
|
|
122 |
doPostAjaxRequestWithParamsHandler(context + "/changePassword", params,
|
|
|
123 |
function(response) {
|
|
|
124 |
alert("Password changed successfully");
|
|
|
125 |
loadChangeAuthUserPassword("main-content");
|
|
|
126 |
});
|
|
|
127 |
}
|
|
|
128 |
function addAuthUser(emailId, firstName, lastName, mobileNumber) {
|
|
|
129 |
var params = {
|
|
|
130 |
"emailId" : emailId,
|
|
|
131 |
"firstName" : firstName,
|
|
|
132 |
"lastName" : lastName,
|
|
|
133 |
"mobileNumber" : mobileNumber
|
|
|
134 |
}
|
|
|
135 |
doPostAjaxRequestWithParamsHandler(
|
|
|
136 |
context + "/createAuthUser",
|
|
|
137 |
params,
|
|
|
138 |
function(response) {
|
|
|
139 |
alert("User successfully added! Password sent to registered email="
|
|
|
140 |
+emailId);
|
|
|
141 |
$('#' + "main-content").html(response);
|
|
|
142 |
});
|
|
|
143 |
}
|
|
|
144 |
function loadAddAuthUser(domId) {
|
|
|
145 |
doGetAjaxRequestHandler(context + "/createAuthUser", function(response) {
|
|
|
146 |
$('#' + domId).html(response);
|
|
|
147 |
});
|
|
|
148 |
}
|
|
|
149 |
function resetAuthUserPassword(domId,emailId)
|
|
|
150 |
{
|
|
|
151 |
var params={
|
|
|
152 |
"emailId":emailId
|
|
|
153 |
}
|
|
|
154 |
doAjaxRequestWithParamsHandler(context + "/forgetPassword", "POST", params,
|
|
|
155 |
function(response) {
|
|
|
156 |
if(response=="true")
|
|
|
157 |
{
|
|
|
158 |
alert("Password send to "+emailId+" Successfully ");
|
|
|
159 |
loadAddAuthUser(domId);
|
|
|
160 |
}
|
|
|
161 |
|
|
|
162 |
});
|
|
|
163 |
}
|
|
|
164 |
function validateEmail(emailField) {
|
|
|
165 |
var reg = /^([a-zA-Z0-9_.+-])+\@(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,4})+$/;
|
|
|
166 |
if (reg.test(emailField) == false) {
|
|
|
167 |
alert('Invalid Email Address');
|
|
|
168 |
return false;
|
|
|
169 |
}
|
|
|
170 |
|
|
|
171 |
return true;
|
|
|
172 |
|
|
|
173 |
}
|