Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
persona
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Hexang 息壤平台
persona
Commits
d625a4cd
Commit
d625a4cd
authored
12 years ago
by
Lloyd Hilaiel
Browse files
Options
Downloads
Patches
Plain Diff
issue #1592 - email_for_token returns need_password: true when no password has been chosen.
parent
82bf7de2
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
lib/db/json.js
+1
-1
1 addition, 1 deletion
lib/db/json.js
lib/db/mysql.js
+2
-2
2 additions, 2 deletions
lib/db/mysql.js
lib/wsapi/email_for_token.js
+55
-15
55 additions, 15 deletions
lib/wsapi/email_for_token.js
with
58 additions
and
18 deletions
lib/db/json.js
+
1
−
1
View file @
d625a4cd
...
@@ -236,7 +236,7 @@ exports.emailForVerificationSecret = function(secret, cb) {
...
@@ -236,7 +236,7 @@ exports.emailForVerificationSecret = function(secret, cb) {
process
.
nextTick
(
function
()
{
process
.
nextTick
(
function
()
{
sync
();
sync
();
if
(
!
db
.
staged
[
secret
])
return
cb
(
"
no such secret
"
);
if
(
!
db
.
staged
[
secret
])
return
cb
(
"
no such secret
"
);
cb
(
null
,
db
.
staged
[
secret
].
email
,
db
.
staged
[
secret
].
existing_user
);
cb
(
null
,
db
.
staged
[
secret
].
email
,
db
.
staged
[
secret
].
existing_user
,
db
.
staged
[
secret
].
passwd
);
});
});
};
};
...
...
This diff is collapsed.
Click to expand it.
lib/db/mysql.js
+
2
−
2
View file @
d625a4cd
...
@@ -265,14 +265,14 @@ exports.haveVerificationSecret = function(secret, cb) {
...
@@ -265,14 +265,14 @@ exports.haveVerificationSecret = function(secret, cb) {
exports
.
emailForVerificationSecret
=
function
(
secret
,
cb
)
{
exports
.
emailForVerificationSecret
=
function
(
secret
,
cb
)
{
client
.
query
(
client
.
query
(
"
SELECT email, existing_user FROM staged WHERE secret = ?
"
,
[
secret
],
"
SELECT email, existing_user
, passwd
FROM staged WHERE secret = ?
"
,
[
secret
],
function
(
err
,
rows
)
{
function
(
err
,
rows
)
{
if
(
err
)
return
cb
(
"
database unavailable
"
);
if
(
err
)
return
cb
(
"
database unavailable
"
);
// if the record was not found, fail out
// if the record was not found, fail out
if
(
!
rows
||
rows
.
length
!=
1
)
return
cb
(
"
no such secret
"
);
if
(
!
rows
||
rows
.
length
!=
1
)
return
cb
(
"
no such secret
"
);
cb
(
null
,
rows
[
0
].
email
,
rows
[
0
].
existing_user
);
cb
(
null
,
rows
[
0
].
email
,
rows
[
0
].
existing_user
,
rows
[
0
].
passwd
);
});
});
};
};
...
...
This diff is collapsed.
Click to expand it.
lib/wsapi/email_for_token.js
+
55
−
15
View file @
d625a4cd
...
@@ -19,7 +19,7 @@ exports.args = ['token'];
...
@@ -19,7 +19,7 @@ exports.args = ['token'];
exports
.
i18n
=
false
;
exports
.
i18n
=
false
;
exports
.
process
=
function
(
req
,
res
)
{
exports
.
process
=
function
(
req
,
res
)
{
db
.
emailForVerificationSecret
(
req
.
query
.
token
,
function
(
err
,
email
,
uid
)
{
db
.
emailForVerificationSecret
(
req
.
query
.
token
,
function
(
err
,
email
,
uid
,
hash
)
{
if
(
err
)
{
if
(
err
)
{
if
(
err
===
'
database unavailable
'
)
{
if
(
err
===
'
database unavailable
'
)
{
httputils
.
serviceUnavailable
(
res
,
err
);
httputils
.
serviceUnavailable
(
res
,
err
);
...
@@ -30,24 +30,64 @@ exports.process = function(req, res) {
...
@@ -30,24 +30,64 @@ exports.process = function(req, res) {
});
});
}
}
}
else
{
}
else
{
// must the user authenticate? This is true if they are not authenticated
function
checkMustAuth
()
{
// as the uid who initiated the verification, and they are not on the same
// must the user authenticate? This is true if they are not authenticated
// browser as the initiator
// as the uid who initiated the verification, and they are not on the same
var
must_auth
=
true
;
// browser as the initiator
var
must_auth
=
true
;
if
(
uid
&&
req
.
session
.
userid
===
uid
)
{
if
(
uid
&&
req
.
session
.
userid
===
uid
)
{
must_auth
=
false
;
must_auth
=
false
;
}
else
if
(
!
uid
&&
typeof
req
.
session
.
pendingCreation
===
'
string
'
&&
req
.
query
.
token
===
req
.
session
.
pendingCreation
)
{
must_auth
=
false
;
}
res
.
json
({
success
:
true
,
email
:
email
,
must_auth
:
must_auth
});
}
// backwards compatibility - issue #1592
// if there is no password in the user record, and no password in the staged
// table, then we require a password be fetched from the user upon verification.
// these checks are temporary and should disappear in 1 trains time.
function
needsPassword
()
{
// no password is set neither in the user table nor in the staged record.
// the user must pick a password
res
.
json
({
success
:
true
,
email
:
email
,
needs_password
:
true
});
}
}
else
if
(
!
uid
&&
typeof
req
.
session
.
pendingCreation
===
'
string
'
&&
req
.
query
.
token
===
req
.
session
.
pendingCreation
)
{
if
(
!
hash
)
{
must_auth
=
false
;
if
(
!
uid
)
{
needsPassword
();
}
else
{
db
.
checkAuth
(
uid
,
function
(
err
,
hash
)
{
if
(
err
)
{
return
res
.
json
({
success
:
false
,
reason
:
err
});
}
if
(
!
hash
)
{
needsPassword
();
}
else
{
checkMustAuth
();
}
});
}
}
else
{
checkMustAuth
();
}
}
res
.
json
({
success
:
true
,
email
:
email
,
must_auth
:
must_auth
});
}
}
});
});
};
};
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