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
3d20fee5
Commit
3d20fee5
authored
Oct 30, 2016
by
NGPixel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Local authentication
parent
dc6fc449
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
74 additions
and
26 deletions
+74
-26
README.md
README.md
+3
-2
login.css
assets/css/login.css
+0
-0
login.scss
client/scss/login.scss
+43
-1
auth.js
controllers/auth.js
+1
-3
ws.js
controllers/ws.js
+3
-1
auth.js
libs/auth.js
+12
-11
user.js
models/user.js
+2
-3
login.pug
views/auth/login.pug
+10
-5
No files found.
README.md
View file @
3d20fee5
...
@@ -19,11 +19,12 @@
...
@@ -19,11 +19,12 @@
-
[
Installation Guide
](
https://requarks-wiki.readme.io/docs/prerequisites
)
-
[
Installation Guide
](
https://requarks-wiki.readme.io/docs/prerequisites
)
##### Milestones
##### Milestones
-
[
]
Account Management
-
[
]
Assets Management
-
[
]
Assets Management
-
[
x
]
Images
-
[
x
]
Images
-
[
]
Files/Documents
-
[
]
Files/Documents
-
[
]
Authentication
-
[
x
]
Authentication
-
[
]
Local
-
[
x
]
Local
-
[
x
]
Microsoft Account
-
[
x
]
Microsoft Account
-
[
x
]
Google ID
-
[
x
]
Google ID
-
[
x
]
Facebook
-
[
x
]
Facebook
...
...
assets/css/login.css
View file @
3d20fee5
This diff is collapsed.
Click to expand it.
client/scss/login.scss
View file @
3d20fee5
@import
'./layout/_base'
;
@import
'./layout/_base'
;
@import
'./layout/_mixins'
;
@import
'./layout/_mixins'
;
@import
'./libs/animate.min.css'
;
body
{
body
{
padding
:
0
;
padding
:
0
;
margin
:
0
;
margin
:
0
;
...
@@ -80,6 +82,34 @@ a {
...
@@ -80,6 +82,34 @@ a {
animation
:
headerIntro
3s
ease
;
animation
:
headerIntro
3s
ease
;
}
}
h3
{
font-size
:
1
.25rem
;
font-weight
:
normal
;
color
:
#FB8C00
;
padding
:
0
;
margin
:
0
;
animation
:
shake
1s
ease
;
>
.fa
{
margin-right
:
7px
;
}
}
h4
{
font-size
:
0
.8rem
;
font-weight
:
normal
;
color
:
rgba
(
255
,
255
,
255
,
0
.7
);
padding
:
0
;
margin
:
0
0
15px
0
;
animation
:
fadeIn
3s
ease
;
}
form
{
display
:
flex
;
flex-direction
:
column
;
}
input
[
type
=
text
],
input
[
type
=
password
]
{
input
[
type
=
text
],
input
[
type
=
password
]
{
width
:
350px
;
width
:
350px
;
max-width
:
80vw
;
max-width
:
80vw
;
...
@@ -96,7 +126,7 @@ a {
...
@@ -96,7 +126,7 @@ a {
&
:focus
{
&
:focus
{
outline
:
none
;
outline
:
none
;
border-color
:
rgba
(
255
,
255
,
255
,
0
.8
)
;
border-color
:
#FB8C00
;
}
}
}
}
...
@@ -148,6 +178,10 @@ a {
...
@@ -148,6 +178,10 @@ a {
background-color
:
#009688
;
background-color
:
#009688
;
border-color
:
lighten
(
#009688
,
10%
);
border-color
:
lighten
(
#009688
,
10%
);
&
:focus
{
border-color
:
#FFF
;
}
&
:hover
{
&
:hover
{
background-color
:
darken
(
#009688
,
10%
);
background-color
:
darken
(
#009688
,
10%
);
}
}
...
@@ -158,6 +192,10 @@ a {
...
@@ -158,6 +192,10 @@ a {
background-color
:
#2196F3
;
background-color
:
#2196F3
;
border-color
:
lighten
(
#2196F3
,
10%
);
border-color
:
lighten
(
#2196F3
,
10%
);
&
:focus
{
border-color
:
#FFF
;
}
&
:hover
{
&
:hover
{
background-color
:
darken
(
#2196F3
,
10%
);
background-color
:
darken
(
#2196F3
,
10%
);
}
}
...
@@ -168,6 +206,10 @@ a {
...
@@ -168,6 +206,10 @@ a {
background-color
:
#673AB7
;
background-color
:
#673AB7
;
border-color
:
lighten
(
#673AB7
,
10%
);
border-color
:
lighten
(
#673AB7
,
10%
);
&
:focus
{
border-color
:
#FFF
;
}
&
:hover
{
&
:hover
{
background-color
:
darken
(
#673AB7
,
10%
);
background-color
:
darken
(
#673AB7
,
10%
);
}
}
...
...
controllers/auth.js
View file @
3d20fee5
...
@@ -41,10 +41,8 @@ router.post('/login', bruteforce.prevent, function(req, res, next) {
...
@@ -41,10 +41,8 @@ router.post('/login', bruteforce.prevent, function(req, res, next) {
if
(
!
user
)
{
if
(
!
user
)
{
req
.
flash
(
'alert'
,
{
req
.
flash
(
'alert'
,
{
class
:
'error'
,
title
:
'Invalid login'
,
title
:
'Invalid login'
,
message
:
"The email or password is invalid."
,
message
:
"The email or password is invalid."
iconClass
:
'fa-times'
});
});
return
res
.
redirect
(
'/login'
);
return
res
.
redirect
(
'/login'
);
}
}
...
...
controllers/ws.js
View file @
3d20fee5
...
@@ -2,7 +2,9 @@
...
@@ -2,7 +2,9 @@
module
.
exports
=
(
socket
)
=>
{
module
.
exports
=
(
socket
)
=>
{
console
.
log
(
socket
.
request
.
user
);
if
(
!
socket
.
request
.
user
.
logged_in
)
{
return
;
}
//-----------------------------------------
//-----------------------------------------
// SEARCH
// SEARCH
...
...
libs/auth.js
View file @
3d20fee5
...
@@ -34,23 +34,24 @@ module.exports = function(passport, appconfig) {
...
@@ -34,23 +34,24 @@ module.exports = function(passport, appconfig) {
passport
.
use
(
'local'
,
passport
.
use
(
'local'
,
new
LocalStrategy
({
new
LocalStrategy
({
usernameField
:
'email'
,
usernameField
:
'email'
,
passwordField
:
'password'
,
passwordField
:
'password'
passReqToCallback
:
true
},
},
function
(
req
,
uEmail
,
uPassword
,
done
)
{
(
uEmail
,
uPassword
,
done
)
=>
{
db
.
User
.
findOne
({
'email'
:
uEmail
}).
then
((
user
)
=>
{
db
.
User
.
findOne
({
email
:
uEmail
,
provider
:
'local'
}).
then
((
user
)
=>
{
if
(
user
)
{
if
(
user
)
{
user
.
validatePassword
(
uPassword
).
then
((
isValid
)
=>
{
return
user
.
validatePassword
(
uPassword
).
then
(()
=>
{
return
(
isValid
)
?
done
(
null
,
user
)
:
done
(
null
,
false
);
return
done
(
null
,
user
)
||
true
;
}).
catch
((
err
)
=>
{
return
done
(
err
,
null
);
});
});
}
else
{
}
else
{
return
done
(
n
ull
,
false
);
return
done
(
n
ew
Error
(
'Invalid Login'
),
null
);
}
}
}).
catch
((
err
)
=>
{
}).
catch
((
err
)
=>
{
done
(
err
)
;
done
(
err
,
null
)
;
});
});
}
)
}
);
)
)
;
}
}
...
...
models/user.js
View file @
3d20fee5
...
@@ -78,9 +78,8 @@ userSchema.statics.hashPassword = (rawPwd) => {
...
@@ -78,9 +78,8 @@ userSchema.statics.hashPassword = (rawPwd) => {
};
};
userSchema
.
methods
.
validatePassword
=
function
(
rawPwd
)
{
userSchema
.
methods
.
validatePassword
=
function
(
rawPwd
)
{
let
self
=
this
;
return
bcrypt
.
compare
(
rawPwd
,
this
.
password
).
then
((
isValid
)
=>
{
return
bcrypt
.
hash
(
rawPwd
).
then
((
pwd
)
=>
{
return
(
isValid
)
?
true
:
Promise
.
reject
(
new
Error
(
'Invalid Login'
));
return
(
self
.
password
===
pwd
)
?
true
:
Promise
.
reject
(
new
Error
(
'Invalid Password'
));
});
});
};
};
...
...
views/auth/login.pug
View file @
3d20fee5
...
@@ -32,10 +32,16 @@ html
...
@@ -32,10 +32,16 @@ html
#root
#root
h1= appconfig.title
h1= appconfig.title
h2 Login required
h2 Login required
if appflash.length > 0
h3
i.fa.fa-warning
= appflash[0].title
h4= appflash[0].message
if appconfig.auth.local.enabled
if appconfig.auth.local.enabled
input#login-user(type='text', placeholder='Email address')
form(method='post', action='/login')
input#login-pass(type='password', placeholder='Password')
input#login-user(type='text', name='email', placeholder='Email address')
button Log In
input#login-pass(type='password', name='password', placeholder='Password')
button(type='submit') Log In
if appconfig.authStrategies.socialEnabled
if appconfig.authStrategies.socialEnabled
#social
#social
if appconfig.auth.local.enabled
if appconfig.auth.local.enabled
...
@@ -59,4 +65,3 @@ html
...
@@ -59,4 +65,3 @@ html
a.icon(href='https://github.com/Requarks/wiki')
a.icon(href='https://github.com/Requarks/wiki')
i.fa.fa-github
i.fa.fa-github
a(href='https://github.com/Requarks/wiki') Requarks Wiki
a(href='https://github.com/Requarks/wiki') Requarks Wiki
\ No newline at end of file
\ No newline at end of file
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