Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wiki-js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
wiki-js
Commits
849d4f47
Commit
849d4f47
authored
Apr 28, 2019
by
Nick
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: twitch auth module
parent
d80bb928
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
11 deletions
+20
-11
users.js
server/models/users.js
+2
-2
authentication.js
server/modules/authentication/twitch/authentication.js
+15
-8
definition.yml
server/modules/authentication/twitch/definition.yml
+3
-1
No files found.
server/models/users.js
View file @
849d4f47
...
@@ -160,7 +160,7 @@ module.exports = class User extends Model {
...
@@ -160,7 +160,7 @@ module.exports = class User extends Model {
// Find existing user
// Find existing user
let
user
=
await
WIKI
.
models
.
users
.
query
().
findOne
({
let
user
=
await
WIKI
.
models
.
users
.
query
().
findOne
({
providerId
:
profile
.
id
,
providerId
:
_
.
toString
(
profile
.
id
)
,
providerKey
providerKey
})
})
...
@@ -224,7 +224,7 @@ module.exports = class User extends Model {
...
@@ -224,7 +224,7 @@ module.exports = class User extends Model {
// Create account
// Create account
user
=
await
WIKI
.
models
.
users
.
query
().
insertAndFetch
({
user
=
await
WIKI
.
models
.
users
.
query
().
insertAndFetch
({
providerKey
:
providerKey
,
providerKey
:
providerKey
,
providerId
:
profile
.
id
,
providerId
:
_
.
toString
(
profile
.
id
)
,
email
:
primaryEmail
,
email
:
primaryEmail
,
name
:
displayName
,
name
:
displayName
,
pictureUrl
:
pictureUrl
,
pictureUrl
:
pictureUrl
,
...
...
server/modules/authentication/twitch/authentication.js
View file @
849d4f47
...
@@ -5,6 +5,7 @@
...
@@ -5,6 +5,7 @@
// ------------------------------------
// ------------------------------------
const
TwitchStrategy
=
require
(
'passport-twitch'
).
Strategy
const
TwitchStrategy
=
require
(
'passport-twitch'
).
Strategy
const
_
=
require
(
'lodash'
)
module
.
exports
=
{
module
.
exports
=
{
init
(
passport
,
conf
)
{
init
(
passport
,
conf
)
{
...
@@ -12,14 +13,20 @@ module.exports = {
...
@@ -12,14 +13,20 @@ module.exports = {
new
TwitchStrategy
({
new
TwitchStrategy
({
clientID
:
conf
.
clientId
,
clientID
:
conf
.
clientId
,
clientSecret
:
conf
.
clientSecret
,
clientSecret
:
conf
.
clientSecret
,
callbackURL
:
conf
.
callbackURL
,
callbackURL
:
conf
.
callbackURL
scope
:
'user_read'
},
async
(
accessToken
,
refreshToken
,
profile
,
cb
)
=>
{
},
function
(
accessToken
,
refreshToken
,
profile
,
cb
)
{
try
{
WIKI
.
models
.
users
.
processProfile
(
profile
).
then
((
user
)
=>
{
const
user
=
await
WIKI
.
models
.
users
.
processProfile
({
return
cb
(
null
,
user
)
||
true
profile
:
{
}).
catch
((
err
)
=>
{
...
profile
,
return
cb
(
err
,
null
)
||
true
picture
:
_
.
get
(
profile
,
'_json.logo'
,
''
)
})
},
providerKey
:
'twitch'
})
cb
(
null
,
user
)
}
catch
(
err
)
{
cb
(
err
,
null
)
}
}
}
))
))
}
}
...
...
server/modules/authentication/twitch/definition.yml
View file @
849d4f47
...
@@ -5,8 +5,10 @@ author: requarks.io
...
@@ -5,8 +5,10 @@ author: requarks.io
logo
:
https://static.requarks.io/logo/twitch.svg
logo
:
https://static.requarks.io/logo/twitch.svg
color
:
indigo darken-2
color
:
indigo darken-2
website
:
https://dev.twitch.tv/docs/authentication/
website
:
https://dev.twitch.tv/docs/authentication/
isAvailable
:
fals
e
isAvailable
:
tru
e
useForm
:
false
useForm
:
false
scopes
:
-
user_read
props
:
props
:
clientId
:
clientId
:
type
:
String
type
:
String
...
...
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