def GET(self): auth = web.ctx.env.get('HTTP_AUTHORIZATION') authreq = False if auth is None: authreq = True else: auth = re.sub('^Basic ','',auth) username,password = base64.decodestring(auth).split(':') if auctionDb.login(username, password): raise web.seeother('/') else: authreq = True if authreq: web.header('WWW-Authenticate','Basic realm="Auth example"') web.ctx.status = '401 Unauthorized' return
def GET(self): auth = web.ctx.env.get('HTTP_AUTHORIZATION') authreq = False if auth is None: authreq = True else: auth = re.sub('^Basic ', '', auth) username, password = base64.decodestring(auth).split(':') if auctionDb.login(username, password): raise web.seeother('/') else: authreq = True if authreq: web.header('WWW-Authenticate', 'Basic realm="Auth example"') web.ctx.status = '401 Unauthorized' return
def POST(self): session = web.config._session data = urlparse.parse_qs(web.data()) print 'POST MADE to /ajax/login' username = data['username'][0] password = data['password'][0] user = auctionDb.login(username, password) result = {} if user != None: session.loggedin = True session.username = user['user_alias'] session.userid = user['user_id'] result['success'] = True else: session.loggedin = False result['success'] = False return json.dumps(result)