Toggle navigation
Toggle navigation
This project
Loading...
Sign in
이정민
/
OPproject
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
서예진
2019-12-03 19:39:39 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
6ddff8c6851a4277a80cc1e126ccd27a76f7cf3e
6ddff8c6
1 parent
088dcf93
passport
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
45 additions
and
0 deletions
passport/index.js
passport/localStrategy.js
passport/index.js
0 → 100644
View file @
6ddff8c
const
local
=
require
(
'./localStrategy'
);
const
{
User
}
=
require
(
'../models'
);
module
.
exports
=
(
passport
)
=>
{
passport
.
serializeUser
((
user
,
done
)
=>
{
done
(
null
,
user
.
id
);
});
passport
.
deserializeUser
((
id
,
done
)
=>
{
User
.
find
({
where
:
{
id
}
})
.
then
(
user
=>
done
(
null
,
user
))
.
catch
(
err
=>
done
(
err
));
});
local
(
passport
);
};
passport/localStrategy.js
0 → 100644
View file @
6ddff8c
const
LocalStrategy
=
require
(
'passport-local'
).
Strategy
;
const
bcrypt
=
require
(
'bcrypt'
);
const
{
User
}
=
require
(
'../models'
);
module
.
exports
=
(
passport
)
=>
{
passport
.
use
(
new
LocalStrategy
({
usernameField
:
'email'
,
passwordField
:
'password'
,
},
async
(
email
,
password
,
done
)
=>
{
try
{
const
exUser
=
await
User
.
find
({
where
:
{
email
}
});
if
(
exUser
)
{
const
result
=
await
bcrypt
.
compare
(
password
,
exUser
.
password
);
if
(
result
)
{
done
(
null
,
exUser
);
}
else
{
done
(
null
,
false
,
{
message
:
'비밀번호가 일치하지 않습니다.'
});
}
}
else
{
done
(
null
,
false
,
{
message
:
'가입되지 않은 회원입니다.'
});
}
}
catch
(
error
)
{
console
.
error
(
error
);
done
(
error
);
}
}));
};
Please
register
or
login
to post a comment