fixing joi validation

This commit is contained in:
knighthawk4227 committed 2025-05-07 19:26:00 -07:00
1 parent 15dd4e0d20
commit 29d682c4e8
2 files changed
+8 -8

No files matched your search

+3 -3
View File
@@ -110,10 +110,10 @@ app.get('/reset/:token', async (req, res) => {
app.post('/resetLink', async (req, res) => {
const { token, password, confirmPassword, } = req.body;
const passwordSchema = joi.object({
password: joi.string().max(20).min(6).required(),
confirmPassword: joi.string().max(20).min(6).required(),
password: joi.string().max(20).required(),
confirmPassword: joi.string().max(20).required(),
});
const valid = passwordSchema.validate(req.body);
const valid = passwordSchema.validate({ password, confirmPassword });
if (valid.error) {
console.log("houston we have a problem");
req.session.error = 'Invalid input';
+5 -5
View File
@@ -6,7 +6,7 @@
<div class="w-96 p-6 shadow-1g bg-white rounded-md">
<h1 class="text-3xl block text-center font-semibold">Reset Password</h1>
<hr class="mt-3">
<input type="hidden" name="token" value="<%=token %>" >
<input type="hidden" name="token" value="<%=token %>">
<div class="mt-3">
<label for="password" class="block text-base mb-2">New Password:</label>
<input type="text" id="password" name="password"
@@ -19,18 +19,18 @@
class="border focus:border-gray-600 w-full rounded-md text-base px-2 py-1 focus:outline-none focus:ring-0 "
placeholder="ReType Password" />
</div>
<% if (typeof errMessage !== 'undefined') { %>
<% if (typeof errMessage !=='undefined' ) { %>
<div class="text-red-800 font-bold" id="forgor">
<%= errMessage %>
</div>
<% } %>
<div class="mt-5">
<button type="submit"
class="cursor-pointer border-2 border-gray-600 bg-blue-600 text-white py-1 w-full rounded-md hover:bg-transparent hover:text-indigo-700 font-semibold">Send
reset Link</button>
class="cursor-pointer border-2 border-gray-600 bg-blue-600 text-white py-1 w-full rounded-md hover:bg-transparent hover:text-indigo-700 font-semibold">Change
Password</button>
</div>
</div>
</form>
</div>
</main>
<%- include("./partials/footer") %>
<%- include("./partials/footer") %>