Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_url(self):
request.app_name = "_default"
self.assertEqual(URL("index"), "/index")
request.app_name = "app"
self.assertEqual(URL("index"), "/app/index")
self.assertEqual(URL("a", "b", vars=dict(x=1), hash="y"), "/app/a/b?x=1#y")
def test_url(self):
request.app_name = "_default"
self.assertEqual(URL("index"), "/index")
request.app_name = "app"
self.assertEqual(URL("index"), "/app/index")
self.assertEqual(URL("a", "b", vars=dict(x=1), hash="y"), "/app/a/b?x=1#y")
def register(self, fields, send=True):
if self.use_username:
fields["username"] = fields.get("username", "").lower()
fields["email"] = fields.get("email", "").lower()
token = str(uuid.uuid4())
fields["action_token"] = "pending-registration:%s" % token
res = self.db.auth_user.validate_and_insert(**fields)
if send and res.get("id"):
self._link = link = URL(
self.route, "verify_email", vars=dict(token=token), scheme=True
)
self.send("verify_email", fields, link=link)
return res
db = self.db
value = email.lower()
if self.use_username:
query = (
(db.auth_user.email == value)
if "@" in value
else (db.auth_user.username == value)
)
else:
query = db.auth_user.email == value
user = db(query).select().first()
if user and not user.action_token == "account-blocked":
token = str(uuid.uuid4())
user.update_record(action_token="reset-password-request:" + token)
if send:
self._link = link = URL(
self.route,
"api",
"reset_password",
vars=dict(token=token),
scheme=True,
)
self.send("reset_password", user, link=link)
return token
def grid(self, table):
name = "vue%s" % str(uuid.uuid4())[:8]
return DIV(
self.mtable(table),
TAG.SCRIPT(_src=URL("static/js/axios.min.js")),
TAG.SCRIPT(_src=URL("static/js/vue.min.js")),
TAG.SCRIPT(_src=URL("static/js/utils.js")),
TAG.SCRIPT(_src=URL("static/components/mtable.js")),
TAG.SCRIPT(XML('var app=utils.app("%s"); app.start()' % name)),
_id=name,
)