Advertisement
Guest User

Untitled

a guest
Feb 28th, 2015
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. def sign_in(email, password):
  2. conn = get_db()
  3. cur = conn.cursor()
  4. password = hashing(password)
  5. print email
  6. cur.execute('select email from user where email =?', (email,))
  7. x = cur.fetchone()
  8. print 'b'
  9. cur.execute('select password from user where email =?', (email,))
  10. y = cur.fetchone()
  11. print 'c'
  12. if x is not None and y is not None and y[0] == password:
  13. token = randomtoken()
  14. cur.execute('insert into token (email) values (?)', (email,))
  15. cur.execute('update token set token =? where email =?', (token, email))
  16. conn.commit()
  17. return jsonify({'success' : 'true', 'message' : 'Successfully signed in.', 'token' : token})
  18. return jsonify({'success' : 'false', 'message' : 'Wrong username or password.'})
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement