Пример #1
0
    def CheckLogin(ctx, Account, Password):
        if Account == SystemInfo.CurrentUserName:
            if Password == SystemInfo.CurrentPassword:
                imanageuser = UserInfo()
                imanageuser.Id = 'Administrator'
                imanageuser.UserName = '******'
                imanageuser.Code = 'Administrator'
                imanageuser.CompanyId = '系统'
                imanageuser.DepartmentId = '系统'
                imanageuser.IPAddress = ctx.transport.req["REMOTE_ADDR"]
                imanageuser.IsAdministrator = True
                # TODO:需要做在线人数统计


                user = json.dumps(imanageuser, default=UserInfo.obj_2_json)
                user = SecretHelper.AESEncrypt(user)
                Msg = str(user, encoding = "utf8")
            else:
                Msg = "['认证失败']"
        else:

            returnStatusCode = ''

            returnStatusCode, userInfo = LogOnService.UserLogOn(Account, Password, '', False, ctx.transport.req["REMOTE_ADDR"])

            if returnStatusCode == StatusCode.statusCodeDic.get('OK'):
                user = json.dumps(userInfo, default=UserInfo.obj_2_json)
                user = SecretHelper.AESEncrypt(user)
                Msg = str(user, encoding="utf8")
            else:
                Msg = "['认证失败']"

        yield Msg
Пример #2
0
def CheckLogin(request):
    if request.method == 'GET':
        return render(request, 'Login/Index.html')
    else:
        Msg = ''
        IPAddress = NetHelper.GetIpAddress(request)
        Account = ''
        Password = ''
        Token = ''
        try:
            Account = request.POST['Account']
            Password = request.POST['Password']

            if Account == SystemInfo.CurrentUserName:
                if Password == SystemInfo.CurrentPassword:
                    imanageuser = UserInfo()
                    imanageuser.Id = 'Administrator'
                    imanageuser.UserName = '******'
                    imanageuser.Code = 'Administrator'
                    imanageuser.CompanyId = '系统'
                    imanageuser.DepartmentId = '系统'
                    imanageuser.IPAddress = IPAddress
                    imanageuser.IsAdministrator = True
                    #TODO:需要做在线人数统计

                    Msg = '3'
                    response = HttpResponse(Msg)
                    CommonUtils.AddCurrent(imanageuser, response, request)
                    response.set_cookie(
                        'UIStyle',
                        CommonUtils.UIStyle(imanageuser, response, request))
                    return response
                else:
                    Msg = '4'
                    return HttpResponse(Msg)
            else:

                returnStatusCode = ''

                returnStatusCode, userInfo = LogOnService.UserLogOn(
                    Account, Password, '', False, IPAddress)

                if returnStatusCode == StatusCode.statusCodeDic.get('OK'):
                    Msg = '3'
                    response = HttpResponse(Msg)
                    CommonUtils.AddCurrent(userInfo, response, request)
                    response.set_cookie(
                        'UIStyle',
                        CommonUtils.UIStyle(userInfo, response, request))
                    return response
                else:
                    Msg = '4'

        except Exception as e:
            print(e)

        return HttpResponse(Msg)