Fix user login from the command line.

This commit is contained in:
yackob03 2013-10-01 12:25:06 -04:00
parent 01240dbf87
commit f5e121d98d

View file

@ -44,11 +44,22 @@ def generate_headers(f):
@app.route('/v1/users/', methods=['POST'])
def create_user():
user_data = request.get_json()
new_user = model.create_user(user_data['username'], user_data['password'],
user_data['email'])
code = model.create_confirm_email_code(new_user)
send_confirmation_email(new_user.username, new_user.email, code.code)
return make_response('Created', 201)
username = user_data['username']
password = user_data['password']
existing_user = model.get_user(username)
if existing_user:
verified = model.verify_user(username, password)
if verified:
return make_response('Verified', 201)
else:
abort(401)
else:
# New user case
new_user = model.create_user(username, password, user_data['email'])
code = model.create_confirm_email_code(new_user)
send_confirmation_email(new_user.username, new_user.email, code.code)
return make_response('Created', 201)
@app.route('/v1/users', methods=['GET'])