Toggle navigation
Toggle navigation
This project
Loading...
Sign in
백승준
/
OSproject
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
SeungJun Baek
2022-06-08 14:00:37 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
b56e52bfa542d7c0d4ac411bac0bfb2871b62aaf
b56e52bf
1 parent
09ba8da7
finishgitlogin 오류 수정
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
9 deletions
src/backend/controllers/globalController.js
src/models/User.js
src/backend/controllers/globalController.js
View file @
b56e52b
...
...
@@ -89,13 +89,14 @@ export const finishGithubLogin = async (req,res) =>
{
const
config
=
{
client_id
:
process
.
env
.
O_A
UTH_CLIENT_ID
,
client_id
:
process
.
env
.
O_A
uth_client_id
,
client_secret
:
process
.
env
.
O_Auth_scret
,
code
:
req
.
query
.
code
}
const
params
=
new
URLSearchParams
(
config
).
toString
();
const
baseURL
=
`https://github.com/login/oauth/access_token`
;
const
finalURL
=
`
${
baseURL
}
?
${
params
}
`
;
console
.
log
(
finalURL
)
const
data
=
await
fetch
(
finalURL
,{
method
:
"POST"
,
headers
:{
...
...
@@ -107,12 +108,13 @@ export const finishGithubLogin = async (req,res) =>
{
const
{
access_token
}
=
token
;
const
apiUrl
=
"https://api.github.com"
const
getUserData
=
await
fetch
(
`
${
apiUrl
}
/user`
,{
method
:
"GET"
,
headers
:{
Authorization
:
`token
${
access_token
}
`
}
});
const
userRequest
=
await
(
await
fetch
(
`
${
apiUrl
}
/user`
,
{
headers
:
{
Authorization
:
`token
${
access_token
}
`
,
},
})
).
json
();
const
emailData
=
await
(
await
fetch
(
`
${
apiUrl
}
/user/emails`
,{
method
:
"GET"
,
...
...
@@ -129,7 +131,7 @@ export const finishGithubLogin = async (req,res) =>
if
(
!
user
){
user
=
await
User
.
create
({
email
:
emailObj
.
email
,
username
:
user
Data
.
login
,
username
:
user
Request
.
login
,
password
:
""
,
isO_Auth
:
true
,
});
...
...
src/models/User.js
View file @
b56e52b
...
...
@@ -11,7 +11,7 @@ const userSchema = new mongoose.Schema({
userSchema
.
pre
(
'save'
,
async
function
(){
console
.
log
(
"Users password:"
,
this
.
password
);
this
.
password
=
await
bcrypt
.
hash
(
this
.
password
,
5
);
``
this
.
password
=
await
bcrypt
.
hash
(
this
.
password
,
5
);
console
.
log
(
"Users password:"
,
this
.
password
);
})
...
...
Please
register
or
login
to post a comment