Skip to content

Commit

Permalink
fix(csrf): fixes csrf error + adds 30 character limit
Browse files Browse the repository at this point in the history
  • Loading branch information
Artlfmj committed Oct 9, 2023
1 parent 5b5e95b commit a1a436b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
2 changes: 0 additions & 2 deletions src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@ app.use(
})
);

app.use(csrf());
app.use(addCSRF)

app.use(flash());
// Initialize Passport and session middleware
Expand Down
4 changes: 2 additions & 2 deletions src/utils/limiter.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ const rateLimit = require("express-rate-limit");


const limiter = rateLimit({
windowMs: 15 * 60 * 1000, // 15 minutes
max: 5, // 5 requests per windowMs
windowMs: 1 * 60 * 1000, // 15 minutes
max: 30, // 5 requests per windowMs
message: "Too many requests from this IP, please try again later.",
});

Expand Down
10 changes: 8 additions & 2 deletions src/views/course-create.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@
<div class="wizard-form-error"></div>
</div>
<div class="form-group">
<textarea type="text" class="form-control" id="shortDescription" name="shortDescription"></textarea>
<textarea type="text" class="form-control" id="shortDescription" name="shortDescription" oninput="limitShortDescription(this, 30)"></textarea>
<label for="shortDescription" class="wizard-form-text-label">Short Description</label>
<div class="wizard-form-error"></div>
</div>
</div>
<div class="form-group">
<textarea type="text" class="form-control" id="longDescription" name="longDescription"></textarea>
<label for="longDescription" class="wizard-form-text-label">Long Description</label>
Expand Down Expand Up @@ -122,6 +122,12 @@
</div>
</section>
<script>
function limitShortDescription(element, maxLength) {
const inputValue = element.value;
if (inputValue.length > maxLength) {
element.value = inputValue.slice(0, maxLength);
}
}
jQuery(document).ready(function() {
// click on next button
jQuery('.form-wizard-next-btn').click(function() {
Expand Down

0 comments on commit a1a436b

Please sign in to comment.