示例#1
0
    async def post(self, szPath):
        dictToken = await self.create_token(self.get_argument("appid"),
                                            self.get_argument("secret"))

        if dictToken is None:
            return obj2json(AjaxResult.error())

        self.write(obj2json(dictToken))
示例#2
0
    async def login(self, szUsername, szPwd):
        from pythinkutils.aio.auth.service.SimpleUserService import SimpleUserService
        from pythinkutils.aio.auth.service.PermissionService import PermissionService
        from pythinkutils.common.object2json import obj2json

        nExpireDays = 180

        nUID, _szUsername, szToken = await SimpleUserService.login(
            szUsername, szPwd, nExpireDays)
        if is_empty_string(szToken):
            return (nUID, _szUsername, szToken)

        self.set_secure_cookie("uid",
                               "{}".format(nUID),
                               expires_days=nExpireDays)
        self.set_secure_cookie("username",
                               _szUsername,
                               expires_days=nExpireDays)
        self.set_secure_cookie("token", szToken, expires_days=nExpireDays)

        lstPermissions = await PermissionService.my_permission_list(nUID)
        self.set_secure_cookie("permissions",
                               obj2json(lstPermissions),
                               expires_days=nExpireDays)

        return (nUID, _szUsername, szToken)
示例#3
0
# -*- coding: utf-8 -*-

from decimal import Decimal
from pythinkutils.common.object2json import obj2json

print(Decimal("1.01"))

dictTest = {"a": Decimal("1.01")}

print(obj2json(dictTest))
示例#4
0
 def success(cls, data):
     return obj2json(AjaxResult(data=data))
示例#5
0
 def error(cls, msg=None):
     if msg is None:
         return obj2json(AjaxResult(500, "Server Error"))
     else:
         return obj2json(AjaxResult(500, msg))