Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
W
webomagic-auth
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Pratik Shrivastava
webomagic-auth
Commits
d93b5e06
Commit
d93b5e06
authored
Jul 23, 2024
by
Pratik Shrivastava
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'upstream/master'
parents
fe649651
7af92f38
Changes
28
Show whitespace changes
Inline
Side-by-side
Showing
28 changed files
with
929 additions
and
295 deletions
+929
-295
app/__init__.py
app/__init__.py
+3
-5
app/app_config/config.py
app/app_config/config.py
+2
-0
app/orm/role_orm.py
app/orm/role_orm.py
+0
-2
app/orm/user_orm.py
app/orm/user_orm.py
+2
-1
app/routes/address/__init__.py
app/routes/address/__init__.py
+71
-0
app/routes/address/address_dao_service.py
app/routes/address/address_dao_service.py
+45
-1
app/routes/address/address_payload.py
app/routes/address/address_payload.py
+13
-0
app/routes/address/address_validator.py
app/routes/address/address_validator.py
+3
-0
app/routes/role/__init__.py
app/routes/role/__init__.py
+43
-9
app/routes/role/role_dao_service.py
app/routes/role/role_dao_service.py
+105
-22
app/routes/role/role_payload.py
app/routes/role/role_payload.py
+11
-3
app/routes/role/role_response.py
app/routes/role/role_response.py
+8
-0
app/routes/role/role_validator.py
app/routes/role/role_validator.py
+6
-1
app/routes/role_type/__init__.py
app/routes/role_type/__init__.py
+44
-0
app/routes/role_type/role_type_dao_service.py
app/routes/role_type/role_type_dao_service.py
+7
-0
app/routes/role_type/role_type_payload.py
app/routes/role_type/role_type_payload.py
+0
-0
app/routes/role_type/role_type_response.py
app/routes/role_type/role_type_response.py
+26
-0
app/routes/role_type/role_type_validator.py
app/routes/role_type/role_type_validator.py
+0
-0
app/routes/user/__init__.py
app/routes/user/__init__.py
+122
-49
app/routes/user/user_dao_service.py
app/routes/user/user_dao_service.py
+152
-54
app/routes/user/user_payload.py
app/routes/user/user_payload.py
+55
-6
app/routes/user/user_response.py
app/routes/user/user_response.py
+33
-7
app/routes/user/user_util.py
app/routes/user/user_util.py
+16
-18
app/routes/user/user_validator.py
app/routes/user/user_validator.py
+32
-1
app/utils/mail_service.py
app/utils/mail_service.py
+7
-97
database/query.sql
database/query.sql
+35
-10
database/schema.sql
database/schema.sql
+10
-9
html_templates/otp-login-template.html
html_templates/otp-login-template.html
+78
-0
No files found.
app/__init__.py
View file @
d93b5e06
...
...
@@ -3,7 +3,7 @@ from flask_cors import CORS
from
flask_bcrypt
import
Bcrypt
from
flask_mail
import
Mail
from
flask_sqlalchemy
import
SQLAlchemy
from
app.app_config.config
import
DB_URI
,
MAIL_DEFAULT_SENDER
,
MAIL_PASSWORD
,
MAIL_PORT
,
MAIL_SERVER
,
MAIL_USERNAME
from
app.app_config.config
import
*
db
:
SQLAlchemy
=
SQLAlchemy
()
bcrypt
:
Bcrypt
=
Bcrypt
()
...
...
@@ -18,8 +18,8 @@ def create_app():
# mail configuration
app
.
config
[
'MAIL_SERVER'
]
=
MAIL_SERVER
app
.
config
[
'MAIL_PORT'
]
=
MAIL_PORT
app
.
config
[
'MAIL_USE_TLS'
]
=
True
app
.
config
[
'MAIL_USE_SSL'
]
=
False
app
.
config
[
'MAIL_USE_TLS'
]
=
MAIL_USE_TLS
app
.
config
[
'MAIL_USE_SSL'
]
=
MAIL_USE_SSL
app
.
config
[
'MAIL_USERNAME'
]
=
MAIL_USERNAME
app
.
config
[
'MAIL_PASSWORD'
]
=
MAIL_PASSWORD
app
.
config
[
'MAIL_DEFAULT_SENDER'
]
=
(
MAIL_DEFAULT_SENDER
,
MAIL_USERNAME
)
...
...
@@ -32,8 +32,6 @@ def create_app():
bcrypt
.
init_app
(
app
)
mail
.
init_app
(
app
)
from
app
import
routes
# registering routes for each sub-folder in routes
...
...
app/app_config/config.py
View file @
d93b5e06
...
...
@@ -30,6 +30,8 @@ MAIL_PORT: int = os.environ.get('MAIL_PORT', 587)
MAIL_USERNAME
=
os
.
environ
.
get
(
'MAIL_USERNAME'
,
'deep.websofttechs@gmail.com'
)
MAIL_PASSWORD
=
os
.
environ
.
get
(
'MAIL_PASSWORD'
,
'xtzsnezbtawrsbwn'
)
MAIL_DEFAULT_SENDER
=
os
.
environ
.
get
(
'MAIL_DEFAULT_SENDER'
,
'Webomagic Admin'
)
MAIL_USE_TLS
:
bool
=
os
.
environ
.
get
(
'MAIL_USE_TLS'
,
'True'
)
==
'True'
MAIL_USE_SSL
:
bool
=
os
.
environ
.
get
(
'MAIL_USE_SSL'
,
'False'
)
==
'True'
LOGGER_PATH
:
str
=
os
.
environ
.
get
(
'LOGGER_PATH'
,
'/etc/webomagic_user/logs/'
)
...
...
app/orm/role_orm.py
View file @
d93b5e06
...
...
@@ -25,8 +25,6 @@ class Role(db.Model, CustomSerializerMixin):
updated_by
=
db
.
Column
(
db
.
BigInteger
)
is_deleted
=
db
.
Column
(
db
.
Boolean
,
default
=
False
)
role_type
=
db
.
relationship
(
'RoleType'
)
__table_args__
=
(
db
.
UniqueConstraint
(
'project_id'
,
'role_name'
,
name
=
'uq_project_id_role_name'
),
)
...
...
app/orm/user_orm.py
View file @
d93b5e06
...
...
@@ -19,6 +19,7 @@ class User(db.Model, CustomSerializerMixin):
password
=
db
.
Column
(
db
.
String
(
80
),
nullable
=
False
)
organization
=
db
.
Column
(
db
.
String
(
255
),
nullable
=
False
)
project_id
=
db
.
Column
(
db
.
BigInteger
,
nullable
=
True
)
role_type_id
=
db
.
Column
(
db
.
BigInteger
,
db
.
ForeignKey
(
'role_type.id'
),
nullable
=
False
)
gstin
=
db
.
Column
(
db
.
String
(
50
),
nullable
=
False
)
email
=
db
.
Column
(
db
.
String
(
120
),
nullable
=
False
,
unique
=
True
)
phone_number
=
db
.
Column
(
db
.
String
(
20
),
nullable
=
False
,
unique
=
True
)
...
...
@@ -30,8 +31,8 @@ class User(db.Model, CustomSerializerMixin):
updated_at
=
db
.
Column
(
db
.
DATETIME
,
onupdate
=
datetime
.
now
)
created_by
=
db
.
Column
(
db
.
BigInteger
)
updated_by
=
db
.
Column
(
db
.
BigInteger
)
is_deleted
=
db
.
Column
(
db
.
Boolean
,
default
=
False
)
user_roles
=
db
.
relationship
(
'UserRoleMap'
)
role_type
=
db
.
relationship
(
'RoleType'
)
serialize_rules
=
(
'-password'
,)
app/routes/address/__init__.py
View file @
d93b5e06
...
...
@@ -147,6 +147,77 @@ class GetAllAddresses(Resource):
return
prepare_api_response
(
EXCEPTION_CODE
,
str
(
e
))
@
ns
.
route
(
'/admin-get'
,
methods
=
[
'GET'
])
class
GetAddressForAdmin
(
Resource
):
@
ns
.
doc
(
security
=
SECURITY
)
@
ns
.
expect
(
*
get_address_payload
())
@
ns
.
response
(
*
get_address_response
())
@
sanitized
()
@
fetch_user
()
def
get
(
self
,
user_id
:
int
):
try
:
validator
=
GetAddressValidator
()
arguments
:
dict
=
validator
.
load
(
request
.
args
)
address_info
:
ORM
.
Address
|
None
=
\
get_address_by_id_for_admin
(
arguments
[
'id'
],
user_id
)
if
address_info
is
None
:
return
prepare_api_response
(
404
,
'Address not found'
)
return
prepare_api_response
(
SUCCESS_CODE
,
GET_SUCCESS_MESSAGE
,
data
=
address_info
.
to_dict
()
)
except
ValidationError
as
e
:
return
prepare_api_response
(
VALIDATION_ERROR_CODE
,
VALIDATION_ERROR_MESSAGE
,
error
=
e
.
normalized_messages
()
)
except
Exception
as
e
:
logger
.
error
(
traceback
.
format_exc
())
return
prepare_api_response
(
EXCEPTION_CODE
,
str
(
e
))
@
ns
.
route
(
'/admin-get-all'
,
methods
=
[
'GET'
])
class
GetAddressListForAdmin
(
Resource
):
@
ns
.
doc
(
security
=
SECURITY
)
@
ns
.
expect
(
*
get_addres_list_for_admin_payload
())
@
ns
.
response
(
*
get_address_response
())
@
sanitized
()
@
fetch_user
()
def
get
(
self
,
user_id
:
int
):
try
:
validator
=
GetAddressListForAdminValidator
()
arguments
:
dict
=
validator
.
load
(
request
.
args
)
addresses_list
:
List
[
ORM
.
Address
]
=
\
get_address_list_of_user_for_admin
(
arguments
[
'user_id'
],
user_id
)
return
prepare_api_response
(
SUCCESS_CODE
,
GET_SUCCESS_MESSAGE
,
data
=
[
address
.
to_dict
()
for
address
in
addresses_list
]
)
except
ValidationError
as
e
:
return
prepare_api_response
(
VALIDATION_ERROR_CODE
,
VALIDATION_ERROR_MESSAGE
,
error
=
e
.
normalized_messages
()
)
except
Exception
as
e
:
logger
.
error
(
traceback
.
format_exc
())
return
prepare_api_response
(
EXCEPTION_CODE
,
str
(
e
))
@
ns
.
route
(
'/delete'
,
methods
=
[
'DELETE'
])
class
DeleteAddress
(
Resource
):
...
...
app/routes/address/address_dao_service.py
View file @
d93b5e06
from
typing
import
List
from
app
import
orm
as
ORM
from
app
import
db
from
app.app_config.constant
import
RoleTypeEnum
from
app.routes.user.user_dao_service
import
get_user_by_id
def
get_address_by_id
(
address_id
:
int
,
user_id
:
int
)
->
ORM
.
Address
|
None
:
...
...
@@ -15,6 +17,49 @@ def get_addresses_by_user_id_and_name(user_id: int, name: str) -> List[ORM.Addre
return
ORM
.
Address
.
query
.
filter_by
(
user_id
=
user_id
,
name
=
name
)
.
first
()
def
get_address_by_id_for_admin
(
address_id
:
int
,
admin_id
:
int
)
->
ORM
.
Address
|
None
:
admin_user
:
ORM
.
User
|
None
=
get_user_by_id
(
admin_id
)
if
not
admin_user
:
raise
Exception
(
'User not found for mapped apiKey'
)
if
admin_user
.
role_type
.
role_name
!=
RoleTypeEnum
.
SUPER_ADMIN
.
value
:
return
(
db
.
session
.
query
(
ORM
.
Address
)
.
join
(
ORM
.
User
,
ORM
.
User
.
id
==
ORM
.
Address
.
user_id
)
.
filter
(
ORM
.
User
.
project_id
==
admin_user
.
project_id
,
ORM
.
Address
.
id
==
address_id
,
)
.
first
()
)
else
:
return
ORM
.
User
.
query
.
filter
(
ORM
.
Address
.
id
==
address_id
)
.
first
()
def
get_address_list_of_user_for_admin
(
user_id
:
int
,
admin_id
:
int
)
->
List
[
ORM
.
Address
]:
admin_user
:
ORM
.
User
|
None
=
get_user_by_id
(
admin_id
)
if
not
admin_user
:
raise
Exception
(
'User not found for mapped apiKey'
)
if
admin_user
.
role_type
.
role_name
!=
RoleTypeEnum
.
SUPER_ADMIN
.
value
:
return
(
db
.
session
.
query
(
ORM
.
Address
)
.
join
(
ORM
.
User
,
ORM
.
User
.
id
==
ORM
.
Address
.
user_id
)
.
filter
(
ORM
.
User
.
project_id
==
admin_user
.
project_id
,
ORM
.
Address
.
user_id
==
user_id
,
)
.
all
()
)
else
:
return
ORM
.
Address
.
query
.
filter_by
(
user_id
=
user_id
)
.
all
()
def
add_address
(
payload
:
dict
)
->
int
:
try
:
address_model
=
ORM
.
Address
(
...
...
@@ -78,4 +123,3 @@ def delete_address(address_id: int) -> bool:
db
.
session
.
delete
(
address
)
db
.
session
.
commit
()
return
True
app/routes/address/address_payload.py
View file @
d93b5e06
...
...
@@ -20,6 +20,7 @@ def add_address_payload() -> list:
)
return
[
payload
]
def
update_address_payload
()
->
list
:
payload
=
api
.
model
(
'UpdateAddress Payload'
,
...
...
@@ -39,11 +40,23 @@ def update_address_payload() -> list:
)
return
[
payload
]
def
get_address_payload
()
->
list
:
parser
=
api
.
parser
()
parser
.
add_argument
(
'id'
,
required
=
True
,
type
=
int
,
location
=
'args'
)
return
[
parser
]
def
get_admin_address_payload
()
->
list
:
return
get_address_payload
()
def
get_addres_list_for_admin_payload
()
->
list
:
parser
=
api
.
parser
()
parser
.
add_argument
(
'user_id'
,
required
=
True
,
type
=
int
,
location
=
'args'
)
return
[
parser
]
def
delete_address_payload
()
->
list
:
payload
=
api
.
model
(
'DeleteAddress Payload'
,
...
...
app/routes/address/address_validator.py
View file @
d93b5e06
...
...
@@ -28,5 +28,8 @@ class UpdateAddressValidator(Schema):
class
GetAddressValidator
(
Schema
):
id
=
fields
.
Integer
(
required
=
True
,
validate
=
validate
.
Range
(
min
=
1
))
class
GetAddressListForAdminValidator
(
Schema
):
user_id
=
fields
.
Integer
(
required
=
True
,
validate
=
validate
.
Range
(
min
=
1
))
class
DeleteAddressValidator
(
Schema
):
id
=
fields
.
Integer
(
required
=
True
,
validate
=
validate
.
Range
(
min
=
1
))
app/routes/role/__init__.py
View file @
d93b5e06
...
...
@@ -8,6 +8,7 @@ from app.app_config.response_code import *
from
app.app_config.response_message
import
*
from
app.app_config.swagger_config
import
SECURITY
from
app.decorators.sanitizer
import
sanitized
from
app.decorators.user_fetcher
import
fetch_user
from
app.routes
import
api
from
app.routes.role.role_payload
import
*
...
...
@@ -32,12 +33,13 @@ class AddRole(Resource):
@
ns
.
expect
(
*
add_role_payload
())
@
ns
.
response
(
*
add_role_response
())
@
sanitized
()
def
post
(
self
):
@
fetch_user
()
def
post
(
self
,
user_id
:
int
):
try
:
validator
=
AddRoleValidator
()
payload
:
dict
=
validator
.
load
(
request
.
get_json
())
role_id
:
int
=
add_role
(
payload
)
role_id
:
int
=
add_role
(
payload
,
user_id
)
return
prepare_api_response
(
SUCCESS_CODE
,
INSERT_SUCCESS_MESSAGE
)
...
...
@@ -60,12 +62,13 @@ class UpdateRole(Resource):
@
ns
.
expect
(
*
update_role_payload
())
@
ns
.
response
(
*
update_role_response
())
@
sanitized
()
def
patch
(
self
):
@
fetch_user
()
def
patch
(
self
,
user_id
:
int
):
try
:
validator
=
UpdateRoleValidator
()
payload
:
dict
=
validator
.
load
(
request
.
get_json
())
updated
:
bool
=
update_role
(
payload
)
updated
:
bool
=
update_role
(
payload
,
user_id
)
if
not
updated
:
return
prepare_api_response
(
...
...
@@ -92,12 +95,13 @@ class GetRole(Resource):
@
ns
.
expect
(
*
get_role_payload
())
@
ns
.
response
(
*
get_role_response
())
@
sanitized
()
def
get
(
self
):
@
fetch_user
()
def
get
(
self
,
user_id
:
int
):
try
:
validator
=
GetRoleValidator
()
arguments
:
dict
=
validator
.
load
(
request
.
args
)
role_info
:
ORM
.
Role
|
None
=
get_role_by_id
(
arguments
[
'id'
])
role_info
:
ORM
.
Role
|
None
=
get_role_by_id
(
arguments
[
'id'
]
,
user_id
)
if
role_info
is
None
:
return
prepare_api_response
(
404
,
'Role not found'
)
...
...
@@ -121,13 +125,14 @@ class GetRole(Resource):
@
ns
.
route
(
'/get-all'
,
methods
=
[
'GET'
])
class
GetAllRole
(
Resource
):
class
GetAllRole
s
(
Resource
):
@
ns
.
doc
(
security
=
SECURITY
)
@
ns
.
response
(
*
get_role_list_response
())
def
get
(
self
):
@
fetch_user
()
def
get
(
self
,
user_id
:
int
):
try
:
roles_list
=
get_role_list
()
roles_list
=
get_role_list
(
user_id
)
return
prepare_api_response
(
SUCCESS_CODE
,
...
...
@@ -153,3 +158,32 @@ class DeleteRole(Resource):
except
Exception
as
e
:
logger
.
error
(
traceback
.
format_exc
())
return
prepare_api_response
(
EXCEPTION_CODE
,
str
(
e
))
@
ns
.
route
(
'/map-web-api'
,
methods
=
[
'POST'
])
class
MapWebApi
(
Resource
):
@
ns
.
doc
(
security
=
SECURITY
)
@
ns
.
expect
(
*
map_api_payload
())
@
ns
.
response
(
*
map_api_response
())
@
sanitized
()
@
fetch_user
()
def
post
(
self
,
user_id
:
int
):
try
:
validator
=
MapApiValidator
()
payload
:
dict
=
validator
.
load
(
request
.
get_json
())
map_web_api
(
payload
,
user_id
)
return
prepare_api_response
(
SUCCESS_CODE
,
'Mapped successfully'
)
except
ValidationError
as
e
:
return
prepare_api_response
(
VALIDATION_ERROR_CODE
,
VALIDATION_ERROR_MESSAGE
,
error
=
e
.
normalized_messages
()
)
except
Exception
as
e
:
logger
.
error
(
traceback
.
format_exc
())
return
prepare_api_response
(
EXCEPTION_CODE
,
str
(
e
))
\ No newline at end of file
app/routes/role/role_dao_service.py
View file @
d93b5e06
from
typing
import
List
from
app
import
orm
as
ORM
from
app
import
db
from
app.app_config.constant
import
EndpointTagEnum
,
RoleTypeEnum
from
app.routes.user.user_dao_service
import
get_user_by_id
def
get_role_by_rolename_and_roletype
(
rolename
:
str
,
roletype
:
int
rolename
:
str
,
roletype
:
int
,
project_id
:
int
)
->
ORM
.
Role
|
None
:
return
ORM
.
Role
.
query
.
filter_by
(
role_name
=
rolename
,
role_type
=
roletype
,
is_deleted
=
False
)
.
first
()
role_name
=
rolename
,
role_type
=
roletype
,
project_id
=
project_id
,
is_deleted
=
False
)
.
first
()
def
add_role
(
role
:
dict
)
->
int
|
None
:
def
add_role
(
role
:
dict
,
user_id
:
int
)
->
int
|
None
:
try
:
user_info
:
ORM
.
User
|
None
=
get_user_by_id
(
user_id
)
if
not
user_info
:
raise
Exception
(
'User not found for mapped apiKey'
)
if
user_info
.
role_type
.
role_name
!=
RoleTypeEnum
.
SUPER_ADMIN
.
value
:
if
role
.
get
(
'project_id'
)
!=
user_info
.
project_id
:
raise
Exception
(
'You have no permission to create role for this project'
)
existing_role
:
ORM
.
Role
|
None
=
get_role_by_rolename_and_roletype
(
role
.
get
(
'role_name'
),
role
.
get
(
'role_type_id'
)
role
.
get
(
'role_name'
),
role
.
get
(
'role_type_id'
)
,
role
.
get
(
'project_id'
)
)
if
existing_role
:
raise
Exception
(
'role_name already exists'
)
raise
Exception
(
'role_name already exists
for this project
'
)
role_model
=
ORM
.
Role
(
role_type_id
=
role
.
get
(
'role_type_id'
),
role_name
=
role
.
get
(
'role_name'
),
project_id
=
role
.
get
(
'project_id'
)
project_id
=
role
.
get
(
'project_id'
),
created_by
=
user_id
,
)
db
.
session
.
add
(
role_model
)
db
.
session
.
flush
([
role_model
])
db
.
session
.
commit
()
return
role_model
.
id
except
Exception
as
e
:
...
...
@@ -37,31 +52,34 @@ def add_role(role: dict) -> int | None:
raise
e
def
get_role_by_id
(
id
:
int
)
->
ORM
.
Role
|
None
:
return
ORM
.
Role
.
query
.
filter_by
(
id
=
id
,
is_deleted
=
False
)
.
first
()
def
get_role_list
()
->
List
[
ORM
.
Role
]
|
list
:
return
ORM
.
Role
.
query
.
filter_by
(
is_deleted
=
False
)
.
all
()
def
update_role
(
role
:
dict
)
->
bool
:
def
update_role
(
role
:
dict
,
user_id
:
int
)
->
bool
:
try
:
role_info
:
ORM
.
Role
=
get_role_by_id
(
role
.
get
(
'id'
),
is_deleted
=
False
)
if
role_info
is
None
:
return
False
user_info
:
ORM
.
User
|
None
=
get_user_by_id
(
user_id
)
if
not
user_info
:
raise
Exception
(
'User not found for mapped apiKey'
)
if
user_info
.
role_type
.
role_name
!=
RoleTypeEnum
.
SUPER_ADMIN
.
value
:
if
role_info
.
project_id
!=
user_info
.
project_id
:
raise
Exception
(
'You have no permission to create role for this project'
)
existing_role
:
ORM
.
Role
|
None
=
get_role_by_rolename_and_roletype
(
role
.
get
(
'role_name'
),
role
.
get
(
'role_type_id'
)
role
.
get
(
'role_name'
),
role
.
get
(
'role_type_id'
)
,
role
.
get
(
'project_id'
)
)
if
existing_role
and
existing_role
.
id
!=
role_info
.
id
:
raise
Exception
(
'rolename already exists'
)
role_info
.
role_type_id
=
role
.
get
(
'role_type_id'
)
role_info
.
role_name
=
role
.
get
(
'role_name'
)
role_info
.
project_id
=
role
.
get
(
'project_id'
)
# TODO: in future if we update role type then user role type also need to be updated
db
.
session
.
commit
()
return
True
...
...
@@ -69,3 +87,68 @@ def update_role(role: dict) -> bool:
except
Exception
as
e
:
db
.
session
.
rollback
()
raise
e
def
get_role_by_id
(
id
:
int
,
user_id
:
int
)
->
ORM
.
Role
|
None
:
user_info
:
ORM
.
User
|
None
=
get_user_by_id
(
user_id
)
if
not
user_info
:
raise
Exception
(
'User not found for mapped apiKey'
)
if
user_info
.
role_type
.
role_name
!=
RoleTypeEnum
.
SUPER_ADMIN
.
value
:
return
ORM
.
Role
.
query
.
filter_by
(
id
=
id
,
is_deleted
=
False
,
project_id
=
user_info
.
project_id
)
.
first
()
return
ORM
.
Role
.
query
.
filter_by
(
id
=
id
,
is_deleted
=
False
)
.
first
()
def
get_role_list
(
user_id
:
int
)
->
List
[
ORM
.
Role
]
|
list
:
user_info
:
ORM
.
User
|
None
=
get_user_by_id
(
user_id
)
if
not
user_info
:
raise
Exception
(
'User not found for mapped apiKey'
)
if
user_info
.
role_type
.
role_name
!=
RoleTypeEnum
.
SUPER_ADMIN
.
value
:
return
ORM
.
Role
.
query
.
filter_by
(
is_deleted
=
False
,
project_id
=
user_info
.
project_id
)
.
all
()
return
ORM
.
Role
.
query
.
filter_by
(
is_deleted
=
False
)
.
all
()
def
map_web_api
(
payload
:
dict
,
admin_id
:
int
)
->
bool
:
admin_info
:
ORM
.
User
|
None
=
get_user_by_id
(
admin_id
)
if
not
admin_info
:
raise
Exception
(
'User not found for mapped apiKey'
)
role
:
ORM
.
Role
|
None
=
ORM
.
Role
.
query
.
filter_by
(
id
=
payload
.
get
(
'role_id'
),
is_deleted
=
False
)
.
first
()
if
not
role
:
raise
Exception
(
'Role not found'
)
if
admin_info
.
role_type
.
role_name
!=
RoleTypeEnum
.
SUPER_ADMIN
.
value
:
if
role
.
project_id
!=
admin_info
.
project_id
:
raise
Exception
(
'You have no permission to map web-api for this role'
)
web_api_list
:
List
[
ORM
.
Api
]
=
ORM
.
Api
.
query
.
filter
(
ORM
.
Api
.
id
.
in_
(
payload
.
get
(
'api_list'
)),
ORM
.
Api
.
tag
==
EndpointTagEnum
.
RA
.
value
,
)
.
all
()
if
len
(
web_api_list
)
!=
len
(
payload
.
get
(
'api_list'
)):
raise
Exception
(
'Some api not found or cannot be mapped for this role'
)
ORM
.
RoleApiMap
.
query
.
filter
(
ORM
.
RoleApiMap
.
role_id
==
role
.
id
,
)
.
delete
(
synchronize_session
=
'fetch'
)
role_api_mappings
=
[
ORM
.
RoleApiMap
(
role_id
=
role
.
id
,
api_id
=
api
.
id
,
created_by
=
admin_id
)
for
api
in
web_api_list
]
db
.
session
.
add_all
(
role_api_mappings
)
db
.
session
.
commit
()
app/routes/role/role_payload.py
View file @
d93b5e06
...
...
@@ -17,9 +17,7 @@ def update_role_payload() -> list:
payload
=
api
.
model
(
'updateRole Payload'
,
{
'id'
:
fields
.
Integer
,
'role_type_id'
:
fields
.
Integer
,
'role_name'
:
fields
.
String
,
'project_id'
:
fields
.
Integer
'role_name'
:
fields
.
String
})
return
[
payload
]
...
...
@@ -39,3 +37,13 @@ def delete_role_payload() -> list:
parser
.
add_argument
(
'id'
,
type
=
int
,
location
=
'args'
)
return
[
parser
]
def
map_api_payload
()
->
list
:
payload
=
api
.
model
(
'mapApi Payload'
,
{
'role_id'
:
fields
.
Integer
,
'api_list'
:
fields
.
List
(
fields
.
Integer
)
})
return
[
payload
]
\ No newline at end of file
app/routes/role/role_response.py
View file @
d93b5e06
...
...
@@ -62,3 +62,11 @@ def delete_role_response() -> any:
message
=
DELETE_SUCCESS_MESSAGE
,
model_name
=
'deleteRole Response'
)
def
map_api_response
()
->
any
:
return
prepare_swagger_response
(
code
=
SUCCESS_CODE
,
message
=
'Mapped successfully'
,
model_name
=
'mapApi Response'
)
\ No newline at end of file
app/routes/role/role_validator.py
View file @
d93b5e06
...
...
@@ -4,13 +4,18 @@ from marshmallow import Schema, fields, validate
class
AddRoleValidator
(
Schema
):
role_name
=
fields
.
String
(
required
=
True
,
validate
=
validate
.
Length
(
min
=
1
))
project_id
=
fields
.
Integer
(
required
=
True
,
validate
=
validate
.
Range
(
min
=
1
))
role_type_id
=
fields
.
Integer
(
required
=
True
,
validate
=
validate
.
Range
(
min
=
1
))
class
UpdateRoleValidator
(
Schema
):
id
=
fields
.
Integer
(
required
=
True
,
validate
=
validate
.
Range
(
min
=
1
))
role_name
=
fields
.
String
(
required
=
True
,
validate
=
validate
.
Length
(
min
=
1
))
project_id
=
fields
.
Integer
(
required
=
True
,
validate
=
validate
.
Range
(
min
=
1
))
class
GetRoleValidator
(
Schema
):
id
=
fields
.
Integer
(
required
=
True
,
validate
=
validate
.
Range
(
min
=
1
))
class
MapApiValidator
(
Schema
):
role_id
=
fields
.
Integer
(
required
=
True
,
validate
=
validate
.
Range
(
min
=
1
))
api_list
=
fields
.
List
(
fields
.
Integer
(
required
=
True
,
validate
=
validate
.
Range
(
min
=
1
)))
app/routes/role_type/__init__.py
0 → 100644
View file @
d93b5e06
import
os
import
traceback
from
flask_restx
import
Resource
from
app.app_config.config
import
get_logger
from
app.app_config.response_code
import
*
from
app.app_config.response_message
import
*
from
app.app_config.swagger_config
import
SECURITY
from
app.decorators.sanitizer
import
sanitized
from
app.routes
import
api
from
app.routes.role_type.role_type_payload
import
*
from
app.routes.role_type.role_type_response
import
*
from
app.routes.role_type.role_type_dao_service
import
*
from
app.routes.role_type.role_type_validator
import
*
from
app.utils.api_response
import
prepare_api_response
logger
=
get_logger
(
__name__
)
ns
=
api
.
namespace
(
name
=
os
.
path
.
dirname
(
__file__
)
.
split
(
os
.
sep
)[
-
1
]
.
replace
(
'_'
,
'-'
),
description
=
'API connected to role module'
,
ordered
=
False
,
)
@
ns
.
route
(
'/get-all'
,
methods
=
[
'GET'
])
class
GetRole
(
Resource
):
@
ns
.
doc
(
security
=
SECURITY
)
@
ns
.
response
(
*
get_role_type_list_response
())
@
sanitized
()
def
get
(
self
):
try
:
role_type_list
:
List
[
ORM
.
Role
]
|
list
=
get_role_type_list
()
return
prepare_api_response
(
SUCCESS_CODE
,
GET_ALL_SUCCESS_MESSAGE
,
data
=
[
role
.
to_dict
()
for
role
in
role_type_list
],
)
except
Exception
as
e
:
logger
.
error
(
traceback
.
format_exc
())
return
prepare_api_response
(
EXCEPTION_CODE
,
str
(
e
))
app/routes/role_type/role_type_dao_service.py
0 → 100644
View file @
d93b5e06
from
typing
import
List
from
app
import
orm
as
ORM
from
app
import
db
def
get_role_type_list
()
->
List
[
ORM
.
Role
]
|
list
:
return
ORM
.
RoleType
.
query
.
filter_by
(
is_deleted
=
False
)
.
all
()
app/routes/role_type/role_type_payload.py
0 → 100644
View file @
d93b5e06
app/routes/role_type/role_type_response.py
0 → 100644
View file @
d93b5e06
from
app.app_config.response_code
import
SUCCESS_CODE
from
app.app_config.response_message
import
*
from
app.routes
import
api
from
flask_restx
import
fields
from
app.utils.api_response
import
prepare_swagger_response
ROLE_TYPE_RESPONSE_MODEL
:
any
=
api
.
model
(
'roleType'
,
{
'id'
:
fields
.
Integer
,
'role_name'
:
fields
.
String
,
'is_deleted'
:
fields
.
Boolean
,
'created_at'
:
fields
.
DateTime
,
'updated_at'
:
fields
.
DateTime
,
},
)
def
get_role_type_list_response
()
->
any
:
return
prepare_swagger_response
(
code
=
SUCCESS_CODE
,
message
=
GET_SUCCESS_MESSAGE
,
model_name
=
'getRoleType Response'
,
data
=
fields
.
List
(
fields
.
Nested
(
ROLE_TYPE_RESPONSE_MODEL
)),
)
app/routes/role_type/role_type_validator.py
0 → 100644
View file @
d93b5e06
app/routes/user/__init__.py
View file @
d93b5e06
...
...
@@ -3,7 +3,8 @@ import traceback
from
flask
import
request
from
flask_restx
import
Resource
from
marshmallow
import
ValidationError
from
app.app_config.config
import
get_logger
from
app.app_config.config
import
MAIL_DEFAULT_SENDER
,
get_logger
from
app.app_config.constant
import
ALPHANUMARIC_STRING
from
app.app_config.response_code
import
*
from
app.app_config.response_message
import
*
from
app.app_config.swagger_config
import
SECURITY
...
...
@@ -26,7 +27,7 @@ logger = get_logger(__name__)
ns
=
api
.
namespace
(
name
=
os
.
path
.
dirname
(
__file__
)
.
split
(
os
.
sep
)[
-
1
]
.
replace
(
'_'
,
'-'
),
description
=
'API connected to user module'
,
ordered
=
False
ordered
=
False
,
)
...
...
@@ -48,26 +49,24 @@ class Login(Resource):
user_info
:
ORM
.
User
|
None
=
get_user_by_email
(
email
)
if
(
not
user_info
)
:
if
not
user_info
:
return
prepare_api_response
(
401
,
'Invalid Email'
)
if
not
bcrypt
.
check_password_hash
(
user_info
.
password
,
password
):
return
prepare_api_response
(
401
,
'Invalid password'
)
api_key
=
generate_api_key
()
api_key
=
self
.
generate_api_key
()
process_valid_loging
(
user_info
,
api_key
)
return
prepare_api_response
(
SUCCESS_CODE
,
SUCCESS_MESSAGE
,
data
=
{
'apiKey'
:
api_key
}
SUCCESS_CODE
,
SUCCESS_MESSAGE
,
data
=
{
'apiKey'
:
api_key
}
)
except
ValidationError
as
e
:
return
prepare_api_response
(
VALIDATION_ERROR_CODE
,
VALIDATION_ERROR_MESSAGE
,
error
=
e
.
normalized_messages
()
error
=
e
.
normalized_messages
()
,
)
except
Exception
as
e
:
...
...
@@ -90,27 +89,23 @@ class LoginOTP(Resource):
user_info
:
ORM
.
User
|
None
=
get_user_by_email
(
email
)
if
(
not
user_info
)
:
if
not
user_info
:
return
prepare_api_response
(
401
,
'Invalid Email'
)
otp
:
int
=
generate_otp
()
otp
:
int
=
self
.
generate_otp
()
send_otp
(
'shadowtitan3003@gmail.com'
,
[
email
]
,
otp
)
send_otp
(
MAIL_DEFAULT_SENDER
,
email
,
otp
)
redis_key
:
str
=
str
(
user_info
.
id
)
+
'_'
+
'otp'
+
str
(
otp
)
set_value
(
redis_key
,
1
,
60
*
5
)
return
prepare_api_response
(
SUCCESS_CODE
,
'OTP generated successfully'
)
return
prepare_api_response
(
SUCCESS_CODE
,
'OTP generated successfully'
)
except
ValidationError
as
e
:
return
prepare_api_response
(
VALIDATION_ERROR_CODE
,
VALIDATION_ERROR_MESSAGE
,
error
=
e
.
normalized_messages
()
error
=
e
.
normalized_messages
()
,
)
except
Exception
as
e
:
...
...
@@ -134,7 +129,7 @@ class LoginOTPVerify(Resource):
user_info
:
ORM
.
User
|
None
=
get_user_by_email
(
email
)
if
(
not
user_info
)
:
if
not
user_info
:
return
prepare_api_response
(
401
,
'Invalid Email'
)
redis_key
:
str
=
str
(
user_info
.
id
)
+
'_'
+
'otp'
+
str
(
provided_otp
)
...
...
@@ -142,16 +137,13 @@ class LoginOTPVerify(Resource):
redis_otp
:
int
|
None
=
get_value
(
redis_key
)
if
redis_otp
is
None
:
raise
Exception
(
'OTP is invalid.'
)
raise
Exception
(
'OTP is invalid.'
)
api_key
=
generate_api_key
()
api_key
=
self
.
generate_api_key
()
process_valid_loging
(
user_info
,
api_key
)
return
prepare_api_response
(
SUCCESS_CODE
,
'OTP Verified Successfully'
,
data
=
{
'apiKey'
:
api_key
}
SUCCESS_CODE
,
'OTP Verified Successfully'
,
data
=
{
'apiKey'
:
api_key
}
)
except
ValidationError
as
e
:
...
...
@@ -235,16 +227,14 @@ class ForgotPasswordVerify(Resource):
process_valid_loging
(
user_info
,
api_key
)
return
prepare_api_response
(
SUCCESS_CODE
,
'Email Verified Successfully'
,
data
=
{
'apiKey'
:
api_key
}
SUCCESS_CODE
,
'OTP Verified Successfully'
,
data
=
{
'apiKey'
:
api_key
}
)
except
ValidationError
as
e
:
return
prepare_api_response
(
VALIDATION_ERROR_CODE
,
VALIDATION_ERROR_MESSAGE
,
error
=
e
.
normalized_messages
()
error
=
e
.
normalized_messages
()
,
)
except
Exception
as
e
:
...
...
@@ -279,7 +269,7 @@ class SetNewPassword(Resource):
return
prepare_api_response
(
VALIDATION_ERROR_CODE
,
VALIDATION_ERROR_MESSAGE
,
error
=
e
.
normalized_messages
()
error
=
e
.
normalized_messages
()
,
)
except
Exception
as
e
:
...
...
@@ -324,8 +314,9 @@ class GetUser(Resource):
validator
=
GetUserValidator
()
arguments
:
dict
=
validator
.
load
(
request
.
args
)
user_info
:
ORM
.
User
|
None
=
\
get_user_by_id_for_admin
(
user_id
,
arguments
[
'id'
])
user_info
:
ORM
.
User
|
None
=
get_user_by_id_for_admin
(
user_id
,
arguments
[
'id'
]
)
if
not
user_info
:
return
prepare_api_response
(
404
,
'User not found'
)
...
...
@@ -361,7 +352,63 @@ class GetAllUsers(Resource):
return
prepare_api_response
(
SUCCESS_CODE
,
GET_ALL_SUCCESS_MESSAGE
,
data
=
[
user
.
to_dict
(
rules
=
(
'-user_roles'
,))
for
user
in
users_list
]
data
=
[
user
.
to_dict
(
rules
=
(
'-user_roles'
,))
for
user
in
users_list
],
)
except
Exception
as
e
:
logger
.
error
(
traceback
.
format_exc
())
return
prepare_api_response
(
EXCEPTION_CODE
,
str
(
e
))
@
ns
.
route
(
'/map-role'
,
methods
=
[
'GET'
])
class
MapRole
(
Resource
):
@
ns
.
doc
(
security
=
SECURITY
)
@
ns
.
expect
(
*
map_user_role_payload
())
@
ns
.
response
(
*
map_user_role_response
())
@
fetch_user
()
@
sanitized
()
def
get
(
self
,
user_id
:
int
):
try
:
validator
=
MapUserRoleValidator
()
payload
:
dict
=
validator
.
load
(
request
.
args
)
map_user_role
(
user_id
,
payload
[
'user_id'
],
payload
[
'role_id'
])
return
prepare_api_response
(
SUCCESS_CODE
,
'Role mapped successfully'
)
except
ValidationError
as
e
:
return
prepare_api_response
(
VALIDATION_ERROR_CODE
,
VALIDATION_ERROR_MESSAGE
,
error
=
e
.
normalized_messages
(),
)
except
Exception
as
e
:
logger
.
error
(
traceback
.
format_exc
())
return
prepare_api_response
(
EXCEPTION_CODE
,
str
(
e
))
@
ns
.
route
(
'/register'
,
methods
=
[
'POST'
])
class
Register
(
Resource
):
@
ns
.
expect
(
*
register_payload
())
@
ns
.
response
(
*
register_response
())
@
sanitized
()
def
post
(
self
):
try
:
validator
=
RegisterValidator
()
payload
:
dict
=
validator
.
load
(
request
.
get_json
())
register_new_user
(
payload
)
return
prepare_api_response
(
SUCCESS_CODE
,
INSERT_SUCCESS_MESSAGE
)
except
ValidationError
as
e
:
return
prepare_api_response
(
VALIDATION_ERROR_CODE
,
VALIDATION_ERROR_MESSAGE
,
error
=
e
.
normalized_messages
(),
)
except
Exception
as
e
:
...
...
@@ -369,4 +416,30 @@ class GetAllUsers(Resource):
return
prepare_api_response
(
EXCEPTION_CODE
,
str
(
e
))
# TODO: implement forget password and registration api
\ No newline at end of file
@
ns
.
route
(
'/add'
,
methods
=
[
'POST'
])
class
AddUser
(
Resource
):
@
ns
.
doc
(
security
=
SECURITY
)
@
ns
.
expect
(
*
add_user_payload
())
@
ns
.
response
(
*
add_user_response
())
@
sanitized
()
@
fetch_user
()
def
post
(
self
,
user_id
:
int
):
try
:
validator
=
AddUserValidator
()
payload
:
dict
=
validator
.
load
(
request
.
get_json
())
add_new_user
(
payload
,
user_id
)
return
prepare_api_response
(
SUCCESS_CODE
,
INSERT_SUCCESS_MESSAGE
)
except
ValidationError
as
e
:
return
prepare_api_response
(
VALIDATION_ERROR_CODE
,
VALIDATION_ERROR_MESSAGE
,
error
=
e
.
normalized_messages
(),
)
except
Exception
as
e
:
logger
.
error
(
traceback
.
format_exc
())
return
prepare_api_response
(
EXCEPTION_CODE
,
str
(
e
))
\ No newline at end of file
app/routes/user/user_dao_service.py
View file @
d93b5e06
from
typing
import
List
from
app
import
orm
as
ORM
from
app
import
db
,
bcrypt
from
app.app_config.constant
import
RoleTypeEnum
from
app
import
db
def
get_user_by_username
(
username
:
str
)
->
ORM
.
User
|
None
:
return
ORM
.
User
.
query
.
filter_by
(
username
=
username
,
is_deleted
=
False
)
.
first
()
return
ORM
.
User
.
query
.
filter_by
(
username
=
username
)
.
first
()
def
get_user_by_email
(
email
:
str
)
->
ORM
.
User
|
None
:
return
ORM
.
User
.
query
.
filter_by
(
email
=
email
,
is_deleted
=
False
)
.
first
()
return
ORM
.
User
.
query
.
filter_by
(
email
=
email
)
.
first
()
def
get_user_by_id
(
id
:
int
)
->
ORM
.
User
|
None
:
return
ORM
.
User
.
query
.
filter_by
(
id
=
id
,
is_deleted
=
False
)
.
first
()
return
ORM
.
User
.
query
.
filter_by
(
id
=
id
)
.
first
()
def
get_user_by_id_for_admin
(
admin_id
:
int
,
user_id
:
int
)
->
ORM
.
User
|
None
:
...
...
@@ -22,27 +23,14 @@ def get_user_by_id_for_admin(admin_id: int, user_id: int) -> ORM.User | None:
if
not
admin_user
:
raise
Exception
(
'User not found for mapped apiKey'
)
if
all
(
user_role
.
role
.
role_type
.
role_name
!=
RoleTypeEnum
.
SUPER_ADMIN
.
value
for
user_role
in
admin_user
.
user_roles
):
if
all
(
user_role
.
role
.
role_type
.
role_name
!=
RoleTypeEnum
.
PROJECT_ADMIN
.
value
for
user_role
in
admin_user
.
user_roles
):
raise
Exception
(
'You do not have permission to view user details'
)
else
:
# return all user data for project admin for his specific project
if
admin_user
.
role_type
.
role_name
!=
RoleTypeEnum
.
SUPER_ADMIN
.
value
:
return
ORM
.
User
.
query
.
filter
(
ORM
.
User
.
is_deleted
==
False
,
ORM
.
User
.
id
==
user_id
,
ORM
.
User
.
project_id
==
admin_user
.
project_id
ORM
.
User
.
project_id
==
admin_user
.
project_id
,
)
.
first
()
else
:
# return all user data for super admin
return
ORM
.
User
.
query
.
filter
(
ORM
.
User
.
is_deleted
==
False
,
ORM
.
User
.
id
==
user_id
)
.
first
()
return
ORM
.
User
.
query
.
filter
(
ORM
.
User
.
id
==
user_id
)
.
first
()
def
get_user_list_for_project_admin
(
admin_id
:
int
)
->
List
[
ORM
.
User
]:
...
...
@@ -51,37 +39,147 @@ def get_user_list_for_project_admin(admin_id: int) -> List[ORM.User]:
if
not
admin_user
:
raise
Exception
(
'User not found for mapped apiKey'
)
if
all
(
user_role
.
role
.
role_type
.
role_name
!=
RoleTypeEnum
.
SUPER_ADMIN
.
value
for
user_role
in
admin_user
.
user_roles
):
if
all
(
user_role
.
role
.
role_type
.
role_name
!=
RoleTypeEnum
.
PROJECT_ADMIN
.
value
for
user_role
in
admin_user
.
user_roles
):
raise
Exception
(
'You do not have permission to view user list'
)
else
:
# return all user data for project admin for his specific project
return
ORM
.
User
.
query
.
filter
(
ORM
.
User
.
is_deleted
==
False
,
ORM
.
User
.
project_id
==
admin_user
.
project_id
)
.
all
()
if
admin_user
.
role_type
.
role_name
!=
RoleTypeEnum
.
SUPER_ADMIN
.
value
:
return
ORM
.
User
.
query
.
filter
(
ORM
.
User
.
project_id
==
admin_user
.
project_id
)
.
all
()
else
:
# return all user data for super admin
return
ORM
.
User
.
query
.
filter
(
ORM
.
User
.
is_deleted
==
False
)
.
all
()
return
ORM
.
User
.
query
.
all
()
def
map_user_role
(
admin_id
:
int
,
user_id
:
int
,
role_id
:
int
)
->
None
:
admin_user
:
ORM
.
User
|
None
=
get_user_by_id
(
admin_id
)
if
not
admin_user
:
raise
Exception
(
'User not found for mapped apiKey'
)
user_info
:
ORM
.
User
|
None
=
get_user_by_id
(
user_id
)
if
not
user_info
:
raise
Exception
(
'User not found for given user_id'
)
role_info
:
ORM
.
Role
|
None
=
ORM
.
Role
.
query
.
filter_by
(
id
=
role_id
)
.
first
()
if
not
role_info
:
raise
Exception
(
'Role not found for given role_id'
)
def
update_password
(
user_id
:
int
,
new_password
:
str
)
->
bool
|
None
:
try
:
if
user_info
.
role_type_id
!=
role_info
.
role_type_id
:
raise
Exception
(
'The role-type for user and role does not match'
)
user_info
:
ORM
.
User
=
get_user_by_id
(
user_id
)
if
user_info
.
project_id
!=
role_info
.
project_id
:
raise
Exception
(
'This role cannot be mapped for this user'
)
user_info
.
password
=
new_password
if
admin_user
.
role_type
.
role_name
!=
RoleTypeEnum
.
SUPER_ADMIN
.
value
:
if
user_info
.
project_id
!=
admin_user
.
project_id
:
raise
Exception
(
'You are not authorized to perform this action'
)
user_role_map
:
ORM
.
UserRoleMap
|
None
=
ORM
.
UserRoleMap
.
query
.
filter
(
ORM
.
UserRoleMap
.
user_id
==
user_id
)
.
first
()
if
user_role_map
:
user_role_map
.
role_id
=
role_id
user_role_map
.
updated_by
=
admin_user
.
id
else
:
user_role_map
=
ORM
.
UserRoleMap
(
user_id
=
user_id
,
role_id
=
role_id
,
created_by
=
admin_user
.
id
)
db
.
session
.
add
(
user_role_map
)
db
.
session
.
commit
()
return
True
except
Exception
as
e
:
db
.
session
.
rollback
()
raise
e
def
register_new_user
(
user_info
:
dict
)
->
int
:
existing_user_info
:
ORM
.
User
|
None
=
ORM
.
User
.
query
.
filter_by
(
username
=
user_info
.
get
(
'username'
)
)
.
first
()
if
existing_user_info
:
raise
Exception
(
'User already exists with this username'
)
existing_user_info
:
ORM
.
User
|
None
=
ORM
.
User
.
query
.
filter_by
(
email
=
user_info
.
get
(
'email'
)
)
.
first
()
if
existing_user_info
:
raise
Exception
(
'User already exists with this email'
)
existing_user_info
:
ORM
.
User
|
None
=
ORM
.
User
.
query
.
filter_by
(
phone_number
=
user_info
.
get
(
'phone_number'
)
)
.
first
()
if
existing_user_info
:
raise
Exception
(
'User already exists with this phone number'
)
role_type_info
=
ORM
.
RoleType
.
query
.
filter_by
(
role_name
=
RoleTypeEnum
.
PROJECT_USER
.
value
)
.
first
()
if
not
role_type_info
:
raise
Exception
(
'Role type not found'
)
user_info
[
'role_type_id'
]
=
role_type_info
.
id
user_info
[
'password'
]
=
bcrypt
.
generate_password_hash
(
user_info
.
get
(
'password'
)
)
.
decode
(
'utf-8'
)
new_user
=
ORM
.
User
(
**
user_info
)
db
.
session
.
add
(
new_user
)
db
.
session
.
commit
()
return
new_user
.
id
def
add_new_user
(
user_info
:
dict
,
admin_id
:
int
)
->
int
:
admin_user
:
ORM
.
User
|
None
=
get_user_by_id
(
admin_id
)
if
not
admin_user
:
raise
Exception
(
'User not found for mapped apiKey'
)
role_type_info
=
ORM
.
RoleType
.
query
.
filter_by
(
id
=
user_info
.
get
(
'role_type_id'
)
)
.
first
()
if
not
role_type_info
:
raise
Exception
(
'Role type not found'
)
if
admin_user
.
role_type
.
role_name
!=
RoleTypeEnum
.
SUPER_ADMIN
.
value
:
if
user_info
.
get
(
'project_id'
)
!=
admin_user
.
project_id
:
raise
Exception
(
'You are not authorized to perform this action'
)
if
role_type_info
.
role_name
in
[
RoleTypeEnum
.
SUPER_ADMIN
.
value
,
RoleTypeEnum
.
PROJECT_ADMIN
.
value
,
]:
raise
Exception
(
'You are not authorized to map this role type'
)
existing_user_info
:
ORM
.
User
|
None
=
ORM
.
User
.
query
.
filter_by
(
username
=
user_info
.
get
(
'username'
)
)
.
first
()
if
existing_user_info
:
raise
Exception
(
'User already exists with this username'
)
existing_user_info
:
ORM
.
User
|
None
=
ORM
.
User
.
query
.
filter_by
(
email
=
user_info
.
get
(
'email'
)
)
.
first
()
if
existing_user_info
:
raise
Exception
(
'User already exists with this email'
)
existing_user_info
:
ORM
.
User
|
None
=
ORM
.
User
.
query
.
filter_by
(
phone_number
=
user_info
.
get
(
'phone_number'
)
)
.
first
()
if
existing_user_info
:
raise
Exception
(
'User already exists with this phone number'
)
user_info
[
'password'
]
=
bcrypt
.
generate_password_hash
(
user_info
.
get
(
'password'
)
)
.
decode
(
'utf-8'
)
user_info
[
'created_by'
]
=
admin_user
.
id
new_user
=
ORM
.
User
(
**
user_info
)
db
.
session
.
add
(
new_user
)
db
.
session
.
commit
()
return
new_user
.
id
app/routes/user/user_payload.py
View file @
d93b5e06
...
...
@@ -13,9 +13,7 @@ def login_payload() -> list:
def
otp_payload
()
->
list
:
payload
=
api
.
model
(
'OTP Payload'
,
{
'email'
:
fields
.
String
}
)
payload
=
api
.
model
(
'OTP Payload'
,
{
'email'
:
fields
.
String
})
return
[
payload
]
...
...
@@ -54,3 +52,54 @@ def get_user_payload() -> list:
parser
.
add_argument
(
'id'
,
required
=
True
,
type
=
int
,
location
=
'args'
)
return
[
parser
]
def
map_user_role_payload
()
->
list
:
parser
=
api
.
parser
()
parser
.
add_argument
(
'user_id'
,
required
=
True
,
type
=
int
,
location
=
'args'
)
parser
.
add_argument
(
'role_id'
,
required
=
True
,
type
=
int
,
location
=
'args'
)
return
[
parser
]
def
register_payload
()
->
list
:
payload
=
api
.
model
(
'Register Payload'
,
{
'username'
:
fields
.
String
(
required
=
True
),
'name'
:
fields
.
String
(
required
=
True
),
'password'
:
fields
.
String
(
required
=
True
),
'organization'
:
fields
.
String
(
required
=
True
),
'project_id'
:
fields
.
Integer
(
required
=
True
),
'gstin'
:
fields
.
String
(
required
=
False
),
'email'
:
fields
.
String
(
required
=
True
),
'phone_number'
:
fields
.
String
(
required
=
True
),
'email_verified'
:
fields
.
Boolean
(
default
=
False
),
'phone_verified'
:
fields
.
Boolean
(
default
=
False
),
'status'
:
fields
.
String
(
default
=
'ACTIVE'
),
},
)
return
[
payload
]
def
add_user_payload
()
->
list
:
payload
=
api
.
model
(
'Register Payload'
,
{
'username'
:
fields
.
String
(
required
=
True
),
'name'
:
fields
.
String
(
required
=
True
),
'password'
:
fields
.
String
(
required
=
True
),
'organization'
:
fields
.
String
(
required
=
True
),
'project_id'
:
fields
.
Integer
(
required
=
True
),
'role_type_id'
:
fields
.
Integer
(
required
=
True
),
'gstin'
:
fields
.
String
(
required
=
False
),
'email'
:
fields
.
String
(
required
=
True
),
'phone_number'
:
fields
.
String
(
required
=
True
),
'email_verified'
:
fields
.
Boolean
(
default
=
False
),
'phone_verified'
:
fields
.
Boolean
(
default
=
False
),
'status'
:
fields
.
String
(
default
=
'ACTIVE'
),
},
)
return
[
payload
]
app/routes/user/user_response.py
View file @
d93b5e06
...
...
@@ -3,6 +3,7 @@ from app.app_config.response_message import *
from
app.routes
import
api
from
flask_restx
import
fields
from
app.routes.role_type.role_type_response
import
ROLE_TYPE_RESPONSE_MODEL
from
app.utils.api_response
import
prepare_swagger_response
USER_RESPONSE_MODEL
:
any
=
api
.
model
(
...
...
@@ -18,14 +19,16 @@ USER_RESPONSE_MODEL: any = api.model(
'email_verified'
:
fields
.
Boolean
,
'phone_verified'
:
fields
.
Boolean
,
'status'
:
fields
.
String
,
'role_type_id'
:
fields
.
Integer
,
'project_id'
:
fields
.
Integer
,
'role_type'
:
fields
.
Nested
(
ROLE_TYPE_RESPONSE_MODEL
),
'user_roles'
:
fields
.
List
(
fields
.
String
(
default
=
'{}'
,
description
=
'user roles object in json'
)
),
'created_at'
:
fields
.
DateTime
,
'created_by'
:
fields
.
Integer
,
'updated_at'
:
fields
.
DateTime
,
'updated_by'
:
fields
.
Integer
,
'is_deleted'
:
fields
.
Boolean
,
'updated_by'
:
fields
.
Integer
},
)
...
...
@@ -36,22 +39,25 @@ def login_response() -> any:
return
prepare_swagger_response
(
code
=
SUCCESS_CODE
,
message
=
SUCCESS_MESSAGE
,
model_name
=
'login
OTP Response'
,
model_name
=
'loginOTP Response'
,
data
=
fields
.
Nested
(
LOGIN_RESPONSE_MODEL
),
)
def
otp_response
()
->
any
:
return
prepare_swagger_response
(
code
=
SUCCESS_CODE
,
message
=
'OTP generated successfully'
,
model_name
=
'Verify
OTP Response'
,
model_name
=
'VerifyOTP Response'
,
data
=
fields
.
Nested
(
LOGIN_RESPONSE_MODEL
),
)
def
otp_verify_response
()
->
any
:
return
prepare_swagger_response
(
code
=
SUCCESS_CODE
,
message
=
'OTP Verified Successfully'
,
model_name
=
'login
OTP
Verify Response'
,
model_name
=
'login
OTP
Verify Response'
,
data
=
fields
.
Nested
(
LOGIN_RESPONSE_MODEL
),
)
...
...
@@ -79,9 +85,11 @@ def get_user_response() -> any:
data
=
fields
.
Nested
(
USER_RESPONSE_MODEL
),
)
def
get_user_profile_response
()
->
any
:
return
get_user_response
()
def
get_user_list_response
()
->
any
:
return
prepare_swagger_response
(
code
=
SUCCESS_CODE
,
...
...
@@ -89,3 +97,21 @@ def get_user_list_response() -> any:
model_name
=
'getUserList Response'
,
data
=
fields
.
List
(
fields
.
Nested
(
USER_RESPONSE_MODEL
)),
)
def
map_user_role_response
()
->
any
:
return
prepare_swagger_response
(
code
=
SUCCESS_CODE
,
message
=
'Role mapped Successfully'
,
model_name
=
'roleMap Response'
)
def
register_response
()
->
any
:
return
prepare_swagger_response
(
code
=
SUCCESS_CODE
,
message
=
INSERT_SUCCESS_MESSAGE
,
model_name
=
'register Response'
,
)
def
add_user_response
()
->
any
:
return
register_response
()
\ No newline at end of file
app/routes/user/user_util.py
View file @
d93b5e06
...
...
@@ -2,6 +2,7 @@ import string
import
secrets
from
typing
import
List
from
app
import
orm
as
ORM
from
app.app_config.constant
import
EndpointTagEnum
from
app.utils.redis
import
set_value
from
app
import
db
from
app.app_config.constant
import
ALPHANUMARIC_STRING
...
...
@@ -9,39 +10,36 @@ from app.app_config.constant import ALPHANUMARIC_STRING
def
process_valid_loging
(
user_info
:
ORM
.
User
,
api_key
:
str
)
->
None
:
set_value
(
f
'{user_info.id}_un'
,
user_info
.
username
,
60
*
60
*
24
)
set_value
(
f
'{api_key}_id'
,
user_info
.
id
,
60
*
60
*
24
)
DEFAULT_EXPIRES
:
int
=
60
*
60
*
24
set_value
(
f
'{user_info.id}_un'
,
user_info
.
username
,
DEFAULT_EXPIRES
)
set_value
(
f
'{user_info.id}_pid'
,
user_info
.
project_id
,
DEFAULT_EXPIRES
)
set_value
(
f
'{api_key}_id'
,
user_info
.
id
,
DEFAULT_EXPIRES
)
# TODO: currently we consider user have only one role
if
len
(
user_info
.
user_roles
)
>
0
:
set_value
(
f
'{api_key}_rid'
,
user_info
.
user_roles
[
0
]
.
role
.
id
,
60
*
60
*
24
)
set_value
(
f
'{user_info.id}_rn'
,
user_info
.
user_roles
[
0
]
.
role
.
role_name
,
60
*
60
*
24
,
)
set_value
(
f
'{user_info.id}_rt'
,
user_info
.
user_roles
[
0
]
.
role
.
role_type
.
role_name
,
60
*
60
*
24
,
)
role_id
:
int
=
user_info
.
user_roles
[
0
]
.
role_id
role_name
:
str
=
user_info
.
user_roles
[
0
]
.
role
.
role_name
set_value
(
f
'{user_info.id}_rid'
,
role_id
,
DEFAULT_EXPIRES
)
set_value
(
f
'{user_info.id}_rn'
,
role_name
,
DEFAULT_EXPIRES
)
set_value
(
f
'{user_info.id}_rt'
,
user_info
.
role_type_id
,
DEFAULT_EXPIRES
)
# TODO: fetch all api mapped with role id and set in redis
api_list
:
List
[
ORM
.
Api
]
=
(
db
.
session
.
query
(
ORM
.
Api
)
.
join
(
ORM
.
RoleApiMap
,
ORM
.
Api
.
id
==
ORM
.
RoleApiMap
.
api_id
)
.
filter
(
ORM
.
RoleApiMap
.
role_id
==
user_info
.
user_roles
[
0
]
.
role
.
id
,
ORM
.
Api
.
tag
==
'RA'
,
ORM
.
RoleApiMap
.
role_id
==
role_
id
,
ORM
.
Api
.
tag
==
EndpointTagEnum
.
RA
.
value
,
)
.
all
()
)
for
api
in
api_list
:
set_value
(
f
'r_{
user_info.user_roles[0].role.
id}_{api.id}_{api.method}'
,
f
'r_{
role_
id}_{api.id}_{api.method}'
,
1
,
60
*
60
*
24
,
DEFAULT_EXPIRES
,
)
...
...
app/routes/user/user_validator.py
View file @
d93b5e06
...
...
@@ -17,3 +17,34 @@ class SetNewPasswordValidator(Schema):
class
GetUserValidator
(
Schema
):
id
=
fields
.
Integer
(
required
=
True
,
validate
=
validate
.
Range
(
min
=
1
))
class
MapUserRoleValidator
(
Schema
):
user_id
=
fields
.
Integer
(
required
=
True
,
validate
=
validate
.
Range
(
min
=
1
))
role_id
=
fields
.
Integer
(
required
=
True
,
validate
=
validate
.
Range
(
min
=
1
))
class
RegisterValidator
(
Schema
):
username
=
fields
.
String
(
required
=
True
,
validate
=
validate
.
Length
(
min
=
1
,
max
=
255
))
name
=
fields
.
String
(
required
=
True
,
validate
=
validate
.
Length
(
min
=
1
,
max
=
255
))
password
=
fields
.
String
(
required
=
True
,
validate
=
validate
.
Length
(
min
=
6
,
max
=
16
))
organization
=
fields
.
String
()
project_id
=
fields
.
Integer
(
required
=
True
,
validate
=
validate
.
Range
(
min
=
1
))
gstin
=
fields
.
String
(
required
=
False
)
email
=
fields
.
String
(
required
=
True
,
validate
=
validate
.
Email
())
phone_number
=
fields
.
String
(
required
=
True
,
validate
=
validate
.
Regexp
(
r'^[0-9]{10}$'
))
email_verified
=
fields
.
Boolean
(
default
=
False
)
phone_verified
=
fields
.
Boolean
(
default
=
False
)
status
=
fields
.
String
(
default
=
'ACTIVE'
)
class
AddUserValidator
(
Schema
):
username
=
fields
.
String
(
required
=
True
,
validate
=
validate
.
Length
(
min
=
1
,
max
=
255
))
name
=
fields
.
String
(
required
=
True
,
validate
=
validate
.
Length
(
min
=
1
,
max
=
255
))
password
=
fields
.
String
(
required
=
True
,
validate
=
validate
.
Length
(
min
=
6
,
max
=
16
))
organization
=
fields
.
String
()
project_id
=
fields
.
Integer
(
required
=
True
,
validate
=
validate
.
Range
(
min
=
1
))
role_type_id
=
fields
.
Integer
(
required
=
True
,
validate
=
validate
.
Range
(
min
=
1
))
gstin
=
fields
.
String
(
required
=
False
)
email
=
fields
.
String
(
required
=
True
,
validate
=
validate
.
Email
())
phone_number
=
fields
.
String
(
required
=
True
,
validate
=
validate
.
Regexp
(
r'^[0-9]{10}$'
))
email_verified
=
fields
.
Boolean
(
default
=
False
)
phone_verified
=
fields
.
Boolean
(
default
=
False
)
status
=
fields
.
String
(
default
=
'ACTIVE'
)
\ No newline at end of file
app/utils/mail_service.py
View file @
d93b5e06
...
...
@@ -3,106 +3,16 @@ from flask_mail import Message
from
app
import
mail
def
send_otp
(
sender
:
str
,
receiver
:
list
,
otp
:
int
)
->
None
:
def
send_otp
(
sender
:
str
,
receiver
:
str
,
otp
:
int
)
->
None
:
email_title
=
'OTP for Login'
msg
=
Message
(
email_title
,
sender
=
sender
,
recipients
=
receiver
)
msg
=
Message
(
email_title
,
sender
=
sender
,
recipients
=
[
receiver
]
)
# Define the OTP template
email_html
=
'''
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>OTP Template</title>
<link
href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600&display=swap"
rel="stylesheet"
/>
</head>
<body
style="
margin: 0;
font-family: 'Poppins', sans-serif;
background: #ffffff;
font-size: 14px;
"
>
<div
style="
max-width: 680px;
margin: 0 auto;
padding: 45px 30px 60px;
background: #f4f7ff;
font-size: 14px;
color: #434343;
"
>
<main>
<div
style="
margin: 0;
margin-top: 70px;
padding: 92px 30px 115px;
background: #ffffff;
border-radius: 30px;
text-align: center;
"
>
<div style="width: 100
%
; max-width: 489px; margin: 0 auto;">
<h1
style="
margin: 0;
font-size: 24px;
font-weight: 500;
color: #1f1f1f;
"
>
OTP Verification
</h1>
<p
style="
margin: 0;
margin-top: 17px;
font-size: 16px;
font-weight: 500;
"
>
Hey {{ user }},
</p>
<p
style="
margin: 0;
margin-top: 17px;
font-weight: 500;
letter-spacing: 0.56px;
"
>
Use the following OTP to login. OTP is valid for
<span style="font-weight: 600; color: #1f1f1f;">5 minutes</span>.
Do not share this code with others.
</p>
<p
style="
margin: 0;
margin-top: 60px;
font-size: 40px;
font-weight: 600;
letter-spacing: 25px;
color: #ba3d4f;
"
>
{{ otp }}
</p>
</div>
</div>
</main>
</div>
</body>
</html>
'''
email_html_rendered
=
render_template_string
(
email_html
,
user
=
receiver
[
0
],
otp
=
otp
)
html_content
:
str
=
''
with
open
(
'html_templates/otp-login-template.html'
,
'r'
)
as
file
:
html_content
=
file
.
read
()
email_html_rendered
=
render_template_string
(
html_content
,
user
=
receiver
,
otp
=
otp
)
msg
.
html
=
email_html_rendered
msg
.
subject
=
'OTP Verification for Login'
...
...
database/query.sql
View file @
d93b5e06
INSERT
INTO
public
.
role_type
(
role_name
,
is_deleted
)
VALUES
(
'SUPER_ADMIN'
,
false
),
(
'PROJECT_ADMIN'
,
false
),
(
'PROJECT_STAFF'
,
false
),
(
'PROJECT_USER'
,
false
);
INSERT
INTO
public
.
webomagic_user
(
username
,
...
...
@@ -6,24 +13,43 @@ INSERT INTO
organization
,
email
,
phone_number
,
status
status
,
role_type_id
)
VALUES
(
'deepdey'
,
'Deep Dey'
,
'$2b$12$
du0B3AlnD5wOYxt.ADYPwuaCFqF7R3XrLHDiNca4FvVtTGPIQVEu2
'
,
'$2b$12$
R0HxrHj7XSx.QszmMWis5O.6jje8FTvpJfOMeQh9Gh9LCQHaalNCW
'
,
'WebsoftTechs'
,
'deep.websofttechs@gmail.com'
,
'8697448896'
,
'IN_ACTIVE'
'IN_ACTIVE'
,
1
);
INSERT
INTO
public
.
role_type
(
role_name
,
is_deleted
)
VALUES
(
'SUPER_ADMIN'
,
false
),
(
'PROJECT_ADMIN'
,
false
),
(
'PROJECT_STAFF'
,
false
),
(
'PROJECT_USER'
,
false
);
public
.
webomagic_user
(
username
,
name
,
password
,
organization
,
email
,
phone_number
,
status
,
role_type_id
,
project_id
)
VALUES
(
'monirul'
,
'monirul Midda'
,
'$2b$12$R0HxrHj7XSx.QszmMWis5O.6jje8FTvpJfOMeQh9Gh9LCQHaalNCW'
,
'WebsoftTechs'
,
'monirul@gmail.com'
,
'8697448896'
,
'IN_ACTIVE'
,
2
,
1
);
INSERT
INTO
public
.
role
(
...
...
@@ -33,8 +59,7 @@ INSERT INTO
is_deleted
,
created_by
)
VALUES
(
1
,
'PROJECT_ADMIN'
,
1
,
false
,
1
),
(
3
,
'PRODUCT_MANAGER'
,
1
,
false
,
1
);
VALUES
(
3
,
'PRODUCT_MANAGER'
,
1
,
false
,
2
);
INSERT
INTO
public
.
webomagic_api
(
endpoint
,
method
,
tag
)
...
...
database/schema.sql
View file @
d93b5e06
CREATE
TABLE
IF
NOT
EXISTS
role_type
(
id
BIGSERIAL
PRIMARY
KEY
NOT
NULL
,
role_name
VARCHAR
(
80
)
UNIQUE
NOT
NULL
,
is_deleted
BOOLEAN
DEFAULT
false
,
created_at
TIMESTAMP
NOT
NULL
DEFAULT
now
(),
updated_at
TIMESTAMP
);
CREATE
TABLE
IF
NOT
EXISTS
webomagic_user
(
id
BIGSERIAL
PRIMARY
KEY
NOT
NULL
,
username
VARCHAR
(
80
)
UNIQUE
NOT
NULL
,
...
...
@@ -5,17 +13,18 @@ CREATE TABLE IF NOT EXISTS webomagic_user (
password
VARCHAR
(
80
)
NOT
NULL
,
organization
VARCHAR
(
255
),
project_id
BIGINT
,
role_type_id
BIGINT
NOT
NULL
,
gstin
VARCHAR
(
50
),
email
VARCHAR
(
120
)
UNIQUE
NOT
NULL
,
phone_number
VARCHAR
(
20
)
UNIQUE
NOT
NULL
,
phone_verified
BOOLEAN
DEFAULT
false
,
email_verified
BOOLEAN
DEFAULT
false
,
status
VARCHAR
(
20
)
NOT
NULL
,
is_deleted
BOOLEAN
DEFAULT
false
,
created_at
TIMESTAMP
NOT
NULL
DEFAULT
now
(),
created_by
BIGINT
,
updated_at
TIMESTAMP
,
updated_by
BIGINT
,
FOREIGN
KEY
(
role_type_id
)
REFERENCES
role_type
(
id
),
FOREIGN
KEY
(
created_by
)
REFERENCES
webomagic_user
(
id
),
FOREIGN
KEY
(
updated_by
)
REFERENCES
webomagic_user
(
id
)
);
...
...
@@ -34,14 +43,6 @@ CREATE TABLE IF NOT EXISTS webomagic_api (
UNIQUE
(
endpoint
,
method
)
);
CREATE
TABLE
IF
NOT
EXISTS
role_type
(
id
BIGSERIAL
PRIMARY
KEY
NOT
NULL
,
role_name
VARCHAR
(
80
)
UNIQUE
NOT
NULL
,
is_deleted
BOOLEAN
DEFAULT
false
,
created_at
TIMESTAMP
NOT
NULL
DEFAULT
now
(),
updated_at
TIMESTAMP
);
CREATE
TABLE
IF
NOT
EXISTS
role
(
id
BIGSERIAL
PRIMARY
KEY
NOT
NULL
,
role_type_id
BIGINT
NOT
NULL
,
...
...
html_templates/otp-login-template.html
0 → 100644
View file @
d93b5e06
<!DOCTYPE html>
<html
lang=
"en"
>
<head>
<meta
charset=
"UTF-8"
/>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1.0"
/>
<meta
http-equiv=
"X-UA-Compatible"
content=
"ie=edge"
/>
<title>
OTP Template
</title>
<link
href=
"https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600&display=swap"
rel=
"stylesheet"
/>
</head>
<body
style=
"
margin: 0;
font-family: 'Poppins', sans-serif;
background: #ffffff;
font-size: 14px;
"
>
<div
style=
"
max-width: 680px;
margin: 0 auto;
padding: 45px 30px 60px;
background: #f4f7ff;
font-size: 14px;
color: #434343;
"
>
<main>
<div
style=
"
margin: 0;
margin-top: 70px;
padding: 92px 30px 115px;
background: #ffffff;
border-radius: 30px;
text-align: center;
"
>
<div
style=
"width: 100%; max-width: 489px; margin: 0 auto;"
>
<h1
style=
"
margin: 0;
font-size: 24px;
font-weight: 500;
color: #1f1f1f;
"
>
OTP Verification
</h1>
<p
style=
"
margin: 0;
margin-top: 17px;
font-size: 16px;
font-weight: 500;
"
>
Hey {{ user }},
</p>
<p
style=
"
margin: 0;
margin-top: 17px;
font-weight: 500;
letter-spacing: 0.56px;
"
>
Use the following OTP to login. OTP is valid for
<span
style=
"font-weight: 600; color: #1f1f1f;"
>
5 minutes
</span>
.
Do not share this code with others.
</p>
<p
style=
"
margin: 0;
margin-top: 60px;
font-size: 40px;
font-weight: 600;
letter-spacing: 25px;
color: #ba3d4f;
"
>
{{ otp }}
</p>
</div>
</div>
</main>
</div>
</body>
</html>
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment