FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
node-stack/github-auth.js at master · cherifya/node-stack · GitHub
cherifya
/
node-stack
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
2
Code
Issues
0
Pull requests
0
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
node-stack
/
github-auth.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
67 lines (53 loc) · 1.97 KB
Breadcrumbs
node-stack
/
github-auth.js
Copy path
File metadata and controls
67 lines (53 loc) · 1.97 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
var
everyauth
=
require
(
'everyauth'
)
,
conf
=
require
(
'./conf'
)
,
Users
=
require
(
'./models/users'
)
,
request
=
require
(
'request'
)
,
logger
=
require
(
'tracer'
)
.
console
(
{
level
:
conf
.
app
.
logLevel
}
)
;
module
.
exports
=
function
(
)
{
/**
* EVERYAUTH AUTHENTICATION
* -------------------------------------------------------------------------------------------------
* allows users to log in and register using OAuth services
**/
everyauth
.
debug
=
true
;
// Configure Facebook auth
var
usersById
=
{
}
,
nextUserId
=
0
,
usersByFacebookId
=
{
}
,
usersByTwitId
=
{
}
,
usersByGhId
=
{
}
;
everyauth
.
everymodule
.
findUserById
(
function
(
id
,
callback
)
{
Users
.
find
(
id
,
function
(
err
,
user
)
{
//console.log("Find user. typeof id:", typeof id);
//console.log("Found user ", user);
//Jugglingdb-mongo replace ids by their string representation
//We don't want that or it will mess up our queries down the line
if
(
typeof
user
.
id
===
'string'
)
{
user
.
id
=
Users
.
schema
.
ObjectID
(
user
.
id
)
;
}
callback
(
err
,
user
)
;
}
)
;
//callback(null, usersById[id]);
}
)
;
everyauth
.
github
.
scope
(
'repo'
)
.
appId
(
conf
.
github
.
appId
)
.
appSecret
(
conf
.
github
.
appSecret
)
.
findOrCreateUser
(
function
(
sess
,
accessToken
,
accessTokenExtra
,
ghUser
)
{
var
promise
=
this
.
Promise
(
)
;
Users
.
findOrCreateUser
(
accessToken
,
ghUser
,
promise
)
;
promise
.
callback
(
function
(
value
)
{
var
user
=
value
;
logger
.
log
(
"Registered user: "
,
user
)
;
//console.log("Typeof id:", typeof user.id);
//update user's repos
user
.
refreshStars
(
)
;
}
)
;
return
promise
;
}
)
.
redirectPath
(
'/'
)
;
logger
.
log
(
'Github auth support activated...'
)
;
}
;
Back
|
FazBrowse Home
|
New Git URL