Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
api
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Merge Requests
0
Merge Requests
0
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
angular-meteor
api
Commits
44a764a1
Commit
44a764a1
authored
Dec 26, 2019
by
GD-A-150752
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
change-user-status
parent
7f6f70bc
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
0 deletions
+26
-0
config.ts
server/config.ts
+1
-0
users.method.ts
server/methods/users.method.ts
+25
-0
No files found.
server/config.ts
View file @
44a764a1
...
@@ -9,6 +9,7 @@ export const PERMISSIONS = {
...
@@ -9,6 +9,7 @@ export const PERMISSIONS = {
CAN_ACCESS_SETTINGS
:
'CAN_ACCESS_SETTINGS'
,
CAN_ACCESS_SETTINGS
:
'CAN_ACCESS_SETTINGS'
,
CAN_ACCESS_EMAIL_TEMPLATES
:
'CAN_ACCESS_EMAIL_TEMPLATES'
,
CAN_ACCESS_EMAIL_TEMPLATES
:
'CAN_ACCESS_EMAIL_TEMPLATES'
,
CAN_UPDATE_ALL_USERS
:
'CAN_UPDATE_ALL_USERS'
,
CAN_UPDATE_ALL_USERS
:
'CAN_UPDATE_ALL_USERS'
,
CAN_ACCESS_USERS_PAGE
:
'CAN_ACCESS_USERS_PAGE'
,
};
};
export
const
CONFIG
=
{
export
const
CONFIG
=
{
...
...
server/methods/users.method.ts
View file @
44a764a1
...
@@ -3,9 +3,17 @@ import { rolesCollection } from '../collections/role.collection';
...
@@ -3,9 +3,17 @@ import { rolesCollection } from '../collections/role.collection';
import
{
ERR
,
E_CODE
,
PERMISSIONS
}
from
'../config'
;
import
{
ERR
,
E_CODE
,
PERMISSIONS
}
from
'../config'
;
import
{
UtilsService
}
from
'../services/utils.service'
;
import
{
UtilsService
}
from
'../services/utils.service'
;
import
{
EmailService
}
from
'../services/email.service'
;
import
{
EmailService
}
from
'../services/email.service'
;
import
{
QueryModel
}
from
'../models/query.model'
;
Meteor
.
methods
({
Meteor
.
methods
({
usersGetCount
(
query
:
QueryModel
):
any
{
return
{
recordsFiltered
:
Meteor
.
users
.
find
(
query
.
query
).
count
(),
recordsTotal
:
Meteor
.
users
.
find
().
count
(),
};
},
registerUser
(
user
:
any
):
string
{
registerUser
(
user
:
any
):
string
{
const
defaultRole
=
rolesCollection
.
findOne
({
title
:
user
.
role
});
const
defaultRole
=
rolesCollection
.
findOne
({
title
:
user
.
role
});
...
@@ -96,4 +104,21 @@ Meteor.methods({
...
@@ -96,4 +104,21 @@ Meteor.methods({
return
Accounts
.
findUserByEmail
(
email
);
return
Accounts
.
findUserByEmail
(
email
);
},
},
switchUser
(
user
:
Meteor
.
User
,
block
=
false
):
any
{
if
(
UtilsService
.
hasPermission
(
PERMISSIONS
.
CAN_UPDATE_USER
))
{
if
(
block
)
{
const
disableRole
=
rolesCollection
.
findOne
({
title
:
'Blocked'
});
user
.
profile
.
originalRole
=
user
.
profile
.
role
;
user
.
profile
.
role
=
disableRole
.
_id
;
}
else
{
user
.
profile
.
role
=
user
.
profile
.
originalRole
;
delete
user
.
profile
.
originalRole
;
}
return
Meteor
.
users
.
update
(
user
.
_id
,
user
);
}
throw
new
Meteor
.
Error
(
E_CODE
.
FORBIDDEN
,
ERR
.
FORBIDDEN
);
},
});
});
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment