def login_user(flask_request): """Get the user for this request.""" data = flask_request.get_json() user = models.User.login_user(data['email'], data['password']) if not user: raise errors.LoginError('Invalid username/password.') return user
def post(self): """Login a user.""" data = flask.request.get_json() user = controllers.user_login(data['email'], data['password']) if not user: raise errors.LoginError('Invalid username/password') return dict(user=user, team=user.team)
def register(flask_request): gae_user = users.get_current_user() if not gae_user: raise errors.LoginError( 'Cannot register if not logged into AppEngine.') data = flask_request.get_json() user = controllers.register_user( gae_user.email(), data['nick'], '', data.get('team_id'), data.get('team_name'), data.get('team_code')) if users.is_current_user_admin(): user.promote() return user