def do_logout(username): login_key = request.form['login_key'] user = User.get_user(login_key) if user: if user['username'] == username: off = User.logout(login_key) return jsonify({'res': 'logout'})
def set_mail_subscription(username): login_key = request.form['login_key'] user = User.get_user(login_key) if username == user['username']: res = User.set_mail_subscription(login_key, username) return jsonify({'subscription': res}) abort(401)
def change_password(username): login_key = request.form['login_key'] user = User.get_user(login_key) if user: if username == user['username']: pwd = request.form['password'] old_password = request.form.get('old_password', '') res = User.change_password(username, pwd, old_password) current_app.logger.info(str(res)) return jsonify({'result': {'code': 'true', 'msg': 'Password updated'}}) if res else abort(401) abort(401)
def update(username): current_app.logger.info('update') login_key = request.form['login_key'] user = User.get_user(login_key) if username == user.get('username', False): first_name = request.form.get('first_name', None) last_name = request.form.get('last_name', None) timezone = request.form.get('timezone', None) img_url = request.form.get('img_url', None) updated_user = {} if first_name: updated_user['first_name'] = first_name if last_name: updated_user['last_name'] = last_name if timezone: updated_user['timezone'] = timezone if img_url: updated_user['img'] = img_url User.update(username, updated_user) return jsonify({'result': {'code': 1, 'msg': 'Object updated'}}) else: abort(401)