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
4b042821
Commit
4b042821
authored
Jun 17, 2018
by
NGPixel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: client login
parent
197b6b41
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
41 additions
and
43 deletions
+41
-43
login.vue
client/components/login.vue
+31
-33
login-mutation-login.gql
client/graph/login-mutation-login.gql
+2
-2
login-query-strategies.gql
client/graph/login-query-strategies.gql
+1
-1
henry-reading.svg
client/static/svg/henry-reading.svg
+0
-0
users.js
server/db/models/users.js
+2
-2
authentication.js
server/graph/resolvers/authentication.js
+1
-1
authentication.graphql
server/graph/schemas/authentication.graphql
+2
-2
sync-graph-locales.js
server/jobs/sync-graph-locales.js
+1
-1
auth.js
server/middlewares/auth.js
+1
-1
No files found.
client/components/login.vue
View file @
4b042821
...
@@ -86,10 +86,12 @@ export default {
...
@@ -86,10 +86,12 @@ export default {
}
}
},
},
mounted
()
{
mounted
()
{
this
.
refreshStrategies
()
this
.
$refs
.
iptEmail
.
focus
()
this
.
$refs
.
iptEmail
.
focus
()
},
},
methods
:
{
methods
:
{
/**
* SELECT STRATEGY
*/
selectStrategy
(
key
,
useForm
)
{
selectStrategy
(
key
,
useForm
)
{
this
.
selectedStrategy
=
key
this
.
selectedStrategy
=
key
this
.
screen
=
'login'
this
.
screen
=
'login'
...
@@ -100,28 +102,10 @@ export default {
...
@@ -100,28 +102,10 @@ export default {
this
.
$refs
.
iptEmail
.
focus
()
this
.
$refs
.
iptEmail
.
focus
()
}
}
},
},
refreshStrategies
()
{
/**
this
.
isLoading
=
true
* LOGIN
this
.
$apollo
.
query
({
*/
query
:
strategiesQuery
async
login
()
{
}).
then
(
resp
=>
{
if
(
_
.
has
(
resp
,
'data.authentication.providers'
))
{
this
.
strategies
=
_
.
get
(
resp
,
'data.authentication.providers'
,
[])
}
else
{
throw
new
Error
(
'No authentication providers available!'
)
}
this
.
isLoading
=
false
}).
catch
(
err
=>
{
console
.
error
(
err
)
this
.
$store
.
commit
(
'showNotification'
,
{
style
:
'red'
,
message
:
err
.
message
,
icon
:
'warning'
})
this
.
isLoading
=
false
})
},
login
()
{
if
(
this
.
username
.
length
<
2
)
{
if
(
this
.
username
.
length
<
2
)
{
this
.
$store
.
commit
(
'showNotification'
,
{
this
.
$store
.
commit
(
'showNotification'
,
{
style
:
'red'
,
style
:
'red'
,
...
@@ -138,14 +122,15 @@ export default {
...
@@ -138,14 +122,15 @@ export default {
this
.
$refs
.
iptPassword
.
focus
()
this
.
$refs
.
iptPassword
.
focus
()
}
else
{
}
else
{
this
.
isLoading
=
true
this
.
isLoading
=
true
this
.
$apollo
.
mutate
({
try
{
mutation
:
loginMutation
,
let
resp
=
await
this
.
$apollo
.
mutate
({
variables
:
{
mutation
:
loginMutation
,
username
:
this
.
username
,
variables
:
{
password
:
this
.
password
,
username
:
this
.
username
,
provider
:
this
.
selectedStrategy
password
:
this
.
password
,
}
strategy
:
this
.
selectedStrategy
}).
then
(
resp
=>
{
}
})
if
(
_
.
has
(
resp
,
'data.authentication.login'
))
{
if
(
_
.
has
(
resp
,
'data.authentication.login'
))
{
let
respObj
=
_
.
get
(
resp
,
'data.authentication.login'
,
{})
let
respObj
=
_
.
get
(
resp
,
'data.authentication.login'
,
{})
if
(
respObj
.
responseResult
.
succeeded
===
true
)
{
if
(
respObj
.
responseResult
.
succeeded
===
true
)
{
...
@@ -173,7 +158,7 @@ export default {
...
@@ -173,7 +158,7 @@ export default {
}
else
{
}
else
{
throw
new
Error
(
'Authentication is unavailable.'
)
throw
new
Error
(
'Authentication is unavailable.'
)
}
}
}
).
catch
(
err
=>
{
}
catch
(
err
)
{
console
.
error
(
err
)
console
.
error
(
err
)
this
.
$store
.
commit
(
'showNotification'
,
{
this
.
$store
.
commit
(
'showNotification'
,
{
style
:
'red'
,
style
:
'red'
,
...
@@ -181,9 +166,12 @@ export default {
...
@@ -181,9 +166,12 @@ export default {
icon
:
'warning'
icon
:
'warning'
})
})
this
.
isLoading
=
false
this
.
isLoading
=
false
}
)
}
}
}
},
},
/**
* VERIFY TFA CODE
*/
verifySecurityCode
()
{
verifySecurityCode
()
{
if
(
this
.
securityCode
.
length
!==
6
)
{
if
(
this
.
securityCode
.
length
!==
6
)
{
this
.
$store
.
commit
(
'showNotification'
,
{
this
.
$store
.
commit
(
'showNotification'
,
{
...
@@ -230,6 +218,16 @@ export default {
...
@@ -230,6 +218,16 @@ export default {
})
})
}
}
}
}
},
apollo
:
{
strategies
:
{
query
:
strategiesQuery
,
update
:
(
data
)
=>
data
.
authentication
.
strategies
,
watchLoading
(
isLoading
)
{
this
.
isLoading
=
isLoading
this
.
$store
.
commit
(
`loading
${
isLoading
?
'Start'
:
'Stop'
}
`
,
'login-strategies-refresh'
)
}
}
}
}
}
}
</
script
>
</
script
>
...
...
client/graph/login-mutation-login.gql
View file @
4b042821
mutation
(
$username
:
String
!,
$password
:
String
!,
$
provider
:
String
!)
{
mutation
(
$username
:
String
!,
$password
:
String
!,
$
strategy
:
String
!)
{
authentication
{
authentication
{
login
(
username
:
$username
,
password
:
$password
,
provider
:
$provider
)
{
login
(
username
:
$username
,
password
:
$password
,
strategy
:
$strategy
)
{
responseResult
{
responseResult
{
succeeded
succeeded
errorCode
errorCode
...
...
client/graph/login-query-strategies.gql
View file @
4b042821
query
{
query
{
authentication
{
authentication
{
provider
s
(
strategie
s
(
filter
:
"isEnabled eq true"
,
filter
:
"isEnabled eq true"
,
orderBy
:
"title ASC"
orderBy
:
"title ASC"
)
{
)
{
...
...
client/static/svg/henry-reading.svg
View file @
4b042821
This diff is collapsed.
Click to expand it.
server/db/models/users.js
View file @
4b042821
...
@@ -171,13 +171,13 @@ module.exports = class User extends Model {
...
@@ -171,13 +171,13 @@ module.exports = class User extends Model {
}
}
static
async
login
(
opts
,
context
)
{
static
async
login
(
opts
,
context
)
{
if
(
_
.
has
(
WIKI
.
config
.
auth
.
strategies
,
opts
.
provider
))
{
if
(
_
.
has
(
WIKI
.
auth
.
strategies
,
opts
.
strategy
))
{
_
.
set
(
context
.
req
,
'body.email'
,
opts
.
username
)
_
.
set
(
context
.
req
,
'body.email'
,
opts
.
username
)
_
.
set
(
context
.
req
,
'body.password'
,
opts
.
password
)
_
.
set
(
context
.
req
,
'body.password'
,
opts
.
password
)
// Authenticate
// Authenticate
return
new
Promise
((
resolve
,
reject
)
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
WIKI
.
auth
.
passport
.
authenticate
(
opts
.
provider
,
async
(
err
,
user
,
info
)
=>
{
WIKI
.
auth
.
passport
.
authenticate
(
opts
.
strategy
,
async
(
err
,
user
,
info
)
=>
{
if
(
err
)
{
return
reject
(
err
)
}
if
(
err
)
{
return
reject
(
err
)
}
if
(
!
user
)
{
return
reject
(
new
WIKI
.
Error
.
AuthLoginFailed
())
}
if
(
!
user
)
{
return
reject
(
new
WIKI
.
Error
.
AuthLoginFailed
())
}
...
...
server/graph/resolvers/authentication.js
View file @
4b042821
...
@@ -16,7 +16,7 @@ module.exports = {
...
@@ -16,7 +16,7 @@ module.exports = {
},
},
AuthenticationQuery
:
{
AuthenticationQuery
:
{
async
strategies
(
obj
,
args
,
context
,
info
)
{
async
strategies
(
obj
,
args
,
context
,
info
)
{
let
strategies
=
await
WIKI
.
db
.
authentication
.
query
().
orderBy
(
'title'
)
let
strategies
=
await
WIKI
.
db
.
authentication
.
getEnabledStrategies
(
)
strategies
=
strategies
.
map
(
stg
=>
({
strategies
=
strategies
.
map
(
stg
=>
({
...
stg
,
...
stg
,
config
:
_
.
transform
(
stg
.
config
,
(
res
,
value
,
key
)
=>
{
config
:
_
.
transform
(
stg
.
config
,
(
res
,
value
,
key
)
=>
{
...
...
server/graph/schemas/authentication.graphql
View file @
4b042821
...
@@ -29,7 +29,7 @@ type AuthenticationMutation {
...
@@ -29,7 +29,7 @@ type AuthenticationMutation {
login
(
login
(
username
:
String
!
username
:
String
!
password
:
String
!
password
:
String
!
provider
:
String
!
strategy
:
String
!
):
AuthenticationLoginResponse
):
AuthenticationLoginResponse
loginTFA
(
loginTFA
(
...
@@ -38,7 +38,7 @@ type AuthenticationMutation {
...
@@ -38,7 +38,7 @@ type AuthenticationMutation {
):
DefaultResponse
):
DefaultResponse
updateStrategy
(
updateStrategy
(
provider
:
String
!
strategy
:
String
!
isEnabled
:
Boolean
!
isEnabled
:
Boolean
!
config
:
[
KeyValuePairInput
]
config
:
[
KeyValuePairInput
]
):
DefaultResponse
):
DefaultResponse
...
...
server/jobs/sync-graph-locales.js
View file @
4b042821
...
@@ -38,7 +38,7 @@ module.exports = async (job) => {
...
@@ -38,7 +38,7 @@ module.exports = async (job) => {
// -> Download locale strings
// -> Download locale strings
if
(
WIKI
.
config
.
lang
A
utoUpdate
)
{
if
(
WIKI
.
config
.
lang
.
a
utoUpdate
)
{
const
respStrings
=
await
apollo
({
const
respStrings
=
await
apollo
({
query
:
`query ($code: String!) {
query
:
`query ($code: String!) {
localization {
localization {
...
...
server/middlewares/auth.js
View file @
4b042821
...
@@ -7,7 +7,7 @@ module.exports = (req, res, next) => {
...
@@ -7,7 +7,7 @@ module.exports = (req, res, next) => {
// Is user authenticated ?
// Is user authenticated ?
if
(
!
req
.
isAuthenticated
())
{
if
(
!
req
.
isAuthenticated
())
{
if
(
WIKI
.
config
.
auth
.
public
!==
true
)
{
if
(
WIKI
.
config
.
public
!==
true
)
{
return
res
.
redirect
(
'/login'
)
return
res
.
redirect
(
'/login'
)
}
else
{
}
else
{
// req.user = rights.guest
// req.user = rights.guest
...
...
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