fixing joi validation
This commit is contained in:
1 parent
15dd4e0d20
commit
29d682c4e8
2 files changed
+12
-12
No files matched your search
@@ -110,10 +110,10 @@ app.get('/reset/:token', async (req, res) => {
|
|||||||
app.post('/resetLink', async (req, res) => {
|
app.post('/resetLink', async (req, res) => {
|
||||||
const { token, password, confirmPassword, } = req.body;
|
const { token, password, confirmPassword, } = req.body;
|
||||||
const passwordSchema = joi.object({
|
const passwordSchema = joi.object({
|
||||||
password: joi.string().max(20).min(6).required(),
|
password: joi.string().max(20).required(),
|
||||||
confirmPassword: joi.string().max(20).min(6).required(),
|
confirmPassword: joi.string().max(20).required(),
|
||||||
});
|
});
|
||||||
const valid = passwordSchema.validate(req.body);
|
const valid = passwordSchema.validate({ password, confirmPassword });
|
||||||
if (valid.error) {
|
if (valid.error) {
|
||||||
console.log("houston we have a problem");
|
console.log("houston we have a problem");
|
||||||
req.session.error = 'Invalid input';
|
req.session.error = 'Invalid input';
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
<div class="w-96 p-6 shadow-1g bg-white rounded-md">
|
<div class="w-96 p-6 shadow-1g bg-white rounded-md">
|
||||||
<h1 class="text-3xl block text-center font-semibold">Reset Password</h1>
|
<h1 class="text-3xl block text-center font-semibold">Reset Password</h1>
|
||||||
<hr class="mt-3">
|
<hr class="mt-3">
|
||||||
<input type="hidden" name="token" value="<%=token %>" >
|
<input type="hidden" name="token" value="<%=token %>">
|
||||||
<div class="mt-3">
|
<div class="mt-3">
|
||||||
<label for="password" class="block text-base mb-2">New Password:</label>
|
<label for="password" class="block text-base mb-2">New Password:</label>
|
||||||
<input type="text" id="password" name="password"
|
<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 "
|
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" />
|
placeholder="ReType Password" />
|
||||||
</div>
|
</div>
|
||||||
<% if (typeof errMessage !== 'undefined') { %>
|
<% if (typeof errMessage !=='undefined' ) { %>
|
||||||
<div class="text-red-800 font-bold" id="forgor">
|
<div class="text-red-800 font-bold" id="forgor">
|
||||||
<%= errMessage %>
|
<%= errMessage %>
|
||||||
</div>
|
</div>
|
||||||
<% } %>
|
<% } %>
|
||||||
<div class="mt-5">
|
<div class="mt-5">
|
||||||
<button type="submit"
|
<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
|
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
|
||||||
reset Link</button>
|
Password</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</main>
|
</main>
|
||||||
<%- include("./partials/footer") %>
|
<%- include("./partials/footer") %>
|
||||||
Reference in new issue
Block a user