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 16:11:38 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
d9f9801b4d8d4a429369a7c434e798b4802276bc
d9f9801b
1 parent
94efb342
make utils.js
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
0 deletions
back/src/utils.js
back/src/utils.js
0 → 100644
View file @
d9f9801
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
);
return
userId
;
}
throw
new
Error
(
"There is no vaild user"
);
};
Please
register
or
login
to post a comment