Add api endpoints for register and activate.
Change-Id: Ifd957fa19960d0f3071f5091c5e30bf50326fde2
This commit is contained in:
parent
64daaeb3a7
commit
d95e844471
@ -393,6 +393,10 @@ def _login(use_cookie):
|
||||
)
|
||||
data['expire_timestamp'] = expire_timestamp
|
||||
user = auth_handler.authenticate_user(**data)
|
||||
if not user.active:
|
||||
raise exception_handler.UserDisabled(
|
||||
'%s is not activated' % user.email
|
||||
)
|
||||
if not login_user(user, remember=data.get('remember', False)):
|
||||
raise exception_handler.UserDisabled('failed to login: %s' % user)
|
||||
|
||||
@ -415,6 +419,17 @@ def login():
|
||||
return _login(True)
|
||||
|
||||
|
||||
@app.route("/users/register", methods=['POST'])
|
||||
def register():
|
||||
"""register new user."""
|
||||
data = _get_request_data()
|
||||
data['is_admin'] = False
|
||||
data['active'] = False
|
||||
return utils.make_json_response(
|
||||
200, user_api.add_user(**data)
|
||||
)
|
||||
|
||||
|
||||
@app.route('/users/logout', methods=['POST'])
|
||||
@login_required
|
||||
def logout():
|
||||
|
Loading…
Reference in New Issue
Block a user