Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@jsonapi_rpc(http_methods=["POST"])
def send_mail(self, **args):
"""
description : Send an email
args:
email:
type : string
example : test email
"""
return {"result": args}
@jsonapi_rpc(http_methods=["POST", "GET"])
def send_mail(self, email):
"""
description : Send an email
args:
email:
type : string
example : test email
"""
content = "Mail to {} : {}\n".format(self.name, email)
with open("/tmp/mail.txt", "a+") as mailfile:
mailfile.write(content)
return {"result": "sent {}".format(content)}
@jsonapi_rpc(http_methods=["POST"])
def hash_password(self, password):
self.password_hash = pwd_context.encrypt(password)
@jsonapi_rpc(http_methods=["POST", "GET"])
def send_mail(self, email):
"""
description : Send an email
args:
email:
type : string
example : test email
"""
content = "Mail to {} : {}\n".format(self.name, email)
with open("/tmp/mail.txt", "a+") as mailfile:
mailfile.write(content)
return {"result": "sent {}".format(content)}
@jsonapi_rpc(http_methods=["POST"])
def verify_password(self, password):
return pwd_context.verify(password, self.password_hash)
@jsonapi_rpc(http_methods=["GET"])
def send_mail(self, email):
"""
description : Send an email
args:
email:
type : string
example : test email
"""
content = "Mail to {} : {}\n".format(self.name, email)
with open("/tmp/mail.txt", "a+") as mailfile:
mailfile.write(content)
return {"result": "sent {}".format(content)}
@jsonapi_rpc(http_methods=["GET", "POST"])
def my_rpc(cls, *args, **kwargs):
"""
description : Generate and return a jsonapi-formatted response
pageable: false
parameters:
- name : my_query_string_param
default : my_value
args:
email: test email
"""
print(args)
print(kwargs)
result = cls
response = SAFRSFormattedResponse()
try:
instances = result.query
@jsonapi_rpc(http_methods=["POST"])
def verify_auth_token(token):
s = Serializer(app.config["SECRET_KEY"])
try:
data = s.loads(token)
except SignatureExpired:
return None # valid token, but expired
except BadSignature:
return None # invalid token
user = User.query.get(data["username"])
return user
@jsonapi_rpc(http_methods=["POST"])
def generate_auth_token(self, expiration=600):
s = Serializer(app.config["SECRET_KEY"], expires_in=expiration)
return s.dumps({"username": self.username})
@jsonapi_rpc(http_methods=["POST"])
def send_mail(self, email):
"""
description : Send an email
args:
email: test email
parameters:
- name : my_query_string_param
default : my_value
"""
content = "Mail to {} : {}\n".format(self.name, email)
with open("/tmp/mail.txt", "a+") as mailfile:
mailfile.write(content)
return {"result": "sent {}".format(content)}