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
d2151f9b
Commit
d2151f9b
authored
13 years ago
by
Lloyd Hilaiel
Browse files
Options
Downloads
Patches
Plain Diff
improve logging when user authentication fails - related to issue #681
parent
78cbbd26
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/wsapi/authenticate_user.js
+17
-6
17 additions, 6 deletions
lib/wsapi/authenticate_user.js
with
17 additions
and
6 deletions
lib/wsapi/authenticate_user.js
+
17
−
6
View file @
d2151f9b
...
...
@@ -14,18 +14,29 @@ exports.authed = false;
exports
.
args
=
[
'
email
'
,
'
pass
'
];
exports
.
process
=
function
(
req
,
res
)
{
function
fail
(
reason
)
{
var
r
=
{
success
:
false
};
if
(
reason
)
r
.
reason
=
reason
;
logger
.
debug
(
'
authentication fails for user:
'
+
req
.
body
.
email
);
return
res
.
json
(
r
);
}
db
.
checkAuth
(
req
.
body
.
email
,
function
(
hash
)
{
if
(
typeof
hash
!==
'
string
'
||
typeof
req
.
body
.
pass
!==
'
string
'
)
{
return
res
.
json
({
success
:
false
});
if
(
typeof
hash
!==
'
string
'
)
{
return
fail
(
'
no such user
'
);
}
// this should never be false because higher level code checks, but
// let's check again! whee!
if
(
typeof
req
.
body
.
pass
!==
'
string
'
)
{
return
fail
(
'
missing "pass" argument
'
);
}
bcrypt
.
compare
(
req
.
body
.
pass
,
hash
,
function
(
err
,
success
)
{
if
(
err
)
{
logger
.
warn
(
"
error comparing passwords with bcrypt:
"
+
err
);
re
s
.
json
({
success
:
false
}
);
logger
.
error
(
"
error comparing passwords with bcrypt:
"
+
err
);
re
turn
fail
(
"
internal password check error
"
);
}
else
if
(
!
success
)
{
re
s
.
json
({
success
:
false
}
);
re
turn
fail
(
"
mismatch
"
);
}
else
{
if
(
!
req
.
session
)
req
.
session
=
{};
wsapi
.
setAuthenticatedUser
(
req
.
session
,
req
.
body
.
email
);
...
...
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