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
17b4fd9a
Commit
17b4fd9a
authored
Dec 13, 2019
by
GD-A-150752
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
user-model-changed
parent
eb83816b
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
28 additions
and
39 deletions
+28
-39
app.seeding.ts
server/app.seeding.ts
+2
-2
main.ts
server/main.ts
+2
-1
users.ts
server/methods/users.ts
+20
-25
user.ts
server/models/user.ts
+4
-11
No files found.
server/app.seeding.ts
View file @
17b4fd9a
...
...
@@ -21,8 +21,8 @@ export const seedDB = async () => {
Description
:
''
,
}).
toPromise
(),
Roles
.
insert
({
Title
:
'
Blocked
'
,
Permissions
:
[],
Title
:
'
User
'
,
Permissions
:
[
PERMISSIONS
.
CAN_LOGIN
,
PERMISSIONS
.
CAN_UPDATE_OWN_USER
],
Description
:
''
,
}).
toPromise
(),
]);
...
...
server/main.ts
View file @
17b4fd9a
...
...
@@ -15,7 +15,8 @@ Meteor.startup(() => {
Accounts
.
validateLoginAttempt
((
data
):
boolean
=>
{
const
user
:
User
=
data
.
user
;
return
user
&&
user
.
profile
.
Role
&&
UtilsService
.
hasPermissionOfUser
(
user
,
PERMISSIONS
.
CAN_LOGIN
);
return
user
&&
user
.
profile
.
Role
&&
UtilsService
.
hasPermissionOfUser
(
user
,
PERMISSIONS
.
CAN_LOGIN
);
});
// Changing url of reset password
...
...
server/methods/users.ts
View file @
17b4fd9a
...
...
@@ -15,31 +15,26 @@ Meteor.methods({
},
registerUser
(
usr
:
any
):
string
{
const
role
=
Roles
.
findOne
({
Slug
:
usr
.
Role
});
registerUser
(
user
:
any
):
string
{
const
myRole
=
Roles
.
findOne
({
Title
:
user
.
role
});
if
(
!
Accounts
.
findUserByEmail
(
user
.
email
))
{
if
(
role
)
{
if
(
!
Accounts
.
findUserByEmail
(
usr
.
Email
))
{
const
user
:
User
=
{
email
:
usr
.
Email
,
password
:
usr
.
Password
,
username
:
usr
.
Email
,
profile
:
{
FirstName
:
usr
.
FirstName
,
LastName
:
usr
.
LastName
,
Role
:
role
.
_id
,
OriginalRole
:
role
.
_id
,
Status
:
usr
.
Status
,
},
};
const
createdUserId
=
Accounts
.
createUser
(
user
);
return
createdUserId
;
}
throw
new
Meteor
.
Error
(
422
,
'Email address already in use.'
);
const
userObj
=
{
email
:
user
.
email
,
password
:
user
.
password
,
username
:
user
.
username
,
profile
:
{
Name
:
user
.
name
,
Email
:
user
.
email
,
Password
:
user
.
password
,
Role
:
myRole
.
_id
,
Status
:
user
.
status
,
RoleObj
:
myRole
,
},
};
return
Accounts
.
createUser
(
userObj
);
}
throw
new
Meteor
.
Error
(
4
03
,
'Not Enough Permissions
'
);
throw
new
Meteor
.
Error
(
4
22
,
'Email address already in use.
'
);
},
updateUser
(
user
:
User
):
any
{
...
...
@@ -72,9 +67,9 @@ Meteor.methods({
async
enableUser
(
user
:
User
):
Promise
<
any
>
{
if
(
UtilsService
.
hasPermission
(
PERMISSIONS
.
CAN_UPDATE_USER
))
{
const
role
=
Roles
.
findOne
({
Slug
:
user
.
profile
.
OriginalRole
});
//
const role = Roles.findOne({ Slug: user.profile.OriginalRole });
const
usr
=
Meteor
.
users
.
findOne
(
user
.
_id
);
usr
.
profile
.
Role
=
role
.
_id
;
//
usr.profile.Role = role._id;
return
Meteor
.
users
.
update
(
user
.
_id
,
usr
);
}
...
...
server/models/user.ts
View file @
17b4fd9a
...
...
@@ -7,23 +7,16 @@ export interface User {
password
?:
string
;
username
?:
string
;
profile
?:
UserProfile
;
Role
?:
any
;
OldPassword
?:
string
;
NewPassword
?:
string
;
ConfirmNewPassword
?:
string
;
}
export
interface
UserProfile
{
FirstName
?:
string
;
LastName
?:
string
;
Role
?:
string
;
OriginalRole
?:
string
;
RoleTitle
?:
string
;
Name
?:
string
;
Email
:
string
;
Password
:
string
;
Role
:
string
;
RoleObj
?:
Role
;
AccountActiveUntil
?:
Date
;
Phone
?:
string
;
Address
?:
string
;
Email
?:
string
;
Password
?:
string
;
Status
?:
'ACTIVE'
|
'DISABLED'
;
}
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