Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def auth_login(H,G,P): #(Headers, Get_DATA, POST_DATA)
- #accounts = [('test','test'),('test2','testy')]
- header = []
- #checkconn = sqlite3.connect('webserve-info.db')
- c = conn.cursor()
- try:
- if P['username'] and P['password']:
- username = P['username'][0]
- password = P['password'][0]
- except Exception, g:
- return 200,[], '<h1> %s not provided </h1>' % (g)
- hashv = generate_session_id(username)
- c.execute("SELECT username, password FROM users WHERE username=?",(username,))
- accounts = c.fetchall()
- if (username,password) in accounts:
- C = Cookie.SimpleCookie()
- C['session'] = sessionID
- x = C.output()
- x += '; Path=/'
- header.insert(len(header), x.split(': ',1))
- return 200,header,'<h4>Login Succesful!</h4>'
- """C = Cookie.SimpleCookie()
- C['user'] = ''
- x = C.output()
- x += '; Path=/'
- header.insert(len(header), x.split(': ',1))"""
- return 401,[],'<h1> Unauthorized Access</h1>'
Add Comment
Please, Sign In to add comment