Update Admin Account Creation/Edit notices
parent
46fb7703d0
commit
2a407d65b1
|
@ -12,6 +12,8 @@
|
|||
"accountAdded": "Account Added",
|
||||
"accountAddedText": "Account has been added.",
|
||||
"monitorDeleted": "Monitor Deleted",
|
||||
"accountCreationError": "Account Creation Error",
|
||||
"accountEditError": "Account Edit Error",
|
||||
"Unmute": "Unmute",
|
||||
"byUser": "by user",
|
||||
"accountDeleted": "Account Deleted",
|
||||
|
@ -34,7 +36,6 @@
|
|||
"Active Monitors": "Active Monitors",
|
||||
"Storage Use": "Storage Use",
|
||||
"Use Raw Snapshot": "Use Raw Snapshot",
|
||||
"Account Edited": "Account Edited",
|
||||
"Failed to Edit Account": "Failed to Edit Account",
|
||||
"How to Connect": "How to Connect",
|
||||
"Login": "Login",
|
||||
|
@ -559,7 +560,12 @@
|
|||
"InvalidJSONText": "Please ensure this is a valid JSON string for Shinobi monitor configuration.",
|
||||
"Passwords don't match": "Passwords don't match",
|
||||
"Email address is in use.": "Email address is in use.",
|
||||
"Account Created": "Account Created",
|
||||
"Account Edited": "Account Edited",
|
||||
"Group Key is in use.": "Group Key is in use.",
|
||||
"adminAccountCreatedMsg": "Your account has been created. Access the account at the primary login page (Non-Superuser).",
|
||||
"adminAccountEditedMsg": "Your account has been edited. You may need to restart Shinobi for some changes to take effect.",
|
||||
"createSubAccountsInfo": "If you are looking to share cameras with another account you may create them in the Sub-Account manager of your non-superuser Dashboard.",
|
||||
"Create Sub-Accounts at /admin": "Create Sub-Accounts at /admin",
|
||||
"No Events found for this video": "No Events found for this video",
|
||||
"Video and Time Span (Minutes)": "Video and Time Span (Minutes)",
|
||||
|
@ -1057,6 +1063,7 @@
|
|||
"Monitor mode is already": "Monitor mode is already",
|
||||
"Monitor or Key does not exist.": "Monitor or Key does not exist.",
|
||||
"No Group with this key exists": "No Group with this key exists",
|
||||
"Group with this key exists already": "Group with this key exists already",
|
||||
"Downloaded!": "Downloaded!",
|
||||
"Downloading...": "Downloading...",
|
||||
"Loading...": "Loading...",
|
||||
|
|
|
@ -292,36 +292,40 @@ module.exports = function(s,config,lang,app){
|
|||
//found address already exists
|
||||
endData.msg = lang['Email address is in use.'];
|
||||
}else{
|
||||
endData.ok = true
|
||||
//create new
|
||||
//user id
|
||||
form.uid = s.gid()
|
||||
//check to see if custom key set
|
||||
if(!form.ke||form.ke===''){
|
||||
form.ke=s.gid()
|
||||
if(!form.ke){
|
||||
form.ke = s.gid()
|
||||
}else{
|
||||
form.ke = form.ke.replace(/[`~!@#$%^&*()_|+\-=?;:'",.<>\{\}\[\]\\\/]/gi, '')
|
||||
form.ke = form.ke.replace(/[`~!@#$%^&*()_|+\-=?;:'",.<>\{\}\[\]\\\/]/gi, '').trim()
|
||||
}
|
||||
//check if "details" is object
|
||||
if(form.details instanceof Object){
|
||||
form.details = JSON.stringify(form.details)
|
||||
}
|
||||
//write user to db
|
||||
s.knexQuery({
|
||||
action: "insert",
|
||||
table: "Users",
|
||||
insert: {
|
||||
ke: form.ke,
|
||||
uid: form.uid,
|
||||
mail: form.mail,
|
||||
pass: s.createHash(form.pass),
|
||||
details: form.details
|
||||
if(!s.group[form.ke]){
|
||||
endData.ok = true
|
||||
//check if "details" is object
|
||||
if(form.details instanceof Object){
|
||||
form.details = JSON.stringify(form.details)
|
||||
}
|
||||
})
|
||||
s.tx({f:'add_account',details:form.details,ke:form.ke,uid:form.uid,mail:form.mail},'$')
|
||||
endData.user = Object.assign(form,{})
|
||||
//init user
|
||||
s.loadGroup(form)
|
||||
//write user to db
|
||||
s.knexQuery({
|
||||
action: "insert",
|
||||
table: "Users",
|
||||
insert: {
|
||||
ke: form.ke,
|
||||
uid: form.uid,
|
||||
mail: form.mail,
|
||||
pass: s.createHash(form.pass),
|
||||
details: form.details
|
||||
}
|
||||
});
|
||||
s.tx({f:'add_account',details:form.details,ke:form.ke,uid:form.uid,mail:form.mail},'$')
|
||||
endData.user = Object.assign(form,{})
|
||||
//init user
|
||||
s.loadGroup(form)
|
||||
}else{
|
||||
endData.msg = lang["Group with this key exists already"]
|
||||
}
|
||||
}
|
||||
close()
|
||||
})
|
||||
|
|
|
@ -35,9 +35,36 @@ function saveAccountSettings(){
|
|||
postData.account = $.aN.selected
|
||||
}
|
||||
$.post(superApiPrefix + $user.sessionKey+'/accounts/'+webPath,postData,function(data){
|
||||
console.log(data)
|
||||
if(data.ok === true){
|
||||
$.aN.e.modal('hide')
|
||||
if(webPath === 'editAdmin'){
|
||||
if(data.ok === true){
|
||||
$.aN.e.modal('hide')
|
||||
new PNotify({
|
||||
title: lang['Account Edited'],
|
||||
text: lang.adminAccountEditedMsg,
|
||||
type: 'success'
|
||||
})
|
||||
}else{
|
||||
new PNotify({
|
||||
title: lang.accountEditError,
|
||||
text: lang['Failed to Edit Account'],
|
||||
type: 'error'
|
||||
})
|
||||
}
|
||||
}else{
|
||||
if(data.ok === true){
|
||||
$.aN.e.modal('hide')
|
||||
new PNotify({
|
||||
title: lang['Account Created'],
|
||||
text: lang.adminAccountCreatedMsg,
|
||||
type: 'success'
|
||||
})
|
||||
}else{
|
||||
new PNotify({
|
||||
title: lang.accountCreationError,
|
||||
text: data.msg + '<br>' + lang.createSubAccountsInfo,
|
||||
type: 'error'
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
@ -54,7 +81,11 @@ $.aN.e.on('change','[name="mail"]',function(){
|
|||
var thisVal = $(this).val()
|
||||
$.each(loadedUsers,function(n,user){
|
||||
if($.aN.selected && user.ke !== $.aN.selected.ke && thisVal.toLowerCase() === user.mail.toLowerCase()){
|
||||
new PNotify({text:lang['Email address is in use.'],type:'error'})
|
||||
new PNotify({
|
||||
title: lang.accountCreationError,
|
||||
text: lang['Email address is in use.'],
|
||||
type: 'error'
|
||||
})
|
||||
}
|
||||
})
|
||||
})
|
||||
|
@ -63,7 +94,11 @@ $.aN.e.on('change','[name="ke"]',function(){
|
|||
var thisVal = $(this).val()
|
||||
$.each(loadedUsers,function(n,user){
|
||||
if(!$.aN.modeIsEdit() && user.ke === thisVal){
|
||||
new PNotify({text:lang['Group Key is in use.'] + ' ' + lang['Create Sub-Accounts at /admin'],type:'error'})
|
||||
new PNotify({
|
||||
title: lang.accountCreationError,
|
||||
text: lang['Group Key is in use.'] + ' ' + lang.createSubAccountsInfo,
|
||||
type: 'error'
|
||||
})
|
||||
}
|
||||
})
|
||||
})
|
||||
|
|
|
@ -54,8 +54,7 @@
|
|||
<ul class="nav navbar-nav navbar-right">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link logout">
|
||||
<i class="fa fa-sign-out-alt"></i>
|
||||
<p class="d-lg-none d-xl-none"><%-lang.Logout%></p>
|
||||
<p><%-lang.Logout%></p>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
@ -244,14 +243,12 @@ $.ccio.ws.on('f',function(d){
|
|||
d.msg = 'Saved Preferences'
|
||||
break;
|
||||
case'edit_account':
|
||||
d.msg='Account Edited';
|
||||
$.each(d.form,function(n,v){
|
||||
$.ccio.accounts[d.ke][n]=v
|
||||
})
|
||||
$('[ke="'+d.ke+'"] .mail').text(d.form.mail)
|
||||
break;
|
||||
case'add_account':
|
||||
d.msg='Account Created';
|
||||
$.ccio.tm(0,d,'#accounts-list')
|
||||
$.aN.selected = $.ccio.accounts[d.ke]
|
||||
break;
|
||||
|
|
Loading…
Reference in New Issue