def get(self): args = request.args.to_dict() _id = get_field("id", args) code = int(get_field("code", args)) user = User.find_user_by_id(_id) if not user: return jsonify( {'message': 'Account already confirmed. Please login.'}) if user.confirmed: return jsonify( {'message': 'Account already confirmed. Please login.'}) updates = { 'confirmed': True, 'confirmed_on': datetime.datetime.utcnow() } if code == user.code: User.update(str(user.id), updates) return json.loads(user.to_json()) return jsonify({'message': 'Not valid code'}), 400
def user_load(user_id): user = UserModel.find_user_by_id(user_id) return user