Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
teknikattan-scoring-system
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
tddd96-grupp1
teknikattan-scoring-system
Commits
d315476f
Commit
d315476f
authored
4 years ago
by
Carl Schönfelder
Browse files
Options
Downloads
Patches
Plain Diff
fix: cors
parent
50d1a77d
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Pipeline
#38435
failed
4 years ago
Stage: setup
Stage: test
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
server/app/__init__.py
+7
-1
7 additions, 1 deletion
server/app/__init__.py
server/app/apis/auth.py
+6
-1
6 additions, 1 deletion
server/app/apis/auth.py
with
13 additions
and
2 deletions
server/app/__init__.py
+
7
−
1
View file @
d315476f
from
flask
import
Flask
,
redirect
,
request
from
flask_cors
import
CORS
import
app.core.models
as
models
from
app.core
import
bcrypt
,
db
,
jwt
...
...
@@ -8,7 +9,6 @@ def create_app(config_name="configmodule.DevelopmentConfig"):
app
=
Flask
(
__name__
)
app
.
config
.
from_object
(
config_name
)
app
.
url_map
.
strict_slashes
=
False
with
app
.
app_context
():
bcrypt
.
init_app
(
app
)
...
...
@@ -25,6 +25,12 @@ def create_app(config_name="configmodule.DevelopmentConfig"):
if
rp
!=
"
/
"
and
rp
.
endswith
(
"
/
"
):
return
redirect
(
rp
[:
-
1
])
@app.after_request
def
set_core
(
response
):
header
=
response
.
headers
header
[
"
Access-Control-Allow-Origin
"
]
=
"
*
"
return
response
return
app
...
...
This diff is collapsed.
Click to expand it.
server/app/apis/auth.py
+
6
−
1
View file @
d315476f
...
...
@@ -11,7 +11,7 @@ from flask_jwt_extended import (
jwt_refresh_token_required
,
jwt_required
,
)
from
flask_restx
import
Namespace
,
Resource
from
flask_restx
import
Namespace
,
Resource
,
cors
api
=
Namespace
(
"
auth
"
)
...
...
@@ -23,6 +23,7 @@ def get_user_claims(item_user):
@api.route
(
"
/signup
"
)
class
AuthSignup
(
Resource
):
@jwt_required
@cors.crossdomain
(
origin
=
"
*
"
)
def
post
(
self
):
args
=
create_user_parser
.
parse_args
(
strict
=
True
)
email
=
args
.
get
(
"
email
"
)
...
...
@@ -44,6 +45,7 @@ class AuthSignup(Resource):
@api.param
(
"
ID
"
)
class
AuthDelete
(
Resource
):
@jwt_required
@cors.crossdomain
(
origin
=
"
*
"
)
def
delete
(
self
,
ID
):
item_user
=
User
.
query
.
filter
(
User
.
id
==
ID
).
first
()
dbc
.
delete
(
item_user
)
...
...
@@ -55,6 +57,7 @@ class AuthDelete(Resource):
@api.route
(
"
/login
"
)
class
AuthLogin
(
Resource
):
@cors.crossdomain
(
origin
=
"
*
"
)
def
post
(
self
):
args
=
login_parser
.
parse_args
(
strict
=
True
)
email
=
args
.
get
(
"
email
"
)
...
...
@@ -74,6 +77,7 @@ class AuthLogin(Resource):
@api.route
(
"
/logout
"
)
class
AuthLogout
(
Resource
):
@jwt_required
@cors.crossdomain
(
origin
=
"
*
"
)
def
post
(
self
):
jti
=
get_raw_jwt
()[
"
jti
"
]
dbc
.
add
.
blacklist
(
jti
)
...
...
@@ -84,6 +88,7 @@ class AuthLogout(Resource):
class
AuthRefresh
(
Resource
):
@jwt_required
@jwt_refresh_token_required
@cors.crossdomain
(
origin
=
"
*
"
)
def
post
(
self
):
old_jti
=
get_raw_jwt
()[
"
jti
"
]
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment