Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
openvpn-app
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
cloudron
openvpn-app
Commits
12a90d09
Commit
12a90d09
authored
Sep 24, 2020
by
Girish Ramakrishnan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make it getConfig
parent
0cd54219
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
5 deletions
+3
-5
server.js
server.js
+3
-5
No files found.
server.js
View file @
12a90d09
...
...
@@ -31,13 +31,13 @@ const OPENVPN_SETTINGS_FILE_PATH = path.join(baseDir, 'openvpn.conf');
console
.
log
(
`Using app config file at
${
CONFIG_FILE_PATH
}
`
);
console
.
log
(
`Using OpenVPN settings file at
${
OPENVPN_SETTINGS_FILE_PATH
}
`
);
function
reload
Config
()
{
function
get
Config
()
{
let
config
=
{};
try
{
config
=
ini
.
parse
(
fs
.
readFileSync
(
CONFIG_FILE_PATH
,
'
utf-8
'
));
}
catch
(
e
)
{
console
.
log
(
'
No config file found, creating empty one
'
);
fs
.
writeFileSync
(
CONFIG_FILE_PATH
,
'
[roles]
\n
#admins=username1,username2
\n
'
);
fs
.
writeFileSync
(
CONFIG_FILE_PATH
,
'
[roles]
\n
#
Restart the app and re-login for role change to take effect
\n
#
admins=username1,username2
\n
'
);
}
config
.
roles
=
config
.
roles
||
{};
config
.
roles
.
admins
=
config
.
roles
.
admins
||
''
;
...
...
@@ -46,8 +46,6 @@ function reloadConfig() {
return
config
;
}
let
config
=
reloadConfig
();
// This only fetches the settings supported by the UI
function
getOpenVPNSetting
()
{
let
settings
=
{};
...
...
@@ -157,7 +155,7 @@ router.post('/api/login', jsonParser, (req, res, next) => {
ldap
.
auth
(
req
.
body
.
username
,
req
.
body
.
password
)
.
then
(
profile
=>
{
// on login check for new roles
con
fig
=
reload
Config
();
con
st
config
=
get
Config
();
profile
.
isAdmin
=
config
.
roles
.
admins
.
indexOf
(
profile
.
username
)
!==
-
1
;
...
...
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