コード例 #1
0
def SignIn(request):
    try:
        success = False
        if request.POST.has_key('username') and request.POST.has_key(
                'password'):
            Setting.log.info("login attemp for user:" +
                             request.POST['username'])
            uw = UserWorker()
            InitDB()
            res = uw.SignIn(request.POST['username'], request.POST['password'])
            if res[0]:
                request.session['authenticated'] = True
                request.session['username'] = request.POST['username']
                request.session['user_id'] = res[2]
                Setting.log.info('sign in done for ' + res[1] +
                                 ' and user id is ' + str(res[2]))
                return {'success': True, 'name': res[1]}

        return {'success': success}
    except Exception as ex:
        Setting.log.LogException(ex)
        if Setting.debuging:
            return Response(ex.__str__())
        else:
            return Response('sorry,problem')
コード例 #2
0
def SignIn(header, request):
    try:
        success = False
        if request.POST.has_key('username') and request.POST.has_key(
                'password'):
            uw = UserWorker()
            InitDB()
            res = uw.SignIn(request.POST['username'], request.POST['password'])
            if res[0]:
                request.session['authenticated'] = True
                request.session['username'] = request.POST['username']
                return {'success': True, 'name': res[1]}

        return {'success': success}
    except Exception as ex:
        Setting.error_log.LogException(ex)
        if Setting.debuging:
            return Response(ex.__str__())
        else:
            return Response('sorry,problem')