Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
DojoBackendAPI
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Dojo Project (HES-SO)
Projects
Backend
DojoBackendAPI
Commits
81a65c52
Commit
81a65c52
authored
2 years ago
by
michael.minelli
Browse files
Options
Downloads
Patches
Plain Diff
User => Add teaching permissions test
parent
9be7c7bf
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
ExpressAPI/src/config/Config.ts
+8
-0
8 additions, 0 deletions
ExpressAPI/src/config/Config.ts
ExpressAPI/src/models/User.ts
+11
-6
11 additions, 6 deletions
ExpressAPI/src/models/User.ts
with
19 additions
and
6 deletions
ExpressAPI/src/config/Config.ts
+
8
−
0
View file @
81a65c52
...
@@ -12,6 +12,10 @@ class Config {
...
@@ -12,6 +12,10 @@ class Config {
public
readonly
jwtSecretKey
:
string
;
public
readonly
jwtSecretKey
:
string
;
public
readonly
sessionTimeout
:
number
;
public
readonly
sessionTimeout
:
number
;
public
permissions
:
{
teachingStaff
:
Array
<
string
>
;
};
public
readonly
userPasswordLength
:
number
;
public
readonly
userPasswordLength
:
number
;
public
readonly
userPasswordSaltRounds
:
number
;
public
readonly
userPasswordSaltRounds
:
number
;
...
@@ -32,6 +36,10 @@ class Config {
...
@@ -32,6 +36,10 @@ class Config {
this
.
jwtSecretKey
=
process
.
env
.
JWT_SECRET_KEY
;
this
.
jwtSecretKey
=
process
.
env
.
JWT_SECRET_KEY
;
this
.
sessionTimeout
=
Number
(
process
.
env
.
SESSION_TIMEOUT
);
this
.
sessionTimeout
=
Number
(
process
.
env
.
SESSION_TIMEOUT
);
this
.
permissions
=
{
teachingStaff
:
JSON
.
parse
(
process
.
env
.
ROLES_WITH_TEACHING_STAFF_PERMISSIONS
)
};
this
.
userPasswordLength
=
Number
(
process
.
env
.
USER_PASSWORD_LENGTH
);
this
.
userPasswordLength
=
Number
(
process
.
env
.
USER_PASSWORD_LENGTH
);
this
.
userPasswordSaltRounds
=
Number
(
process
.
env
.
USER_PASSWORD_SALT_ROUNDS
);
this
.
userPasswordSaltRounds
=
Number
(
process
.
env
.
USER_PASSWORD_SALT_ROUNDS
);
}
}
...
...
This diff is collapsed.
Click to expand it.
ExpressAPI/src/models/User.ts
+
11
−
6
View file @
81a65c52
...
@@ -29,6 +29,7 @@ class User extends Model {
...
@@ -29,6 +29,7 @@ class User extends Model {
'
lastName
'
:
this
.
userLastName
,
'
lastName
'
:
this
.
userLastName
,
'
mail
'
:
this
.
userMail
,
'
mail
'
:
this
.
userMail
,
'
role
'
:
this
.
userRole
,
'
role
'
:
this
.
userRole
,
'
isTeachingStaff
'
:
this
.
isTeachingStaff
,
'
deleted
'
:
this
.
userDeleted
'
deleted
'
:
this
.
userDeleted
};
};
...
@@ -39,6 +40,10 @@ class User extends Model {
...
@@ -39,6 +40,10 @@ class User extends Model {
return
this
.
userLastName
.
toUpperCase
()
+
'
'
+
this
.
userFirstName
;
return
this
.
userLastName
.
toUpperCase
()
+
'
'
+
this
.
userFirstName
;
}
}
get
isTeachingStaff
():
boolean
{
return
Config
.
permissions
.
teachingStaff
.
includes
(
this
.
userRole
);
}
public
importFromJsonObject
(
jsonObject
:
any
)
{
public
importFromJsonObject
(
jsonObject
:
any
)
{
this
.
userID
=
jsonObject
.
id
;
this
.
userID
=
jsonObject
.
id
;
this
.
userFirstName
=
jsonObject
.
firstName
;
this
.
userFirstName
=
jsonObject
.
firstName
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment