Guest User

Untitled

a guest
May 23rd, 2018
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. def auth_login(H,G,P): #(Headers, Get_DATA, POST_DATA)
  2.  
  3. #accounts = [('test','test'),('test2','testy')]
  4.  
  5. header = []
  6.  
  7. #checkconn = sqlite3.connect('webserve-info.db')
  8.  
  9. c = conn.cursor()
  10.  
  11.  
  12.  
  13. try:
  14.  
  15. if P['username'] and P['password']:
  16.  
  17. username = P['username'][0]
  18.  
  19. password = P['password'][0]
  20.  
  21. except Exception, g:
  22.  
  23. return 200,[], '<h1> %s not provided </h1>' % (g)
  24.  
  25.  
  26.  
  27.  
  28. hashv = generate_session_id(username)
  29.  
  30. c.execute("SELECT username, password FROM users WHERE username=?",(username,))
  31.  
  32. accounts = c.fetchall()
  33.  
  34.  
  35.  
  36. if (username,password) in accounts:
  37.  
  38. C = Cookie.SimpleCookie()
  39.  
  40. C['session'] = sessionID
  41.  
  42. x = C.output()
  43.  
  44. x += '; Path=/'
  45.  
  46. header.insert(len(header), x.split(': ',1))
  47.  
  48. return 200,header,'<h4>Login Succesful!</h4>'
  49.  
  50.  
  51.  
  52.  
  53.  
  54. """C = Cookie.SimpleCookie()
  55.  
  56. C['user'] = ''
  57.  
  58. x = C.output()
  59.  
  60. x += '; Path=/'
  61.  
  62. header.insert(len(header), x.split(': ',1))"""
  63.  
  64. return 401,[],'<h1> Unauthorized Access</h1>'
Add Comment
Please, Sign In to add comment