-
Notifications
You must be signed in to change notification settings - Fork 0
Omar #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Omar #3
Changes from all commits
b360ef8
7997998
e2bca72
f48c414
b524919
ff6af7d
9177a33
d7f3abb
ce33a1f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
reviews: | ||
enabled: true | ||
auto_review: true | ||
auto_summarize: true | ||
auto_title: true | ||
auto_title_instructions: "Generate a title based on the changes in the PR" | ||
max_comments: 10 | ||
simple_changes: false | ||
comment_lgtm: false | ||
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,30 @@ | ||||||||||
name: Deploy Flask to Heroku | ||||||||||
|
||||||||||
on: | ||||||||||
push: | ||||||||||
branches: | ||||||||||
- main | ||||||||||
|
||||||||||
jobs: | ||||||||||
deploy: | ||||||||||
runs-on: ubuntu-latest | ||||||||||
|
||||||||||
steps: | ||||||||||
- name: Checkout repository | ||||||||||
uses: actions/checkout@v3 | ||||||||||
|
||||||||||
Comment on lines
+13
to
+15
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Verification agent 🧩 Analysis chainUpdate Actions Checkout Version Static analysis indicates that using - uses: actions/checkout@v3
+ uses: actions/checkout@v4 🌐 Web query:
💡 Result: The latest version of the GitHub Action Key Details:
Summary:
Citations:
Action Required: Update GitHub Checkout Action to v4 The current workflow uses
📝 Committable suggestion
Suggested change
🧰 Tools🪛 actionlint (1.7.4)14-14: the runner of "actions/checkout@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue (action) |
||||||||||
- name: Set up Python | ||||||||||
uses: actions/setup-python@v4 | ||||||||||
with: | ||||||||||
python-version: "3.9" | ||||||||||
|
||||||||||
- name: Install dependencies | ||||||||||
run: | | ||||||||||
pip install -r requirements.txt | ||||||||||
|
||||||||||
- name: Deploy to Heroku | ||||||||||
run: | | ||||||||||
heroku login | ||||||||||
git push heroku main | ||||||||||
env: | ||||||||||
HEROKU_API_KEY: ${{ secrets.HEROKU_API_KEY }} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,4 +3,4 @@ | |
venv | ||
__pycache__ | ||
app/__pycache__ | ||
.github/workflow/*.yml | ||
Bootstrap Studio/* |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,31 @@ | ||
{ | ||
"tasks": [ | ||
{ | ||
"type": "cppbuild", | ||
"label": "C/C++: gcc.exe build active file", | ||
"command": "C:\\msys64\\ucrt64\\bin\\gcc.exe", | ||
"args": [ | ||
"-fdiagnostics-color=always", | ||
"-g", | ||
"${file}", | ||
"-o", | ||
"${fileDirname}\\${fileBasenameNoExtension}.exe" | ||
], | ||
"options": { | ||
"cwd": "${fileDirname}" | ||
}, | ||
"problemMatcher": [ | ||
"$gcc" | ||
], | ||
"group": { | ||
"kind": "build", | ||
"isDefault": true | ||
}, | ||
"detail": "Task generated by Debugger." | ||
} | ||
], | ||
"version": "2.0.0" | ||
} | ||
"tasks": [ | ||
{ | ||
"type": "cppbuild", | ||
"label": "C/C++: gcc.exe build active file", | ||
"command": "C:\\msys64\\ucrt64\\bin\\gcc.exe", | ||
"args": [ | ||
"-fdiagnostics-color=always", | ||
"-g", | ||
"${file}", | ||
"-o", | ||
"${fileDirname}\\${fileBasenameNoExtension}.exe" | ||
], | ||
"options": { | ||
"cwd": "${fileDirname}" | ||
}, | ||
"problemMatcher": ["$gcc"], | ||
"group": { | ||
"kind": "build", | ||
"isDefault": true | ||
}, | ||
"detail": "Task generated by Debugger." | ||
} | ||
], | ||
"yaml.customTags": [ | ||
"!Scalar-example scalar", | ||
"!Seq-example sequence", | ||
"!Mapping-example mapping" | ||
], | ||
"version": "2.0.0" | ||
} |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -1,15 +1,25 @@ | ||||||||||||||||||||||||||||||||
from flask import Blueprint, render_template | ||||||||||||||||||||||||||||||||
auth = Blueprint('user', __name__) | ||||||||||||||||||||||||||||||||
# login_manager.login_view = 'login' # Redirect to login page if not logged in | ||||||||||||||||||||||||||||||||
from flask_login import UserMixin | ||||||||||||||||||||||||||||||||
Comment on lines
1
to
+2
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Import missing dependencies The current imports are incomplete for the authentication functionality implemented in this file. -from flask import Blueprint, render_template
-from flask_login import UserMixin
+from flask import Blueprint, render_template, request, redirect, url_for, flash
+from flask_login import UserMixin, login_user, logout_user, current_user
from App import login_manager 📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||
from App import login_manager | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
# from . import routes | ||||||||||||||||||||||||||||||||
auth = Blueprint('auth', __name__) | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
users = {"admin": {"password": "password123"}} | ||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove hardcoded credentials from the code Storing plaintext passwords in the code is a serious security vulnerability. Passwords should be hashed and stored securely, preferably in a database, and never in the source code. -users = {"admin": {"password": "password123"}}
+# Configure proper user authentication with a database and password hashing
+# Example using Flask-SQLAlchemy and werkzeug:
+# from werkzeug.security import generate_password_hash, check_password_hash
+#
+# users = {} # This should be replaced with database queries Consider using a database with SQLAlchemy and implement proper password hashing using a library like passlib or werkzeug.security. 📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
class User(UserMixin): | ||||||||||||||||||||||||||||||||
def __init__(self, user_id): | ||||||||||||||||||||||||||||||||
self.id = user_id | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
@login_manager.user_loader | ||||||||||||||||||||||||||||||||
def load_user(user_id): | ||||||||||||||||||||||||||||||||
if user_id in users: | ||||||||||||||||||||||||||||||||
return User(user_id) | ||||||||||||||||||||||||||||||||
return None # If user not found | ||||||||||||||||||||||||||||||||
Comment on lines
+13
to
+17
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Improve user loading security The current user loading mechanism is simplistic and insecure. It needs to be enhanced with proper user retrieval from a database. @login_manager.user_loader
def load_user(user_id):
- if user_id in users:
- return User(user_id)
- return None # If user not found
+ # Example with SQLAlchemy:
+ # return User.query.get(int(user_id))
+
+ # Temporary implementation until database is set up:
+ if user_id in users:
+ user = User(user_id)
+ return user
+ return None 📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
@auth.route('/Login', methods=["POST", "GET"]) | ||||||||||||||||||||||||||||||||
def home(): | ||||||||||||||||||||||||||||||||
return "<h1>Login</h1" | ||||||||||||||||||||||||||||||||
return render_template('auth/login.html') | ||||||||||||||||||||||||||||||||
Comment on lines
19
to
+21
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Implement authentication logic in the login route The login route doesn't contain any authentication logic. It simply renders the template without processing the form data. @auth.route('/Login', methods=["POST", "GET"])
def home():
- return render_template('auth/login.html')
+ form_errors = []
+ if request.method == "POST":
+ username = request.form.get("email")
+ password = request.form.get("password")
+
+ # Implement proper authentication logic with password hashing
+ # Example:
+ # user = User.query.filter_by(email=username).first()
+ # if user and check_password_hash(user.password, password):
+ # login_user(user)
+ # next_page = request.args.get('next')
+ # return redirect(next_page or url_for('main.index'))
+ # else:
+ # form_errors.append("Invalid username or password")
+
+ return render_template('auth/login.html', form_errors=form_errors) Don't forget to import the necessary functions: from flask import request, redirect, url_for, flash
from flask_login import login_user |
||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
# @login_manager.user_loader | ||||||||||||||||||||||||||||||||
@auth.route("/testing") | ||||||||||||||||||||||||||||||||
def test(): | ||||||||||||||||||||||||||||||||
return render_template('base.html') | ||||||||||||||||||||||||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,17 @@ | ||
from flask import Blueprint, render_template | ||
from App import login_manager | ||
from flask import Blueprint, render_template, redirect, url_for | ||
from flask_login import login_required | ||
|
||
user_bp = Blueprint('user', __name__) | ||
|
||
from . import routes | ||
@login_manager.user_loader | ||
|
||
|
||
@user_bp.route('') | ||
@login_required | ||
def home(): | ||
return render_template('auth/login.html') | ||
return render_template('base/base.html') | ||
|
||
@login_manager.user_loader | ||
@user_bp.route("/testing") | ||
@login_required | ||
def test(): | ||
return render_template('base.html') | ||
|
||
return "testing" | ||
|
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,4 @@ | ||
* { | ||
margin: 0; | ||
padding: 0; | ||
box-sizing: border-box; | ||
} | ||
|
||
header, | ||
footer { | ||
background-color: lightgray; | ||
width: 100dvw; | ||
height: 10dvh; | ||
} | ||
|
||
header { | ||
display: flex; | ||
align-items: center; | ||
justify-content: space-around; | ||
} | ||
header a { | ||
color: black; | ||
text-decoration: none; | ||
transition: color 0.3s; | ||
} | ||
|
||
main { | ||
background-color: antiquewhite; | ||
width: 100dvw; | ||
min-height: 80dvh; | ||
footer, | ||
nav { | ||
background-color: rgb(230, 230, 230); | ||
}/*# sourceMappingURL=login.css.map */ |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,4 @@ | ||
* { | ||
margin: 0; | ||
padding: 0; | ||
box-sizing: border-box; | ||
footer, | ||
nav { | ||
background-color: rgb(230, 230, 230); | ||
} | ||
header, | ||
footer { | ||
background-color: lightgray; | ||
width: 100dvw; | ||
height: 10dvh; | ||
} | ||
header { | ||
display: flex; | ||
align-items: center; | ||
justify-content: space-around; | ||
a { | ||
color: black; | ||
text-decoration: none; | ||
transition: color 0.3s; | ||
} | ||
} | ||
main { | ||
background-color: antiquewhite; | ||
width: 100dvw; | ||
min-height: 80dvh; | ||
} | ||
// body { | ||
// display: grid; | ||
// place-content: center; | ||
// width: 100dvw; | ||
// height: 100dvh; | ||
// } | ||
// h1 { | ||
// font-size: 3rem; | ||
// font-family: serif; | ||
// text-transform: uppercase; | ||
// letter-spacing: 0.5em; | ||
// } |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"name":"","short_name":"","icons":[{"src":"/android-chrome-192x192.png","sizes":"192x192","type":"image/png"},{"src":"/android-chrome-512x512.png","sizes":"512x512","type":"image/png"}],"theme_color":"#ffffff","background_color":"#ffffff","display":"standalone"} |
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -1,8 +1,64 @@ | ||||||||||||||
{% extends "base.html" %} {% block title %}Home - My Website{% endblock %} {% | ||||||||||||||
block content %} | ||||||||||||||
<div class="text-center"> | ||||||||||||||
<h1 class="display-4">Welcome to My Website</h1> | ||||||||||||||
<p class="lead">This is a Bootstrap-enhanced Flask application.</p> | ||||||||||||||
<a href="{{ url_for('about') }}" class="btn btn-primary">Learn More</a> | ||||||||||||||
</div> | ||||||||||||||
{% extends "base/base.html" %} {% block title %}Home - My Website{% endblock %} | ||||||||||||||
{% block content %} | ||||||||||||||
<section class="position-relative py-4 py-xl-5"> | ||||||||||||||
<div class="container"> | ||||||||||||||
<div class="row mb-5"> | ||||||||||||||
<div class="col-md-8 col-xl-6 text-center mx-auto"> | ||||||||||||||
<h2>Log in</h2> | ||||||||||||||
<p class="w-lg-50"> | ||||||||||||||
Curae hendrerit donec commodo hendrerit egestas tempus, turpis | ||||||||||||||
facilisis nostra nunc. Vestibulum dui eget ultrices. | ||||||||||||||
</p> | ||||||||||||||
</div> | ||||||||||||||
</div> | ||||||||||||||
<div class="row d-flex justify-content-center"> | ||||||||||||||
<div class="col-md-6 col-xl-4"> | ||||||||||||||
<div class="card mb-5"> | ||||||||||||||
<div class="card-body d-flex flex-column align-items-center"> | ||||||||||||||
<div class="bs-icon-xl bs-icon-circle bs-icon-primary bs-icon my-4"> | ||||||||||||||
<svg | ||||||||||||||
xmlns="http://www.w3.org/2000/svg" | ||||||||||||||
width="1em" | ||||||||||||||
height="1em" | ||||||||||||||
fill="currentColor" | ||||||||||||||
viewBox="0 0 16 16" | ||||||||||||||
class="bi bi-person" | ||||||||||||||
> | ||||||||||||||
<path | ||||||||||||||
d="M8 8a3 3 0 1 0 0-6 3 3 0 0 0 0 6m2-3a2 2 0 1 1-4 0 2 2 0 0 1 4 0m4 8c0 1-1 1-1 1H3s-1 0-1-1 1-4 6-4 6 3 6 4m-1-.004c-.001-.246-.154-.986-.832-1.664C11.516 10.68 10.289 10 8 10c-2.29 0-3.516.68-4.168 1.332-.678.678-.83 1.418-.832 1.664z" | ||||||||||||||
></path> | ||||||||||||||
</svg> | ||||||||||||||
</div> | ||||||||||||||
<form class="text-center" method="post" action=""> | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add CSRF protection to the login form The form is missing CSRF protection, which is important for security. In Flask, you should use the CSRF token provided by Flask-WTF. - <form class="text-center" method="post" action="">
+ <form class="text-center" method="post" action="">
+ <input type="hidden" name="csrf_token" value="{{ csrf_token() }}"/> Note: Make sure Flask-WTF is set up in your application with 📝 Committable suggestion
Suggested change
|
||||||||||||||
<div class="mb-3"> | ||||||||||||||
<input | ||||||||||||||
class="form-control" | ||||||||||||||
type="email" | ||||||||||||||
name="email" | ||||||||||||||
placeholder="Email" | ||||||||||||||
/> | ||||||||||||||
</div> | ||||||||||||||
<div class="mb-3"> | ||||||||||||||
<input | ||||||||||||||
class="form-control" | ||||||||||||||
type="password" | ||||||||||||||
name="password" | ||||||||||||||
placeholder="Password" | ||||||||||||||
/> | ||||||||||||||
</div> | ||||||||||||||
<div class="mb-3"> | ||||||||||||||
<button class="btn btn-primary d-block w-100" type="submit"> | ||||||||||||||
Login | ||||||||||||||
</button> | ||||||||||||||
</div> | ||||||||||||||
<a class="text-muted" href="#ForgotPassword" | ||||||||||||||
>Forgot your password?</a | ||||||||||||||
> | ||||||||||||||
Comment on lines
+54
to
+56
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Implement the forgot password functionality The "Forgot your password?" link currently points to a placeholder anchor. This should be linked to an actual forgot password route. - <a class="text-muted" href="#ForgotPassword"
- >Forgot your password?</a
- >
+ <a class="text-muted" href="{{ url_for('auth.forgot_password') }}"
+ >Forgot your password?</a
+ > 📝 Committable suggestion
Suggested change
|
||||||||||||||
</form> | ||||||||||||||
</div> | ||||||||||||||
</div> | ||||||||||||||
</div> | ||||||||||||||
</div> | ||||||||||||||
</div> | ||||||||||||||
</section> | ||||||||||||||
{% endblock %} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Configuration Schema Violation:
auto_review
The CodeRabbit configuration schema expects the
auto_review
property to be an object, but a boolean (true
) is provided here. This mismatch leads to a validation error ("Expected object, received boolean atreviews.auto_review
").For example, modify the configuration as follows:
Please update this section to match the schema.
📝 Committable suggestion