Toggle navigation
Toggle navigation
This project
Loading...
Sign in
2020-1-capstone-design1
/
Triz_Project1
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
1
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
sdy
2020-04-19 17:04:22 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
1258415912a791fcf58cc1379b432d82a6eb7c62
12584159
1 parent
1c37ea51
update jwt_secret value
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
1 additions
and
3 deletions
back/src/utils.js
back/src/utils.js
View file @
1258415
import
jwt
from
"jsonwebtoken"
;
import
{
PrismaClient
}
from
"@prisma/client"
;
export
const
APP_SECRET
=
"a"
;
// TODO : value update to object
export
const
prisma
=
new
PrismaClient
();
export
const
getUserId
=
(
context
)
=>
{
const
Authorization
=
context
.
request
.
get
(
"Authorization"
);
if
(
Authorization
)
{
const
token
=
Authorization
.
replace
(
"Bearer "
,
""
);
const
{
userId
}
=
jwt
.
verify
(
token
,
APP
_SECRET
);
const
{
userId
}
=
jwt
.
verify
(
token
,
process
.
env
.
JWT
_SECRET
);
return
userId
;
}
throw
new
Error
(
"There is no vaild user"
);
...
...
Please
register
or
login
to post a comment