<template>
<ValidationProvider
name="name"
:rules="{
minmax:{min:5,max:10}}"
v-slot="{ errors}"
/>
</template>
<script>
import {ValidationObserver, ValidationProvider} from "vee-validate";
import {extend} from 'vee-validate';
extend('minmax', {
validate(value, {min, max}) {
return value.length >= min && value.length <= max;
},
params: ['min', 'max'],
message: 'The {_field_} must be between {min} and {max} symbols'
});
}
</script>
checkEmail(email) {
axios.post('auth/signin/confirm', {
user: {
email:email,
confirmation_code: this.confirmation_code
}
}).then(res => {
console.log(res);
if (res.data.success === true) {
}
})
}
, сам запрос module.exports.signinConfirm = function (req, res) {
if (process.env.APP_SIGNIN_2FA != "true") {
return res.json({success: false, message: AuthMessages.SIGNIN_CONFIRMED_NOT_ENABLED});
}
if (!req.body.user || !req.body.user.email || !req.body.user['confirmation_code']) {
return res.json({success: false, message: ErrorMessages.FILL_REQUIRED_FIELDS});
}
User.findOne({email: req.body.user.email, active: true}).then(function (user) {
if (!user) {
return res.json({success: false, message: AuthMessages.USER_NOT_EXIST});
}
if (user.signinToken != req.body.user['confirmation_code']) {
return res.json({success: false, message: AuthMessages.TOKEN_NOT_VALID});
}
if (process.env.APP_SIGNIN_2FA_TTL) {
let currentDateTime = new Date();
let tokenTimeDiff = currentDateTime.getTime() - user.signinTokenDate.getTime();
if (Math.round(tokenTimeDiff / 60000) > process.env.APP_SIGNIN_2FA_TTL) {
return res.json({success: false, message: AuthMessages.TOKEN_EXPIRED});
}
}
user.signinToken = null;
user.signinTokenDate = null;
user.save(function (err) {
if (err) {
return res.json({success: false, message: err.message});
} else {
passport.authenticate('local', {'session': true})(req, res, function () {
return res.json({success: true, message: AuthMessages.SIGNIN_SUCCESSFUL});
});
}
});
});
}