Beispiel #1
0
def sign_in(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()
            init_db()
            res = uw.sign_in(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.log_exception(ex)
        if Setting.debuging:
            return Response(ex.__str__())
        else:
            return Response('sorry,problem')