The IReporter App is a Flask-based server for managing redflags and interventions. It includes features for user authentication, token verification, and role-based access control. The application integrates with Cloudinary for media uploads and uses JSON Web Tokens (JWT) for secure API access.
- User authentication and JWT-based session management
- User and admin roles with specific access permissions
- Upload and management of redflags and interventions with media support
- Token-based verification for user accounts
- Admin functionality for updating user roles and status
- Python 3.8 or higher
- Virtualenv
- Flask
- SQLAlchemy
- Cloudinary
-
Clone the repository:
git clone git@github.com:john7319/IReporter-server.git cd ireporter-app
-
Create and activate a virtual environment:
pipenv --python /usr/bin/python pipenv shell
-
Install the dependencies:
pipenv install
-
Set up environment variables:
Create a
.env
file in the root directory and add the following:DATABASE_URI=your_database_uri CLOUD_NAME=your_cloud_name API_KEY=your_api_key API_SECRET=your_api_secret
-
Initialize the database:
flask db upgrade
-
Run the application:
flask run
-
Login
POST /login
Request body:
{ "email": "user@example.com", "password": "your_password" } Response: { "access_token": "your_jwt_token" }
-
Check Session
GET /check_session
Requires JWT in the Authorization header.
Response: { "id": 1, "name": "User Name", "email": "user@example.com", "image": "image_url", "role": "user", "intervention": [/* ... */], "redflags": [/* ... */], "token_verified": true, "is_active": true, "requesting_admin": false }
GET /users
Response: [ { "id": 1, "name": "User Name", "email": "user@example.com", "role": "user", "token_verified": true, "is_active": true, "requesting_admin": false } ]
POST /users
Request body: { "name": "New User", "email": "newuser@example.com", "password": "new_password" } Response: { "success": "User created successfully! Verification token sent to email.", "user": { "id": 2, "name": "New User", "email": "newuser@example.com", "role": "user", "token_verified": false, "is_active": true } }
PATCH /users/<int:user_id>
Request body: { "email": "updateduser@example.com", "image": "new_image_url", "old_password": "current_password", "new_password": "new_password" } Response: { "success": "User updated successfully.", "user": { "id": 1, "name": "Updated User", "email": "updateduser@example.com", "role": "user", "token_verified": true, "is_active": true } }
PATCH /admin/users/<int:user_id>/update-token
Request body: { "token_verified": true } Response: { "success": "User token verification status updated successfully." }
PATCH /admin/users/<int:user_id>/update-status
Request body: { "is_active": false } Response: { "success": "User status updated successfully." }
We welcome contributions to the IReporter App! If you'd like to contribute, please follow these guidelines:
-
Fork the Repository
- Click on the "Fork" button at the top right of the repository page to create your own copy of the project.
-
Create a New Branch
- Navigate to your forked repository and create a new branch for your feature or bug fix. Use a descriptive name for your branch, e.g.,
feature/new-feature
.
- Navigate to your forked repository and create a new branch for your feature or bug fix. Use a descriptive name for your branch, e.g.,
-
Make Your Changes
- Implement your changes and make sure to write clear and concise commit messages. Follow the existing code style and conventions of the project.
-
Test Thoroughly
- Ensure that your changes are well-tested. Run all existing tests and write new tests if necessary to cover your modifications.
-
Submit a Pull Request
- Go to the "Pull Requests" section of the original repository and click "New Pull Request." Select your branch and provide a detailed description of your changes. Explain why the changes are necessary and how they improve the project.
-
Review Process
- Your pull request will be reviewed. Be prepared to make additional changes if requested.
Thank you for contributing to the IReporter App!