Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Wolfgang Knopki
Spacedeck-open-SAML
Commits
92cf6c43
Commit
92cf6c43
authored
Apr 09, 2020
by
mntmn
Browse files
some cleanups to mailer and user deletion
parent
d6f93051
Changes
2
Show whitespace changes
Inline
Side-by-side
helpers/mailer.js
View file @
92cf6c43
...
...
@@ -61,33 +61,6 @@ module.exports = {
}
});
}
else
if
(
config
.
get
(
'
mail_provider
'
)
===
'
aws
'
)
{
/*
AWS.config.update({region: 'eu-west-1'});
var ses = new AWS.SES();
ses.sendEmail( {
Source: from,
Destination: { ToAddresses: [to_email] },
ReplyToAddresses: reply_to,
Message: {
Subject: {
Data: subject
},
Body: {
Text: {
Data: plaintext,
},
Html: {
Data: htmlText
}
}
}
}, function(err, data) {
if (err) console.error("Error sending email:", err);
else console.log("Email sent.");
});
*/
}
}
};
routes/api/users.js
View file @
92cf6c43
...
...
@@ -89,28 +89,31 @@ router.post('/', function(req, res) {
res
.
sendStatus
(
400
);
})
.
then
(
u
=>
{
var
home
Space
=
{
var
home
Folder
=
{
_id
:
uuidv4
(),
name
:
req
.
i18n
.
__
(
"
home
"
),
space_type
:
"
folder
"
,
creator_id
:
u
.
_id
};
db
.
Space
.
create
(
home
Space
)
db
.
Space
.
create
(
home
Folder
)
.
error
(
err
=>
{
res
.
sendStatus
(
400
);
})
.
then
(
home
Space
=>
{
u
.
home_folder_id
=
home
Space
.
_id
;
.
then
(
home
Folder
=>
{
u
.
home_folder_id
=
home
Folder
.
_id
;
u
.
save
()
.
then
(()
=>
{
res
.
status
(
201
).
json
({});
mailer
.
sendMail
(
u
.
email
,
req
.
i18n
.
__
(
"
confirm_subject
"
),
req
.
i18n
.
__
(
"
confirm_body
"
),
{
action
:
{
link
:
config
.
endpoint
+
"
/confirm/
"
+
u
.
confirmation_token
,
name
:
req
.
i18n
.
__
(
"
confirm_action
"
)
// home folder created,
// auto accept pending invites
db
.
Membership
.
update
({
"
state
"
:
"
active
"
},
{
where
:
{
"
email_invited
"
:
u
.
email
,
"
state
"
:
pending
}
});
res
.
status
(
201
).
json
({});
})
.
error
(
err
=>
{
res
.
status
(
400
).
json
(
err
);
...
...
@@ -174,36 +177,35 @@ router.post('/:id/password', function(req, res, next) {
});
});
}
else
{
res
.
status
(
403
).
json
({
"
error
"
:
"
old
password
wrong
"
});
res
.
status
(
403
).
json
({
"
error
"
:
"
Please enter the correct current
password
.
"
});
}
}
else
{
res
.
status
(
403
).
json
({
"
error
"
:
"
wrong user
"
});
res
.
status
(
403
).
json
({
"
error
"
:
"
Access denied.
"
});
}
}
else
{
res
.
status
(
400
).
json
({
"
error
"
:
"
password_to_short
"
});
res
.
status
(
400
).
json
({
"
error
"
:
"
Please choose a new password with at least 6 characters.
"
});
}
});
router
.
delete
(
'
/:id
'
,
(
req
,
res
,
next
)
=>
{
const
user
=
req
.
user
;
if
(
user
.
_id
==
req
.
params
.
id
)
{
if
(
user
.
account_type
==
'
email
'
)
{
if
(
user
.
_id
==
req
.
params
.
id
)
{
if
(
bcrypt
.
compareSync
(
req
.
query
.
password
,
user
.
password_hash
))
{
user
.
remove
((
err
)
=>
{
// TODO: this doesn't currently work.
// all objects (indirectly) belonging to the user have
// to be walked and deleted first.
user
.
destroy
().
then
(
err
=>
{
if
(
err
)
res
.
status
(
400
).
json
(
err
);
else
res
.
sendStatus
(
204
);
});
}
else
{
res
.
bad_request
(
"
password_incorrect
"
);
res
.
bad_request
(
"
Please enter the correct current password.
"
);
}
}
else
{
user
.
remove
((
err
)
=>
{
if
(
err
)
res
.
status
(
400
).
json
(
err
);
else
res
.
sendStatus
(
204
);
});
}
res
.
status
(
403
).
json
({
error
:
"
Access denied.
"
});
}
else
res
.
status
(
403
).
json
({
error
:
""
});
});
router
.
put
(
'
/:user_id/confirm
'
,
(
req
,
res
)
=>
{
...
...
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