def METHOD_NAME():
    token = request.json['data']['token']
    try:
        role_invite = RoleInvite.query.filter_by(hash=token).one()
    except NoResultFound:
        raise NotFoundError({'source': ''}, 'Role Invite Not Found')
    else:
        try:
            user = User.query.filter_by(email=role_invite.email).first()
        except NoResultFound:
            raise NotFoundError(
                {'source': ''}, 'User corresponding to role invite not Found'
            )
        try:
            role = Role.query.filter_by(name=role_invite.role_name).first()
        except NoResultFound:
            raise NotFoundError(
                {'source': ''}, 'Role corresponding to role invite not Found'
            )
        event = Event.query.filter_by(id=role_invite.event_id).first()
        uer = (
            UsersEventsRoles.query.filter_by(user=user)
            .filter_by(event=event)
            .filter_by(role=role)
            .first()
        )
        if not uer:
            if role_invite.role_name == 'owner':
                past_owner = UsersEventsRoles.query.filter_by(
                    event=event, role=role
                ).first()
                oldrole = Role.query.filter_by(name='organizer').first()
                prevuser = User.query.filter_by(id=past_owner.user_id).first()
                if past_owner:
                    delete_previous_uer(past_owner)
                    puer = UsersEventsRoles(user=prevuser, event=event, role=oldrole)
                    save_to_db(puer, 'User Event Role changed')
            role_invite.status = "accepted"
            save_to_db(role_invite, 'Role Invite Accepted')
            # reset the group of event
            event.group_id = None
            save_to_db(event, 'Group ID Removed')
            uer = UsersEventsRoles(user=user, event=event, role=role)
            save_to_db(uer, 'User Event Role Created')
            if not user.is_verified:
                user.is_verified = True
                save_to_db(user, 'User verified')
    return jsonify(
        {
            "email": user.email,
            "event": role_invite.event_id,
            "event_identifier": role_invite.event.identifier,
            "name": user.fullname if user.fullname else None,
            "role": uer.role.name,
        }
    )