mirror of
https://gitlab.com/bmcgonag/get_my.git
synced 2026-03-27 08:18:50 +00:00
Adding edit and delete users from system.
This commit is contained in:
parent
07a8496542
commit
45b78101c8
5 changed files with 88 additions and 5 deletions
25
client/Accounts/UserMgmt/userInfoModal.html
Normal file
25
client/Accounts/UserMgmt/userInfoModal.html
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
<template name="userInfoModal">
|
||||
<div id="userInfoModal" class="modal">
|
||||
<div class="modal-content">
|
||||
<div class="row">
|
||||
<div class="col s12 m12 12">
|
||||
<h4>Password Reset</h4>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col s12 m6 l6 input-field">
|
||||
<input type="password" class="newPass" id="newPass" />
|
||||
<label for="newPass">Enter New Password</label>
|
||||
</div>
|
||||
<div class="col s12 m6 l6 input-field">
|
||||
<input type="password" class="newPassConf" style="{{#if $eq passMatch false}}background: red;{{/if}}" id="newPassConf" />
|
||||
<label for="newPassConf">Enter New Password</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<a href="#" id="closePass" class="modal-close waves-effect waves-orange btn-flat white-text">Cancel</a>
|
||||
<a href="#" id="chPass" class="waves-effect waves-green btn-flat white-text">change Password</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
50
client/Accounts/UserMgmt/userInfoModal.js
Normal file
50
client/Accounts/UserMgmt/userInfoModal.js
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
Template.userInfoModal.onCreated(function() {
|
||||
|
||||
});
|
||||
|
||||
Template.userInfoModal.onRendered(function() {
|
||||
Session.set("passMatch", true);
|
||||
Session.set("passErr", false);
|
||||
$('.modal').modal();
|
||||
});
|
||||
|
||||
Template.userInfoModal.helpers({
|
||||
passMatch: function() {
|
||||
return Session.get("passMatch");
|
||||
}
|
||||
});
|
||||
|
||||
Template.userInfoModal.events({
|
||||
"click #chPass" (event) {
|
||||
event.preventDefault();
|
||||
let usersId = Session.get("usersId");
|
||||
let passwd = $("#newPass").val();
|
||||
let passMatch = Session.get("passMatch");
|
||||
if (passwd == null || passwd == "" || passMatch == false) {
|
||||
Session.set("passErr", true);
|
||||
return;
|
||||
} else {
|
||||
Meteor.call('change.userPass', usersId, passwd, function(err, result) {
|
||||
if (err) {
|
||||
console.log(" ERROR changing user passwrod:" + err);
|
||||
} else {
|
||||
console.log(" Password changed successfully!");
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
"click #closePass" (event) {;
|
||||
|
||||
},
|
||||
"keyup #newPassConf" (event) {
|
||||
let newPass = $("#newPass").val();
|
||||
let newPassConf = $("#newPassConf").val();
|
||||
if (newPassConf.length > 2 && (newPass != null || newPass != "")) {
|
||||
if (newPass != newPassConf) {
|
||||
Session.set("passMatch", false);
|
||||
} else {
|
||||
Session.set("passMatch", true);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
@ -20,7 +20,7 @@
|
|||
<td>{{userRole}}</td>
|
||||
<td>
|
||||
<div class="input-field">
|
||||
<i class="material-icons clickable deleteUser">delete</i>
|
||||
<i class="material-icons modal-trigger clickable deleteUser">delete</i>
|
||||
<i class="material-icons clickable editUser">edit</i>
|
||||
</div>
|
||||
</td>
|
||||
|
|
@ -31,4 +31,6 @@
|
|||
</div>
|
||||
</div>
|
||||
{{/if}}
|
||||
{{> deleteConfirmationModal}}
|
||||
{{> userInfoModal}}
|
||||
</template>
|
||||
|
|
@ -6,6 +6,7 @@ Template.userMgmt.onCreated(function() {
|
|||
|
||||
Template.userMgmt.onRendered(function() {
|
||||
$('select').formSelect();
|
||||
$('.modal').modal();
|
||||
});
|
||||
|
||||
Template.userMgmt.helpers({
|
||||
|
|
@ -29,7 +30,8 @@ Template.userMgmt.events({
|
|||
|
||||
let userId = this._id;
|
||||
// take action
|
||||
console.log("Edit called on: " + userId);
|
||||
Session.set("usersId", userId);
|
||||
$("#userInfoModal").modal('open');
|
||||
},
|
||||
"click .deleteUser" (event) {
|
||||
event.preventDefault();
|
||||
|
|
@ -41,8 +43,6 @@ Template.userMgmt.events({
|
|||
Session.set("item", "User");
|
||||
Session.set("view", "Users");
|
||||
Session.set("method", "delete.userFromSys");
|
||||
Meteor.setTimeout(function() {
|
||||
$('.modal').open('modalDelete');
|
||||
}, 150);
|
||||
$('#modalDelete').modal('open');
|
||||
}
|
||||
});
|
||||
|
|
@ -29,4 +29,10 @@ Meteor.methods({
|
|||
}
|
||||
});
|
||||
},
|
||||
'change.userPass' (usersId, password) {
|
||||
check(usersId, String);
|
||||
check(password, String);
|
||||
|
||||
return Accounts.setPassword(usersId, password);
|
||||
},
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue