-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #420 from noharm-ai/develop
v4.16-beta
- Loading branch information
Showing
14 changed files
with
404 additions
and
118 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
|
||
|
||
class Config: | ||
VERSION = "v4.15-beta" | ||
VERSION = "v4.16-beta" | ||
FRONTEND_VERSION = "4.0.10" | ||
ENV = getenv("ENV") or NoHarmENV.DEVELOPMENT.value | ||
SECRET_KEY = getenv("SECRET_KEY") or "secret_key" | ||
|
@@ -31,6 +31,8 @@ class Config: | |
MAIL_SENDER = getenv("MAIL_SENDER") or "[email protected]" | ||
MAIL_HOST = getenv("MAIL_HOST") or "localhost" | ||
|
||
NIFI_BUCKET_NAME = getenv("NIFI_BUCKET_NAME") or "" | ||
|
||
CACHE_BUCKET_NAME = getenv("CACHE_BUCKET_NAME") or "" | ||
CACHE_BUCKET_ID = getenv("CACHE_BUCKET_ID") or "" | ||
CACHE_BUCKET_KEY = getenv("CACHE_BUCKET_KEY") or "" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
from sqlalchemy import func, or_, desc, asc | ||
|
||
from models.main import db, User, UserAuthorization, UserExtra | ||
from security.role import Role | ||
|
||
|
||
def get_user_by_credentials(email: str, password: str) -> User: | ||
return ( | ||
db.session.query(User) | ||
.filter(func.lower(User.email) == email.lower()) | ||
.filter(User.password == func.crypt(password, User.password)) | ||
.filter(User.active == True) | ||
.first() | ||
) | ||
|
||
|
||
def get_user_by_email(email: str) -> User: | ||
return ( | ||
db.session.query(User).filter(func.lower(User.email) == email.lower()).first() | ||
) | ||
|
||
|
||
def get_admin_users_list(schema: str): | ||
segments_query = db.session.query( | ||
func.array_agg(UserAuthorization.idSegment) | ||
).filter(User.id == UserAuthorization.idUser) | ||
|
||
extra_roles_query = ( | ||
db.session.query(UserExtra) | ||
.filter(UserExtra.idUser == User.id) | ||
.filter( | ||
or_( | ||
UserExtra.config["roles"].astext.contains(Role.ADMIN.value), | ||
UserExtra.config["roles"].astext.contains(Role.CURATOR.value), | ||
UserExtra.config["roles"].astext.contains(Role.RESEARCHER.value), | ||
UserExtra.config["roles"].astext.contains( | ||
Role.SERVICE_INTEGRATOR.value | ||
), | ||
UserExtra.config["roles"].astext.contains(Role.STATIC_USER.value), | ||
) | ||
) | ||
) | ||
|
||
users = ( | ||
db.session.query(User, segments_query.scalar_subquery()) | ||
.filter(User.schema == schema) | ||
.filter( | ||
~User.config["roles"].astext.contains(Role.ADMIN.value), | ||
~User.config["roles"].astext.contains(Role.CURATOR.value), | ||
~User.config["roles"].astext.contains(Role.RESEARCHER.value), | ||
~User.config["roles"].astext.contains(Role.SERVICE_INTEGRATOR.value), | ||
~User.config["roles"].astext.contains(Role.STATIC_USER.value), | ||
) | ||
.filter(~extra_roles_query.exists()) | ||
.order_by(desc(User.active), asc(User.name)) | ||
.all() | ||
) | ||
|
||
return users |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.