Skip to content
GitLab
Explore
Projects
Groups
Snippets
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
m4lab_tv1
User Account
Commits
9b8cdb72
Commit
9b8cdb72
authored
4 years ago
by
Rosanny Sihombing
Browse files
Options
Download
Email Patches
Plain Diff
gitlab activation: the skeleton
parent
d61008fd
master
MLAB-677
devel
reset-jul13
reset-merge
testing
6 merge requests
!143
updating yml config
,
!91
Prepare prod
,
!90
Testing
,
!89
Testing
,
!67
Testing
,
!66
Mlab 183
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
routes/methods.js
+20
-1
routes/methods.js
routes/routes-account.js
+29
-0
routes/routes-account.js
with
49 additions
and
1 deletion
+49
-1
routes/methods.js
+
20
-
1
View file @
9b8cdb72
...
...
@@ -69,7 +69,7 @@ var methods = {
})
},
getUserByEmail
:
function
(
email
,
callback
)
{
dbconn
.
user
.
query
(
'
SELECT verificationStatus, salutation, title, firstname, lastname, industry, organisation, speciality, m4lab_idp FROM user WHERE email = "
'
+
email
+
'
"
'
,
function
(
err
,
rows
,
fields
)
{
dbconn
.
user
.
query
(
'
SELECT
id,
verificationStatus, salutation, title, firstname, lastname, industry, organisation, speciality, m4lab_idp FROM user WHERE email = "
'
+
email
+
'
"
'
,
function
(
err
,
rows
,
fields
)
{
if
(
err
)
{
throw
err
;
}
...
...
@@ -212,6 +212,25 @@ var methods = {
})
callback
(
err
)
})
},
/* ===== GitLab ===== */
getGitlabId
:
function
(
userId
,
callback
){
let
gitlabUserId
dbconn
.
user
.
query
(
'
SELECT gu.gitlab_userId FROM user_gitlab gu, user u WHERE u.id = "
'
+
userId
+
'
" and gu.user_id = u.id
'
,
function
(
err
,
rows
)
{
if
(
err
)
{
throw
err
}
else
if
(
rows
[
0
])
{
gitlabUserId
=
rows
[
0
].
gitlab_userId
}
callback
(
gitlabUserId
,
err
)
})
},
addGitlabUser
:
function
(
data
,
callback
){
dbconn
.
user
.
query
(
'
INSERT INTO user_gitlab SET ?
'
,
data
,
function
(
err
)
{
if
(
err
)
throw
err
callback
(
err
)
})
}
};
...
...
This diff is collapsed.
Click to expand it.
routes/routes-account.js
+
29
-
0
View file @
9b8cdb72
...
...
@@ -10,6 +10,7 @@ const salt = 64; // salt length
const
async
=
require
(
'
async
'
)
const
crypto
=
require
(
'
crypto
'
)
const
mailer
=
require
(
'
./mailer
'
)
const
superagent
=
require
(
'
superagent
'
)
module
.
exports
=
function
(
app
,
config
,
passport
,
i18n
)
{
...
...
@@ -180,6 +181,34 @@ module.exports = function (app, config, passport, i18n) {
methods
.
getUserByEmail
(
req
.
user
.
email
,
function
(
data
,
err
){
if
(
!
err
)
{
if
(
data
.
verificationStatus
==
1
)
{
// start =============== RS: MLAB-183
let
userId
=
data
.
id
methods
.
getGitlabId
(
userId
,
function
(
data
,
err
){
if
(
!
err
)
{
if
(
data
)
{
console
.
log
(
"
TODO: GitLab is already activated for this user. Allow project creation.
"
)
}
else
{
superagent
.
get
(
'
https://transfer.hft-stuttgart.de/gitlab/api/v4/users?private_token=
'
+
config
.
gitlab
.
token_readWriteProjects
+
'
&search=
'
+
req
.
user
.
email
)
.
then
(
res
=>
{
if
(
res
.
body
.
length
>
0
)
{
let
gitlabActivationData
=
{
user_id
:
userId
,
gitlab_userId
:
res
.
body
[
0
].
id
}
methods
.
addGitlabUser
(
gitlabActivationData
,
function
(
err
){})
}
else
{
console
.
log
(
'
TODO: Show gitlab activation button: transfer.hft-stuttgart.de/gitlab
'
)
}
})
.
catch
(
err
=>
{
console
.
log
(
err
.
message
)
});
}
}
})
// end =============== RS: MLAB-183
res
.
render
(
lang
+
'
/account/services
'
,
{
user
:
data
});
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment
Menu
Explore
Projects
Groups
Snippets